Skip to Content
0
Former Member
Jan 29, 2008 at 06:50 AM

MODYFYING ITAB LINE

13 Views

Hi Experts,

I have a 2 internal tables. 1st is itab & 2nd is itabf. itabf is initial. In ITAB I have MATNR, WERKS, PQTY. And ITABF has MATNR, PQTY1, PQTY2.

I am moving rows from ITAB to ITABF. If werks in ITAB is PLANT1 then PQTY should go in PQTY1 of ITABF or if werks is PLANT2 then PQTY should go in PQTY2.

If MATNR is same then it will update the same row in ITABF else append a new row in ITABF.

According to my code its appending a row but in second loop when it gets same MATNR but diffrent WERKS, it delete exixting row and append new PQTY in respective column.

***********************************

N = 1.

LOOP AT ITAB.

ON CHANGE OF ITAB-MATNR.

ITABF-MATNR = ITAB-MATNR.

ITABF-WERKS = ITAB-WERKS.

VMATNR = ITAB-MATNR.

APPEND ITABF.

ENDON.

IF VMATNR = ITAB-MATNR.

SY-TABIX = N.

IF ITAB-WERKS = 'PC01'.

ITABF-FPC01 = ITAB-PQTY.

ELSEIF ITAB-WERKS = 'PC02'.

ITABF-FPC02 = ITAB-PQTY.

MODIFY ITABF INDEX SY-TABIX.

CLEAR: ITAB, ITABF.

AT END OF MATNR.

N = N + 1.

ENDAT.

ENDIF.

ENDLOOP.

**************************************

PLz help. URGENT..

KHAN