Online Tutorials & Training Materials | STechies.com
Register Login

Duplicate orders with same external number

|| || 0

Duplicate orders with same external number
Stechies

The following root causes can result in duplicate orders with the same external number:

In customizing the number range for APO planned orders was set to a smaller value than before. You set number ranges using transaction /SAPAPO/RRPC1.
A system copy was not done correctly. After the system copy two different systems (with two different current values of the number range) work on the same liveCache.

Related: Table to Find Invoice and Document Number with Respective Sales Order Number

Note, that for planning purposes, the external order number is not needed by the system (though it probably helps planners to communicate). If for example R/3 production orders are used to execute the plan, then APO planned orders do not necessarily have to be numbered. In customizing (transaction /SAPAPO/RRPCUST1) you can decide, whether PP/DS planned orders are given an external order number. If PP/DS planned orders are not given an external order number (the external order number is SPACE), then of course the external order number of all these orders is identical.

To find and delete duplicte orders proceed as follows:

If necessary implement the correction from note 630710.
Run the report provided in this note.
Delete duplicate orders e.g. using transaction /SAPAPO/RRP2.

To prevent the problem in future:

Make sure number ranges are not changed to a value, that could have been used earlier.
Make sure a system copy is performed as discribed in note 210564.

Here comes the report in question:
*&---------------------------------------------------------------------*
*& Report  Z_DISPLAY_DUPLORDNO                                         *
*&                                                                     *
*&--- Display orders with duplicate order numbers ---------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  z_display_duplordno           .

DATA: lv_ord_nr  TYPE /sapapo/ordernr,
      lv_subrc   TYPE sysubrc,
      lt_ordkey  TYPE /sapapo/om_ordkey_tab,
      lt_ordkey_dupl TYPE /sapapo/om_ordkey_tab,
      ls_ordkey  TYPE /sapapo/ordkey,
      ls_ordkey1 TYPE /sapapo/ordkey,
      ls_supply  TYPE /sapapo/rrp_order_str,
      lv_matnr   TYPE /sapapo/matnr,
      lv_locno   TYPE /sapapo/locno,
      lv_text    TYPE text25.

* Display orders with duplicate order numbers
* Please, specify the planning version and
* an interval of orders .
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
PARAMETERS: verid TYPE /sapapo/vrsioid OBLIGATORY.
SELECT-OPTIONS ord_ran FOR lv_ord_nr NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK block1.

AT SELECTION-SCREEN.
* ...

START-OF-SELECTION.
  CALL FUNCTION '/SAPAPO/DM_SELECT_ORDNO_RANGE'
    EXPORTING
      iv_simid                = verid
      it_ordno_range          = ord_ran[]
*   IV_ORDNO                =
   IMPORTING
     et_ordkey               = lt_ordkey
     ev_subrc                = lv_subrc
   EXCEPTIONS
     lc_connect_failed       = 1
     lc_com_error            = 2
     OTHERS                  = 3
            .
  IF sy-subrc <> 0 OR lv_subrc <> 0.
*   An error occurred
    WRITE text-003.
    EXIT.
  ENDIF.

* Collect duplicate orders
  SORT lt_ordkey BY ordno ordtype.
  LOOP AT lt_ordkey INTO ls_ordkey.
    DELETE lt_ordkey INDEX 1.
    READ TABLE lt_ordkey INTO ls_ordkey1 INDEX 1.
    IF  sy-subrc           = 0  "there're duplicate entries
    AND ls_ordkey1-ordno   = ls_ordkey-ordno
    AND ls_ordkey1-ordtype = ls_ordkey-ordtype.
      APPEND ls_ordkey TO  lt_ordkey_dupl.
      APPEND ls_ordkey1 TO lt_ordkey_dupl.
    ENDIF.
  ENDLOOP.

* filter duplicate entries
  SORT lt_ordkey_dupl BY ordid.
  DELETE ADJACENT DUPLICATES FROM lt_ordkey_dupl COMPARING ordid.

* No duplkicates found -> exit
  IF lt_ordkey_dupl[] IS INITIAL.
    EXIT.
  ENDIF.

* Display
  SORT lt_ordkey_dupl BY ordno ordtype.

  WRITE :text-002 ,/.

  LOOP AT lt_ordkey_dupl INTO ls_ordkey.
    CALL FUNCTION '/SAPAPO/RRP_LC_ORDER_GET_DATA'
         EXPORTING
              iv_order      = ls_ordkey-ordid
         IMPORTING
              es_supply     = ls_supply
         EXCEPTIONS
              error_message = 0.

    CALL FUNCTION '/SAPAPO/DM_MATID_GET_MATERIAL'
         EXPORTING
              iv_matid = ls_supply-source-matid
         IMPORTING
              ev_matnr = lv_matnr
         EXCEPTIONS
              OTHERS   = 2.
    IF sy-subrc <> 0.
      CLEAR lv_matnr.
    ENDIF.

    CALL FUNCTION '/SAPAPO/DM_LOCID_GET_LOCATION'
         EXPORTING
              iv_locid = ls_supply-source-locto
         IMPORTING
              ev_locno = lv_locno
         EXCEPTIONS
              OTHERS   = 2.
    IF sy-subrc <> 0.
      CLEAR lv_locno.
    ENDIF.

    CALL FUNCTION '/SAPAPO/DM_ORDID_GET_ORDER'
         EXPORTING
              iv_ordid  = ls_ordkey-ordid
         IMPORTING
              ev_text25 = lv_text
         EXCEPTIONS
              OTHERS    = 3.
    IF sy-subrc <> 0.
      CLEAR lv_text.
    ENDIF.

    WRITE: ls_ordkey-ordtype, ls_ordkey-ordid,
           lv_text, lv_matnr, lv_locno, /.
  ENDLOOP.
* End of list for duplicate orders
  WRITE: text-004, /.


 


Related Articles

0.0174 seconds.