Application Development 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: 

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.

former_member391265
Participant
0 Kudos

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.

1 REPLY 1

kesavadas_thekkillath
Active Contributor
0 Kudos

Moderator message:

Please search form the mentioned information in SAP help , Un-marking this thread as a question due to its basic nature, from next time please try to use a meaningful subject line.

Hint: Move the third field to first field of itab and use a control break statement with first field along with SUM addition.