‎2005 Jun 15 12:01 AM
Hi, i need to call a single form with different table names as parameters depending on conditions.
for eg here is the approach
if flag1_is_set
call form1 multiple times with table1, table2....... as parameters
"and i can avoid this
" form 1 using table 1
" form 1 using table 2
" form 1 using table 3
" form 1 using table 4
" form 1 using table 5
elseif
flag2_is_set
form 1 using table 2
elseif
flag3_is_set
form 1 using table 3.
-
but i cannot call forms like this. can someone suggest
an equivalent implementation on how to do this.
if i dont implement in the above mentioned approach i have to code the same thing with minor changes multiple times
thanks.
your help would be appreciated.
kranthi.
‎2005 Jun 15 2:01 AM
I dont think you have any other option but to use perform several times with different tables .OR if you like
Loop at internal tables (of difftable names )
Perform < >> using inttab-intabname.
endloop.
‎2005 Jun 15 2:01 AM
I dont think you have any other option but to use perform several times with different tables .OR if you like
Loop at internal tables (of difftable names )
Perform < >> using inttab-intabname.
endloop.
‎2005 Jun 15 4:43 AM
Hi,
I assume that you want to call the form at the maximum 3 times if flag1 is set.
if ( flag1 = 'X' or flag2 = 'X' or flag3 = 'X').
Perform form1 tables
table1 table2 table3.
endif.
If flag2 is set,then I assume that you are refreshing table1 and table3.Then in that case those tables are initial.So it won't affect.Similarly for flag3.
‎2005 Jun 15 6:17 AM
Hi Kranthi,
You have mentioned that you are calling the sub-routine using different tablenames.Sadly enough you have to call the perform several times.We could help you out if you could give us the exact requirements.You can use the solution suggested by Jayanthi as long as you have values passed to all the formal parameters or the one suggested by Bhandari.
Please close the thread by awarding some reward points.In case you have any more questions please post the same.
Cheers
Nishanth
‎2005 Jun 15 6:39 PM
You might try passing a field symbol (itab) in the tables.
And assign the filed symbol with your itab as per the condition.
Check if the program below gives you any idea.
REPORT Z_RAM_DYN_TAB_IN_FORM.
PARAMETERS : P_TAB1 TYPE C.
DATA: lt_users2 type standard table of usr02.
DATA: lt_users1 type standard table of usr01.
FIELD-SYMBOLS: <fs_itab> type standard table.
SELECT * into table lt_users1 FROM usr01.
SELECT * into table lt_users2 FROM usr02.
IF P_TAB1 eq 'X'.
ASSIGN lt_users1 to <fs_itab>.
ELSE.
ASSIGN lt_users2 to <fs_itab>.
ENDIF.
PERFORM test_form TABLES <fs_itab>.
FORM test_form TABLES x_itab .
FIELD-SYMBOLS: <fs_wa> type any.
FIELD-SYMBOLS: <fs_field> type any.
LOOP AT x_itab ASSIGNING <fs_wa>.
DO 5 times. "Write first 5 fields of itabs.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_wa> to <fs_field>.
WRITE : <fs_field>.
ENDDO.
WRITE :/.
ENDLOOP.Thanks,
Ram
Message was edited by: Ram Manohar Tiwari