‎2006 Dec 27 6:53 PM
Hello Experts,
I need to write the each content (each row) of my internal table to output parameters (out1, out2,out3...outn) of my Func Module.
The internal table has only one column. The contents of my internal table is as follows:
cont1
cont2
cont3
..............
-
contn
output should be :
out1 = cont1
out2 = cont2
-
outn = contn
Pls tell me if this a way of doing this. Points will be awarded.
thanks
Dany
‎2006 Dec 27 7:29 PM
Hi,
I believe the exporting parameters is static..You cannot create exporting parameters on the fly..
Thanks,
Naren
‎2006 Dec 27 7:00 PM
You can use field symbols for this. Questions, are CONT1, CONT2, CONT3 are these varaibles names within the function module? Are the field names always like this CONT and (1) numeric or alpha? What about OUT1, OUT2, etc, same thing here? Always OUT and numeric or alpha? If so you can build the field names on the fly and assign to field symbols in order to move them.
Regards,
Rich Heilman
‎2006 Dec 27 7:04 PM
Hi,
You can do it using field-symbols..
But if there are more number of rows in the internal table than the number of exporting parameters...what should happen..
Or it the number of rows in the internal table is always fixed as the number of exporting parameters..
Thanks,
Naren
‎2006 Dec 27 7:05 PM
Hi Dan,
Its like if you have particular number of output parameters (suppose 5 output parameters) then you can loop on internal table and assign the values like:
Read table itab into x_itab index 1.
out1 = x_itab-field.
Read table itab into x_itab index 2.
out2 = x_itab-field.
Read table itab into x_itab index 3.
out3 = x_itab-field.
Read table itab into x_itab index 4.
out4 = x_itab-field.
Read table itab into x_itab index 5.
out5 = x_itab-field.
Otherwise,
You can use the output parameter as Table and pass your table to it directly and take you internal table in the program and work with it.
Regards,
Amandeep Kumar
‎2006 Dec 27 7:06 PM
Something like this maybe.
report zrich_0001.
data: cont1 type c value 'A',
cont2 type c value 'B',
cont3 type c value 'C',
cont4 type c value 'D'.
data: out1 type c,
out2 type c,
out3 type c,
out4 type c.
data: begin of itab occurs 0,
fld(30) type c,
end of itab.
data: out_field(30).
field-symbols: <fs_i>,
<fs_o>.
itab-fld = 'CONT1'. append itab.
itab-fld = 'CONT2'. append itab.
itab-fld = 'CONT3'. append itab.
itab-fld = 'CONT4'. append itab.
loop at itab.
assign (itab-fld) to <fs_i>.
out_field = 'OUT'.
out_field+3(1) = itab-fld+4(1).
assign (out_field) to <fs_o>.
<fs_o> = <fs_i>.
endloop.
write:/ out1, out2, out3, out4.
Regards,
RIch Heilman
‎2006 Dec 27 7:12 PM
Hi Rich,
CONT1..etc are contents of my itab. It can be num or alphanum..& its char type.
The field names can be num or alphanu.
OUT 1, OUT2 are export params of FM ..just display the content of my itab.
Q) How can we build the field names on the fly and assign to field symbols in order to move them? Pls tell me using Work Areas?
Narendra:
Thanks for your response.
The no of rows of internal table is not fixed...can u help me doing this with work areas ?
Thanks
‎2006 Dec 27 7:19 PM
Hi,
Check this example..
DATA: BEGIN OF itab OCCURS 0,
value(10),
END OF itab.
itab-value = 'CONT1'.APPEND itab.
itab-value = 'CONT2'.APPEND itab.
itab-value = 'CONT3'.APPEND itab.
***Assuming if you have three exporting parameters..
***Named OUT1 OUT2 & OUT3
DATA: v_field(30).
DATA: v_char(5).
FIELD-SYMBOLS: <fs>.
DO.
READ TABLE itab INDEX sy-index.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CLEAR: v_field.
v_char = sy-index.
SHIFT v_char LEFT DELETING LEADING space.
CONCATENATE 'OUT' v_char INTO v_field.
ASSIGN (v_field) TO <fs>.
<fs> = itab-value.
ENDDO.
Thanks,
Naren
‎2006 Dec 27 7:28 PM
Hi All,
The no of rows of internal table is not fixed.
Cant we build the export parameters of the FM dynamically based on no of records in itab.
thanks
‎2006 Dec 27 7:29 PM
Hi,
I believe the exporting parameters is static..You cannot create exporting parameters on the fly..
Thanks,
Naren
‎2006 Dec 27 7:46 PM
Hi Naren,
I am getting the output provided its for fixed no of output params.
Please tell me if i can do it like this
LOOP AT itab INTO wa_itab.
IF sy-tabix = 1.
strout1 = wa_itab-f1.
ELSEIF sy-tabix = 2.
strout2 = wa_itab-f1.
ELSEIF sy-tabix = 3.
strout3 = wa_itab-f1.
ELSEIF sy-tabix = 4.
strout4 = wa_itab-f1.
ELSEIF sy-tabix = 5.
strout5 = wa_itab-f1.
ELSEIF sy-tabix = 6.
strout6 = wa_itab-f1.
ELSEIF sy-tabix = 7.
strout7 = wa_itab-f1.
ELSEIF sy-tabix = 8.
strout8 = wa_itab-f1.
ELSEIF sy-tabix = 9.
strout9 = wa_itab-f1.
ENDIF.
ENDLOOP.
‎2006 Dec 27 7:55 PM
‎2006 Dec 27 7:58 PM