Skip to Content
0
Jan 24, 2013 at 09:03 AM

eed to add qty fields if both c1,c2(cust number) and (cp1, cp2)cust part are not matching in rows.. if it is matching is sholud not sum up.

32 Views

C1,cp2,Y407,5000,10000,20000

C2,cp2,Y407,5000,10000,20000

C1,cp1,Y407,5000,10000,20000'

cst num and cst pt are primary keys and matnr also

result should come y407 15000 30000 60000

Hi

Above is the text file, i need to add qty fields if both c1,c2(cust number) and (cp1, cp2)cust part are not matching in rows.. if it is matching is sholud not sum up.

i tried doing it buut it is giving me sum of y407 10000 20000 40000 instead of y407 15000 30000 60000

below is my code. kindly suggest whats wrong..

REFRESH: itab2.

SORT itab BY matnr .

LOOP AT itab INTO watab.

IF sy-tabix NE 1.

wi_tabix = sy-tabix - 1.

READ TABLE itab INTO watab2 INDEX wi_tabix.

IF watab-wc_cstno <> watab2-wc_cstno

OR watab-wc_cstpt <> watab2-wc_cstpt.

if sy-subrc = 0.

watab-wc_cstno = ''.

watab-wc_cstpt = ''.

endif.

COLLECT watab INTO itab2.

ENDIF.

ENDIF.

ENDLOOP.