‎2010 Oct 20 10:19 AM
Hi,
I have a requirement...an internal table contains three fields material no, bin no, and Quantity
Mat. No | Bin No | Quantity
a | x1 | 10
a | x1 | 10
a | x2 | 20
b | x3 | 10
c | x3 | 20
c | x4 | 30
c | x4 | 40
In this I need to append the records to new internal table say itab1 where multiple entries exist for some material no like mat no 'a' and 'c' and
if the material no. exist only once in the table, it has to be moved to another new internal table say itab2.
Pls suggest some logic that does not have performance issues.
Thanks in advance
Saravana
‎2010 Oct 20 10:31 AM
‎2010 Oct 20 11:07 AM
Hi there,
a solution in brief...
data: wa_itab1_a like itab1,
wa_itab2_b like itab1,
lv_tabix type sytabix.
sort itab1 by matnr.
loop at itab1.
wa_itab1_a = itab1.
at new matnr.
lv_tabix = sy-tabix + 1.
clear wa_itab2_b.
READ TABLE itab1 into wa_itab2_b
INDEX lv_tabix.
if wa_itab2_b-matnr ne wa_itab1_a-matnr.
append wa_itab1_a to itab2.
delete itab1 where matnr = wa_itab1_a-matnr.
endif.
endat.
endloop.
Regards
George Zervas
Edited by: gzervas on Oct 20, 2010 12:08 PM
‎2010 Oct 20 11:19 AM
sort itab by matnr.
clear lv_oldmatnr.
loop at itab.
if itab-matnr NE lv_oldmatnr.
append itab to itab2.
else.
read itab2 with key matnr = itab-matnr.
if sy-subrc = 0.
append itab2 to itab1.
lv_index = sy-tabix.
delete itab2 index lv_index.
endif.
append itab to itab1.
endif.
lv_oldmatnr = itab-matnr.
endloop.
Edited by: Pedro Guarita on Oct 20, 2010 11:22 AM