Skip to Content
0
Former Member
Mar 17, 2009 at 02:20 PM

How to move ' 0 ' for repeated values

17 Views

Hi Experts,

Please advice how to move zero or ' ' to a field if the values are repeating.

As per my requirement I need to fetch finished goods from mseg-matnr and raw materials from

resb-matnr where baugr eq mseg-matnr and I need to display

ebeln for the corresponding finished goods.

But when Iam displaying it I will sort out the finished goods (matnr) , rawmaterial so that

raw material and finished goods wont repeat as there are many ebeln for each matnr.

Now my problem is with the values of the corresponding rawmaterials as they connot be sorted

as per the raw material. So please advice how to move ' ' or zero to those values which are repeating.

LOOP AT IT_FIN_GOODS.
    MOVE-CORRESPONDING IT_FIN_GOODS TO IT_FINAL.
    LOOP AT IT_RAW_MAT WHERE EBELN EQ IT_FIN_GOODS-EBELN
                         AND EBELP EQ IT_FIN_GOODS-EBELP
                         AND BAUGR EQ IT_FIN_GOODS-MATNR.
    .
      MOVE IT_RAW_MAT-CON_KGS TO IT_FINAL-CON_KGS.
      MOVE IT_RAW_MAT-STLNR   TO IT_FINAL-STLNR.
      MOVE IT_RAW_MAT-NORMS   TO IT_FINAL-NORMS.
      MOVE IT_RAW_MAT-MATNR   TO IT_FINAL-IDNRK.
      MOVE IT_RAW_MAT-SHKZG   TO IT_FINAL-SHKZG.
      MOVE IT_RAW_MAT-MEINS   TO IT_FINAL-MEINS.
      APPEND IT_FINAL.
      CLEAR: IT_FINAL-WEMNG.
    ENDLOOP.
  ENDLOOP.

SORT IT_FINAL BY MATNR IDNRK EBELN LIFNR.
  DELETE ADJACENT DUPLICATES FROM IT_FINAL COMPARING MATNR IDNRK EBELN LIFNR

.

SELECT * FROM MSEG AS A INNER JOIN MKPF AS B ON A~MBLNR EQ B~MBLNR
                                             AND A~MJAHR EQ B~MJAHR
                  INTO CORRESPONDING FIELDS OF TABLE IT_OPEN FOR ALL ENTRIES IN IT_FINAL
                                           WHERE A~MATNR EQ IT_FINAL-IDNRK
                                             AND A~LIFNR EQ IT_FINAL-LIFNR
                                             AND A~WERKS EQ IT_FINAL-WERKS
                                             AND A~BWART IN ('541','542','543','544').

  SORT IT_FINAL BY IDNRK.

LOOP AT IT_FINAL.

    LOOP AT IT_OPEN WHERE MATNR EQ IT_FINAL-IDNRK
                      AND LIFNR EQ IT_FINAL-LIFNR
                      AND WERKS EQ IT_FINAL-WERKS
                      AND BUDAT IN O_DATE.


      IF ( IT_OPEN-SHKZG = 'S' AND IT_OPEN-BWART = '541' )
      OR ( IT_OPEN-SHKZG = 'H' AND IT_OPEN-BWART = '542' )
      OR ( IT_OPEN-SHKZG = 'H' AND IT_OPEN-BWART = '543' )
      OR ( IT_OPEN-SHKZG = 'S' AND IT_OPEN-BWART = '544' ).


        IF IT_OPEN-SHKZG = 'H'.
          IT_OPEN-MENGE = IT_OPEN-MENGE * -1.
        ENDIF.

        OBAL = OBAL + IT_OPEN-MENGE.

      ENDIF.
    ENDLOOP.



    LOOP AT IT_OPEN WHERE MATNR = IT_FINAL-IDNRK
                      AND WERKS = IT_FINAL-WERKS
                      AND LIFNR = IT_FINAL-LIFNR
                      AND BUDAT IN BUDAT.



      IF ( IT_OPEN-SHKZG = 'S' AND IT_OPEN-BWART = '541' ).

        M541 = M541 + IT_OPEN-MENGE.

      ELSEIF ( IT_OPEN-SHKZG = 'H' AND IT_OPEN-BWART = '542' ).

        M542 = M542 + IT_OPEN-MENGE.

      ELSEIF ( IT_OPEN-SHKZG = 'H' AND IT_OPEN-BWART = '543' ).

        M543 = M543 + IT_OPEN-MENGE.

      ELSEIF ( IT_OPEN-SHKZG = 'S' AND IT_OPEN-BWART = '544' ).

        M544 = M544 + IT_OPEN-MENGE.

      ENDIF.

    ENDLOOP.
    MOVE M541 TO IT_FINAL-M541.
    MOVE M542 TO IT_FINAL-M542.
    MOVE M543 TO IT_FINAL-M543.
    MOVE M544 TO IT_FINAL-M544.
    MOVE OBAL TO IT_FINAL-OBAL.
    MODIFY IT_FINAL.
    CLEAR: OBAL,M541, M542, M543, M544,IT_OPEN, IT_FINAL.
  ENDLOOP.

Please advice how to move 0 or ' ' to OBAL,M541, M542, M543, M544

Thanks

Karthik.

Edited by: Karthik R on Mar 17, 2009 7:51 PM