06-04-2009 8:09 AM
Hi Experts,
I have internal table. In that internal table i have 3 fields.
MATNR MTART MENIS
TESTMAT ZHLB M
123te ZHLB M
123te ZHLB M
123te ZHLB M
ABC HALB M
ZYX FERT M
9620075 ZHLB M
9620075 ZHLB M
Here i need to move the material into another internal table which comes more than once. That means here i need to move 123te and 9620075 into another internal table.
Can any one help this?
Mohana
06-04-2009 8:16 AM
Hi,
Try below logic
LOOP AT it_itab INTO wa_itab.
IF lv_matnr = wa_itab-matnr.
CLEAR lv_matnr.
APPEND wa_itab TO it_dup.
ENDIF.
lv_matnr = wa_itab-matnr.
CLEAR wa_itab.
ENDLOOP.
Regards
Bala Krishna
Edited by: Bala Krishna on Jun 4, 2009 12:46 PM
06-04-2009 8:16 AM
Hi,
Try below logic
LOOP AT it_itab INTO wa_itab.
IF lv_matnr = wa_itab-matnr.
CLEAR lv_matnr.
APPEND wa_itab TO it_dup.
ENDIF.
lv_matnr = wa_itab-matnr.
CLEAR wa_itab.
ENDLOOP.
Regards
Bala Krishna
Edited by: Bala Krishna on Jun 4, 2009 12:46 PM
06-04-2009 8:18 AM
Hi,
Follow the following steps :
sort the internal table which contains the duplicate entries.
set a flag for each entry which is getting repeated.
move all the flagged records to another internal table.
sort again and use Delete Adjacent Duplicates : using Delete Adjacent Duplicates will keep only one instance of the multiple times repeated record.
Regards.
06-04-2009 8:21 AM
Hi,
Just go through this logic.
First sort your internal table using MATNR.
data V_1(3),
V_2(3).
Loop at <internal table> .
Move the <wa> to another <NEW wa>.
AT NEW MATNR.
CLEAR : V_1, V_2.
Move the SY-TABIX to a variable V_1.
ENDAT.
AT END OF MATNR.
CLEAR V_2.
Move the SY-TABIX to a variable V_2.
END AT.
IF V_1 NE V_2 AND V_1 is not initial AND V_2 is not initial.
Append the new internal table here.
ENDIF.
Hope this will help you.
Regards,
Smart Varghese.
06-04-2009 8:25 AM
Tried like this!
DATA: begin of itab1 occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
meins like mara-meins,
end of itab1.
data: itab2 like table of itab1 with header line.
itab1-matnr = '123e'.
itab1-mtart = 'zhlb'.
itab1-meins = 'M'.
APPEND ITAB1.
itab1-matnr = '123e'.
itab1-mtart = 'zhlb'.
itab1-meins = 'M'.
APPEND ITAB1.
move itab1[] to itab2[].
loop at itab2.
write:/ itab2-matnr.
endloop.