Application Development and Automation 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: 
Read only

Duplicate Orders.

Former Member
0 Likes
337

Hi,

I have a report which displays no. of orders in staging(before comming in to SAP, between EDI and SAP) by Sold to and PO date. For Ex:

soldto podate no-of-orders

Walmart 20071001 10

walmart 20071005 25

If I put cursor on one of the above lines and by clicking the button 'Duplicate orders', it gives the details of the duplicate orders(6) by cust.ship to, po number and shipto.

cust.ship-to po number shipto

15 105PO15 1055000015

15 105PO15 1055000015

15 105PO15 1055000015

16 105PO16 1055000016

16 105PO16 1055000016

16 105PO16 1055000016

Suppose if the first line has 6 duplicate orders and second line does not have any duplicate orders, then user wants me to display like the following.

soldto podate no-of-orders Duplicate Orders

Walmart 20071001 10 6

no second line - because no duplicate orders for this.

Please help me to solve this.

Thanks,

Veni.


* Initial Output to the Screen
    SET PF-STATUS 'NORM'.
    LOOP AT itab_output.
 READ TABLE itab_kna1 WITH KEY kunnr = itab_output-sndprn BINARY SEARCH.
      itab_output-name1 = itab_kna1-name1.
      MODIFY itab_output.
      CLEAR itab_output.

    ENDLOOP.
    SORT itab_output BY name1 datum.
    LOOP AT itab_output.
      WRITE: /01 sy-vline,
              02 itab_output-name1,
              40 sy-vline,
              41 itab_output-datum,
              51 sy-vline,
              52 itab_output-orders,
              62 sy-vline.
      HIDE: itab_output-inpnr.
            
    ENDLOOP.
    ULINE: /(62).
  ELSE.
    SET PF-STATUS 'NORM'.
    WRITE: /05 '********* NO DATA FOUND **************'.
  ENDIF.

* Duplicate order details
FORM output2.
  SET PF-STATUS 'STAT'.
  SORT itab_output2 ASCENDING BY belnr inpnr.
  LOOP AT itab_output2 WHERE sndprn = itab_output-sndprn
                         AND datum = itab_output-datum.
    FORMAT INTENSIFIED OFF.
    FORMAT COLOR 2.
    CLEAR counter.
    LOOP AT itab_output2 WHERE belnr = itab_output2-belnr
    			AND inpnr = itab_output2-inpnr.
      counter = counter + 1.
    ENDLOOP.
    IF counter > 1.


      SELECT SINGLE * FROM edid4 WHERE docnum EQ itab_output2-docnum
                              AND segnam EQ 'E1EDKT2'.
      IF sy-subrc EQ 0.
        FORMAT INTENSIFIED ON COLOR = 7.
      ENDIF.

      IF itab_output2-inpnr = 'UNKNOWN'.
        FORMAT INTENSIFIED ON COLOR = 6.
      ENDIF.
      WRITE: /01 sy-vline,
              02 chk AS CHECKBOX,
              03 sy-vline,
              04 itab_output2-lifnr,
              20 sy-vline,
              21 itab_output2-belnr,
              42 sy-vline,
              43 itab_output2-vtext,
              72 sy-vline,
              73 itab_output2-inpnr,
              83 sy-vline.
    ENDIF.
  ENDLOOP.
  ULINE :/(83).
ENDFORM.                                                    " OUTPUT2


* Get data

FORM check_data.
  LOOP AT t_itab_edid4 WHERE segnam = 'E1EDK02'.
    MOVE t_itab_edid4-sdata TO itab_e1edk02.
    IF ( itab_e1edk02-qualf = '001' AND itab_e1edk02-belnr IN s_ponumb
                                 AND itab_e1edk02-datum IN s_podate ).
      ind = 'V'.
      itab_output2-sndprn = itab_output-sndprn = t_itab_edid4-sndprn.
      itab_output2-docnum = t_itab_edid4-docnum.
      itab_output2-belnr = itab_e1edk02-belnr.
      itab_output2-datum = itab_output-datum = itab_e1edk02-datum.
      EXIT.
    ELSE.
      CLEAR: itab_e1edk02.
      ind = 'I'.
    ENDIF.
  ENDLOOP.


  IF ind = 'V'.
    LOOP AT t_itab_edid4 WHERE segnam = 'E1EDKA1'.
      MOVE t_itab_edid4-sdata TO itab_e1edka1.
 IF ( itab_e1edka1-parvw = 'WE' )."and itab_e1edka1-lifnr in s_shipto ).
        READ TABLE itab_edpar WITH KEY kunnr = t_itab_edid4-sndprn
                               expnr = itab_e1edka1-lifnr BINARY SEARCH.
        IF sy-subrc EQ 0.
          IF ( itab_edpar-inpnr IN s_shipto ).
            ind = 'V'.
            itab_output2-lifnr = itab_e1edka1-lifnr.
            itab_output2-inpnr = itab_edpar-inpnr.
            itab_output-orders = 1.
            COLLECT: itab_output, itab_output2.
            CLEAR: itab_output, itab_output2.
          ELSE.
            ind = 'I'.
          ENDIF.
          EXIT.
        ELSE.
          IF ( s_shipto EQ space ).
            itab_output2-lifnr = itab_e1edka1-lifnr.
            itab_output2-inpnr = 'UNKNOWN'.
            itab_output-orders = 1.
            COLLECT: itab_output, itab_output2.
            CLEAR: itab_output, itab_output2.
            ind = 'V'.
            EXIT.
          ENDIF.
          ind = 'I'.
        ENDIF.
        EXIT.
      ELSE.
        ind = 'I'.
      ENDIF.
    ENDLOOP.
  ENDIF.

1 REPLY 1
Read only

andreas_mann3
Active Contributor
0 Likes
308

I'd collect this information in an extra internal table.

Finally I 'd loop this table:

loop at ztab where duplicate_order > 0.

...

A.