Application Development and Automation 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: 
Read only

Passing Tables dynamically to Form

Former Member
0 Likes
1,143

Hi,

I have a small peculiar requirement, I have to pass an Internal table dynamically to

a form. Actually, this form should work for four different internal table of different types. But, the logic is same for these four tables. Depending on some condition, I

will pass different internal table to that form.

for example, I have written the code like this:

if cond1..

perform form_name using it_table1.

elseif cond2.

perform form_name using it_table2.

elseif cond3.

perform form_name using it_table3.

elseif cond4.

perform form_name using it_table4.

endif.

form form_name using it_table type any.

loop at it_table.

-


-


endloop.

endform.

This code is giving the error "it_table is not declared as table or Generic type'.

How to handle this scenario?

Could you please anybody help on this...

Thanks,

AJ

Hi,

I have a small peculiar requirement, I have to pass an Internal table dynamically to

a form. Actually, this form should work for four different internal table of different types. But, the logic is same for these four tables. Depending on some condition, I

will pass different internal table to that form.

for example, I have written the code like this:

if cond1..

perform form_name using it_table1.

elseif cond2.

perform form_name using it_table2.

elseif cond3.

perform form_name using it_table3.

elseif cond4.

perform form_name using it_table4.

endif.

form form_name using it_table type any.

loop at it_table.

-


-


endloop.

endform.

This code is giving the error "it_table is not declared as table or Generic type'.

How to handle this scenario?

Could you please anybody help on this...

Thanks,

AJ

9 REPLIES 9
Read only

Former Member
0 Likes
1,110

Change this :

form form_name using it_table type any <b>TABLE</b>.

loop at it_table.

-


-


endloop.

endform.

This should do.

Thanks and Regards,

Srihari

Read only

0 Likes
1,110

Hi Srihari,

Agaun it is giving error like ' formal parameters and actual parameters are incompatable'

regards,

Ajay

Read only

0 Likes
1,110

Have you defined a header line for your internal table ??

If yes, try to avoid it.

If you cant :

Call the perform like this

perform <form_name> using it_table[].

Thanks and Regards,

Srihari

Read only

0 Likes
1,110

Hi Srihari,

Still i am getting same error.

regards,

Ajay

Read only

0 Likes
1,110

Can you please post a part of your code:

1) Your data declarations

2) Perform call

3) Form routine

Read only

former_member194669
Active Contributor
0 Likes
1,110

Hi,

may be this way.


define form_name.
loop at &1.
----
----
endloop.


endefinition.

if condition eq 'XXXXXXXX'
form_name it_table1.
form_name it_table2.
form_name it_table3.
elseif cond4.
form_name it_table4.
endif.

Only disadvantage by using macro. within the loop you could not debug

aRs

Read only

Former Member
0 Likes
1,110

Hi,

Please try this.


If <cond1>.
  perform form_name tables it_table1.
elseif <cond2>.
  perform form_name tables it_table2.
elseif <cond3>.
  perform form_name tables it_table3.
elseif <cond4>.
  perform form_name tables it_table4.
endif.


form form_name tables p_table.

  loop at p_table.
    ...
  endloop.

endform.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,110

Hi,

This is one of the way. It uses field symbols.

For Eg:

PERFORM appl_upload USING gv_header 'gt_header[]'.

PERFORM appl_upload USING gv_header1 'gt_header1[]'.

PERFORM appl_upload USING gv_header2 'gt_header1[]'.

Here gt_header, gt_header1 and gt_header2 can have different structures. As you can see you are just passing the name of the table as a constant.

FORM appln_upload USING gv_header type ...

tabname type string.

FIELD SYMBOL: <tab> type any.

ASSIGN (tabname) to <tab>.

LOOP AT <tab>..."can do u r processing.....

ENDFORM.

So in the form as u can see, u pass the tabname to the fieldsymbol.

In this way you can use the same perform though the structurs used in it are different.

Sri

Read only

Former Member
0 Likes
1,110

Is your problem solved? Or u need any further info.

Sri