‎2008 Apr 24 8:20 AM
I have an internal table with the following structure and data:
fld1 fld2 fld3 fld4 fld5
XY 123 001 line1 tag1
XY 123 002 line2 tag2
XY 234 001 line3 tagx
XY 345 001 linex tagy
XY 345 002 liney tagx
XY 345 003 linez tagz
YX 111 001 abc def
YX 111 002 abd yyy
In this table, the first two fields r used to create header and the last two as items..in a function module. I need to call a function module and pass header (structure) and items (table) depending upon the third field..
for example, in above itab..
XY and 123 form one header and it has two items 001 and 002 with different fld4 and fld5 values..for this header and item combination i want to call a function module..
similarly, for another group as loop moves further..
any logic??
pls
‎2008 Apr 24 8:27 AM
Here you can use ON CHANGE OF command.
Loop at itab.
on change of fld 2.
If sy-tabix NE 1.
lt_header-fld1 = lt_prev_itab-fld1.
lt_header-fld2 = lt_prev_itab-fld2.
append lt_header.
call function <fun_name>
exporting
lt_header
lt_list.
refresh : lt_header ,lt_list.
endif.
endon.
lt_list-fld1 = itab-fld3.
lt_list-fld2 = itab-fld4.
append lt_list.
lt_prev_itab = itab.
endloop.
To call the F/M for the last grp.
if not lt_header[] is initial.
call function <fun_name>
exporting
lt_header
lt_list.
endif.
Reward points if useful.
THanks,
Pranjal.
Edited by: Pranjal Gadkari on Apr 24, 2008 9:28 AM
‎2008 Apr 24 8:27 AM
Here you can use ON CHANGE OF command.
Loop at itab.
on change of fld 2.
If sy-tabix NE 1.
lt_header-fld1 = lt_prev_itab-fld1.
lt_header-fld2 = lt_prev_itab-fld2.
append lt_header.
call function <fun_name>
exporting
lt_header
lt_list.
refresh : lt_header ,lt_list.
endif.
endon.
lt_list-fld1 = itab-fld3.
lt_list-fld2 = itab-fld4.
append lt_list.
lt_prev_itab = itab.
endloop.
To call the F/M for the last grp.
if not lt_header[] is initial.
call function <fun_name>
exporting
lt_header
lt_list.
endif.
Reward points if useful.
THanks,
Pranjal.
Edited by: Pranjal Gadkari on Apr 24, 2008 9:28 AM
‎2008 Apr 24 8:32 AM
hi u can use this logic:
say you have str1 structure and itab1 internal table to pass to FM.
sort itab by field1 field2.
loop at itab.
at first .
continue.
endat.
at new field2.
call Function Module Passing str1 and itab1.
endat.
str1-field1 = itab-field1.
str1-field2 = itab-field2.
itab1-field3 = itab-field3.
itab1-field4 = itab-field4.
itab1-field5 = itab-field5.
append itab1.
endloop.
call Function Module Passing str1 and itab1.
reward if useful.