‎2008 Nov 19 12:35 PM
Hi All
I have a requirement like this - there is an internal table IT1 with fld1 fld2. It is sorted in fld1 fld2 order. I want to append the fld1 fld2 entries in another internal table IT2 until there is a change in fld2. Whenever fld2 changes, I want to call a function module and pass internal table IT2. After the execution of function module, I want to refresh IT2. Again populate fld1 fld2 of internal table IT2 until fld2 changes and then call function module
Thanks
‎2008 Nov 19 12:46 PM
Hi,
you can do it like:
data:
g_fld2 type it1-fld2.
loop at IT1 into wa_it1.
if g_fld2 is initial. "IF 1
g_fld2 = wa_it1-fld2.
append wa_it1 to IT2.
else. "IF 1
if g_fld2 = wa_it1-fld2. "IF 2
append wa_it1 to IT2.
else. "IF 2
call function <FM you want to call with IT2>
refresh IT2.
clear g_fld2.
g_fld2 = wa_it1-fld2.
append wa_it1 to IT2.
endif. "IF 2
endif. "IF 1
endloop.
Edited by: Neha Shukla on Nov 19, 2008 1:47 PM
Edited by: Neha Shukla on Nov 19, 2008 1:47 PM
‎2008 Nov 19 12:40 PM
HI,
You can do like this.
Loop at IT1.
AT New fld2.
"Cal your function module here to copy the fields "
clear fld2.
endat.
Endloop.
Regards
Mudit
‎2008 Nov 19 12:40 PM
HI,
Sort the table on fld2.
Loop at Itab1.
append the data to itab2.
at end of fld2.
call the function module.
refresh itab2.
endat.
Endloop.
Edited by: avinash kodarapu on Nov 19, 2008 6:30 PM
‎2008 Nov 19 12:41 PM
loop at it1 into wa1.
descibe table it2 lines v_line.
read table it2 into wa2 index v_line.
if sy-subrc = 0.
if wa1-fld1 <> wa2-fld2.
" Call FM.
refresh it2.
else.
append wa1 to it2.
endif.
endif.
endloop.
‎2008 Nov 19 12:42 PM
hi srikar,
Use the control break as the at end of fid2 mean while u push all the records into the table 2 at the end of the fld 2 comes make the operation as pushing the whole rtable to function module. and refresh table 2 after getting the output. this process will help u.
regards,
Naresh
‎2008 Nov 19 12:46 PM
Hi,
you can do it like:
data:
g_fld2 type it1-fld2.
loop at IT1 into wa_it1.
if g_fld2 is initial. "IF 1
g_fld2 = wa_it1-fld2.
append wa_it1 to IT2.
else. "IF 1
if g_fld2 = wa_it1-fld2. "IF 2
append wa_it1 to IT2.
else. "IF 2
call function <FM you want to call with IT2>
refresh IT2.
clear g_fld2.
g_fld2 = wa_it1-fld2.
append wa_it1 to IT2.
endif. "IF 2
endif. "IF 1
endloop.
Edited by: Neha Shukla on Nov 19, 2008 1:47 PM
Edited by: Neha Shukla on Nov 19, 2008 1:47 PM