Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Fill itab in form-routine - field unknown

Former Member
0 Kudos

Hi there,

My first attempt at smartforms isn't working out. I'm trying to fill a custom made internal table with data that I collect from the database in a custom form.

The itab definition is there in the 'Types' tab. Also I've declared the table and its needed workarea.

In the init tab I call my form, which can be found in the form-routines tab. The form collects various data from tables, places is in the workarea and finally appends that workarea to the corresponding itab.

As far as I know everything is in place there. The error message I'm getting is that the workarea field is unknown. The definition itself can be found and the itab and workarea are being created.

In the documentation I've found that I cannot access the structure unless I explicitly pass it on to the form... but how? Thx in advance for the suggestions.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi E.Venema,

1. We can use like this.

FORM DEFINITION :

form abc tables tab1 structure mara

using p1 structure t001

p2 structure itab.

endform.

USING PERFORM :

PERFORM ABC TABLES MYITAB USING MYP1 MYP2.

2. The Form DEFINITION is important.

The word STRUCTURE is important.

inside the form, we can access the

fields of the structure. (other wise not)

3. The STRUCTURE can be in database

or defined in TYPES tab as u said.

Regards,

Amit M.

Message was edited by: Amit Mittal

17 REPLIES 17

Former Member
0 Kudos

Hi,

In SMARTFORMS, in the form interface, if you are passing your custom made internal table with its reference type then there should not be any problem.

Though it would be better if you create a structure in SE11 and use the same in both the places (in the calling program and in the smartforms)

regards,

Satya

Former Member
0 Kudos

Hi Venema,

When you write your code in <b>'program lines'</b> of smartform, In <b>'General Attributes'</b> tab, you can define <b>'Input Parameters' and 'Output Parameters'</b> for the code written.

In this way, you can pass your internal table to the program code and the same will appear in 'output parameters' too...

Regards,

Raj

Former Member
0 Kudos

Hi

You should use the field-symbols to define automatically a structure.

But you should know your code.

Max

Former Member
0 Kudos

Hi E.Venema,

1. We can use like this.

FORM DEFINITION :

form abc tables tab1 structure mara

using p1 structure t001

p2 structure itab.

endform.

USING PERFORM :

PERFORM ABC TABLES MYITAB USING MYP1 MYP2.

2. The Form DEFINITION is important.

The word STRUCTURE is important.

inside the form, we can access the

fields of the structure. (other wise not)

3. The STRUCTURE can be in database

or defined in TYPES tab as u said.

Regards,

Amit M.

Message was edited by: Amit Mittal

Former Member
0 Kudos

Hi Venema,

Check if you have declared the table and work area in Global data tab.

Now, call the form as :

Perform formA tables itab1 using struct1.

itab1(internal table) and struct1(work area) should be declared in Global data.

Now in the form routines tab write the routine code as:

Form formA tables p_itab1 structure ty_table(declared in types) using p_struct1 type ty_table.

Hope it helps...

Lokesh

Pls reward appropriate points

0 Kudos

Hi Lokesh,

Both the table and workarea are declared in the Global Data tab. The perform statement I can understand, but where do the different fields in the form statement come from?

If I declared the name 'blah' for my itab and 'wa_blah' for the workarea, then the form would look like this:

FORM <formname>

TABLES p_blah (new name for inside the form)

STRUCTURE ty_table (a 3rd declaration in types?)

USING p_wa_blah (once again a new name)

TYPE ty_table (the 3rd declaration again)

The new names for inside the form I can understand, that's to make sure you know where you put your data, but where does the ty_table come from?

The answers so far were helpfull (so increase my understanding of how smartforms handles data), but as I read it there are multiple ways of making this work?

Egbert (Venema is my surname.. adjusted profile )

0 Kudos

Hi again,

1. what is the purpose of your FORM routine ?

2. I suppose it takes some internal table

and provides data into the same internl table.!

3. but where does the ty_table come from?

It does not come from anywhere.

It is we who tell the form

about the structure of the internal table

( so that inside the form we can

use the fields of that internal table)

4. USING p_wa_blah (once again a new name)

TYPE ty_table (the 3rd declaration again)

this is not required,

U can declare a work area inside

the form itself.

Kindly see help form FORM.

Type FORM in se38 and press F1.

regards,

amit m.

Message was edited by: Amit Mittal

0 Kudos

Hi

I think you can't use this way to define your routine becuase you should use a dictionary structure:

FORM <formname>

TABLES p_blah (new name for inside the form)

STRUCTURE <ZSTRUCUTRE> <----


from dictionary

USING p_wa_blah (once again a new name)

TYPE ty_table (the 3rd declaration again)

But you can use this declaration:

- TYPES TAB

TYPES: BEGIN OF TY_MY_WORK_AREA,

.... TYPE ....

END OF TY_MY_WORK_AREA.

- FORM TAB

FORM <FORM> USING P_TABLE TYPE STANDARD TABLE OF TY_MY_WORK_AREA.

ENDFORM.

or you can also do:

- TYPES TAB

TYPES: BEGIN OF TY_MY_WORK_AREA,

.... TYPE ....

END OF TY_MY_WORK_AREA.

TYPE: MY_TABLE TYPE STANDARD TABLE OF TY_MY_WORK_AREA.

- FORM TAB

FORM <FORM> USING P_TABLE TYPE MY_TABLE

P_WA TYPE TY_MY_WORK_AREA.

LOOP AT P_TABLE INTO P_WA.

ENDLOOP.

ENDFORM.

Max

Message was edited by: max bianchi

0 Kudos

Hi Amit,

The function of the form is indeed to fill the internal table with data. It consists of two select-statements which fill the workarea (into corresponding fields of) and eventually append the workarea to the internal table.

To give you an idea of what everything looks like, let's say I've declared the following structure in the 'Types' tab. This is only a small part, but that doesn't matter for the execution.

TYPES:

BEGIN OF tablestructure,

name TYPE but000-name_first,

city TYPE adrc-city1,

END OF tablestructure.

In the 'Global Data' tab, I've declared two tables:

itab TYPE tablestructure,

wa_itab TYPE tablestructure

In responce to earlier replies, In the 'Initialization' tab, I've added both (itab and wa_itab) to the 'Input Parameters' and 'Output Parameters' list.

Also the perform statement is there:

PERFORM function TABLES itab USING wa_itab.

Finally in the 'Form Routines' there is the form itself:

FORM function TABLES itab STRUCTURE wa_itab (still working on this, but same names should matter to the program).

The rather strange message that is returned by the system is that ITAB isn't an internal table, since the 'OCCURS n' specification is missing. I'm aware of that, but I thought the data definitions were all in the 'Global Data' tab, at which I can't add such a specification.

I hope this explains the problem better...

0 Kudos

Hi

see my answer above!

If you want to create a routine without to link a particular table you can do that:

FORM <MY_FORM> USING P_TABLE TYPE TABLE

WA.

LOOP AT P_TABLE INTO WA.

ENDLOOP.

ENDFORM.

In this case the structure of p_table and wa depend on while using this routine.

0 Kudos

Hi again,

1. In the 'Global Data' tab, I've declared two tables:

itab TYPE tablestructure,

wa_itab TYPE tablestructure

declare ITAB using LIKE (and not type)

regards,

amit m.

0 Kudos

Hi again,

I tried at my end.

It was giving same error.

Do this.

1. In initalization,

declare :

data : itab like table of tablestructure.

2. then perform.

PERFORM function TABLES itab USING wa_itab.

3. I tried this at my end.

and now it does not give the error u said.

regards,

amit m.

0 Kudos

Hi Egbert,

FORM <formname>

TABLES p_blah (new name for inside the form, you can use the same name)

STRUCTURE ty_table (the same declaration as in types for internal table ->for the form routine to understand the type of the table used)

USING p_wa_blah (not a new name, its just to identify that its a parameter, you can use the same name as the work area you declared in global data)

TYPE ty_table (same as internal table, just for dclaration of the work area in the form)

This is a general ABAP (Perform and Form stmts)

Eg:


Data:
     PROJECT type table of ZST_PL_PROJECT,
     wa_project type ZST_PL_PROJECT,
     MESSAGES type table of  BAPIRET2,
     COMMENTS type table of  ZST_TEXT_LINES.

PERFORM CHECK_INPUT_VALIDATIONS           
                   TABLES PROJECT
                          MESSAGES
                          COMMENTS
                   USING  wa_project

In the Form Routines Tab.
FORM CHECK_INPUT_VALIDATIONS TABLES
                      P_PROJECT STRUCTURE ZST_PL_PROJECT
                      MESSAGES  STRUCTURE BAPIRET2
                      COMMENTS  STRUCTURE ZST_TEXT_LINES
                      USING
                      wa_project TYPE ZST_PL_PROJECT.

Hope it helps...

Lokesh

Pls. do reward appropriate points by clicking the stars on the left side, if the answer helps.

0 Kudos

I see there are a couple of things I should try to make it work. However the position of the Global Data tab is now getting unclear.

My understanding was that it was the place to declare variables. A 'var TYPE vartype' would be exactly the same as putting it in a DATA: block in the 'Initialization' tab. However here I see seperate declarations in the solutions.

I realise that the Form and Perform statements are standard ABAP... however in the crash course I attended all data declarations were global and therefore always accessable. I'll study those chapters again...

There are a couple of screens in which I can assign data elements. Declarations, types, input and output in various screens. The declaration in Global Data and the Types tab are all good, since the itab and workarea are created with the correct structure.

Keep in mind I'm still figuring out smartforms, so things you state as obvious can be totally new to me Going to try everything above, thx.

0 Kudos

Hi again,

1. did your problem get solved ?

2. As per forum etiquette, if u find

any answer helpful, pls reward points

by clicking on the STAR to the left of the reply.

regards,

amit m.

0 Kudos

Still trying all suggestions. Don't worry, i'll award points

Former Member
0 Kudos

Hi Venema,

The new names which you find in the form routine are supplied by SAP itself...

You can reatin them, or change..no problem... (these are formal parameters)

Actual parameters are those which u pass while calling the subroutine passing along the internal table etc...to be used in the routine...

formal parameters are the way to address and use the actual values passed to the routine...

Example:

PERFORM bdc_field USING 'RM07I-ZLDAT' it_data-date.

FORM bdc_field USING fnam fval.

CLEAR bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

APPEND bdcdata.

ENDFORM. "bdc_field

Here, fnam will have RM07I-ZLDAT AND fval will have it_data-date in the sub-routine.

Regards,

Raj