‎2010 Jan 18 7:55 AM
Hi Abappers,
I have 1 internal table as
Material Plant Flag
A 1 Y
B 1 N
C 1 Y
C 1 N
Here, I have to take those material for which flag is both Y and N for the same materail and Plant.
As C has both Y and N for the same plant.
How to extract material C into different interanal table.
Regards,
Rahul
‎2010 Jan 18 8:18 AM
Hi Rahul,
sort itab by matnr plant.
loop at the same internal table.
check if the third field is "y'.
then read the same internal tabel with third field eq 'N'.
if sy-subrc eq 0.
append it to the new internal table.
Loop at Itab into workarea.
if thirdfield eq 'Y'.
read Itab into workarea2 with key matnr plant thirdfield eq 'N'.
if sy-subrc eq 0.
append workarea to new internal table.
endif.
clear workarea1.workarea2.
endloop.
hope this will solve ur problem.
Edited by: Javed Parvez on Jan 18, 2010 9:19 AM
‎2010 Jan 18 8:16 AM
Hope this helps, its not tested
sort itab by material plant ascending.
loop at itab into wa.
lv_index2 = sy-tabix.
at new wa-plant.
read table itab into wa index sy-tabix.
if sy-subrc = 0.
lv_flag = wa-flag.
lv_index1 = sy-tabix.
continue.
endif.
endat.
if lv_flag ne wa-flag.
append lines of itab to itab2 from lv_index1 to lv_index2 . "check this syntax.
clear lv_index1.
clear lv_index2.
endif.
endloop.
‎2010 Jan 18 8:18 AM
Hi Rahul,
sort itab by matnr plant.
loop at the same internal table.
check if the third field is "y'.
then read the same internal tabel with third field eq 'N'.
if sy-subrc eq 0.
append it to the new internal table.
Loop at Itab into workarea.
if thirdfield eq 'Y'.
read Itab into workarea2 with key matnr plant thirdfield eq 'N'.
if sy-subrc eq 0.
append workarea to new internal table.
endif.
clear workarea1.workarea2.
endloop.
hope this will solve ur problem.
Edited by: Javed Parvez on Jan 18, 2010 9:19 AM
‎2010 Jan 18 9:57 AM
Hi rahul,
Can you please paste the code which solved your problem.