Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Manipulating Internal Table

Former Member
0 Likes
511

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
456

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

3 REPLIES 3
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
456

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.

Read only

Former Member
0 Likes
457

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

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
456

Hi rahul,

Can you please paste the code which solved your problem.