1. 程式人生 > >從生產訂單增加或刪除序列號

從生產訂單增加或刪除序列號

LOOP AT lt_sernos.
  CALL FUNCTION 'DEQUEUE_EIEQSE'
    EXPORTING
      mandt  sy-mandt
      matnr  i_planning-plnbez
      sernr  lt_sernos-sernr
      _scope '3'.
ENDLOOP.
IF lt_sernos[] IS NOT INITIAL.
* 增加序列號
  CALL FUNCTION 'SERNR_ADD_TO_PP'
    EXPORTING
      material              i_planning-plnbez
      j_vorgang             
'PMP2'
      ppaufnr               i_planning-aufnr
      ppposnr               p_posnr
    IMPORTING
      anzsn                 l_num_serno
*     ZEILEN_ID             =
*     SERIAL_COMMIT         =
    TABLES
      sernos                lt_sernos
    EXCEPTIONS
      serialnumber_errors   1
      serialnumber_warnings 
2
      OTHERS                3.

  IF sy-subrc 0.
    CALL FUNCTION 'SERIAL_LISTE_POST_PP'
      EXPORTING
        memory_id_status 'SN_STATS'.
    IF sy-subrc 0.
      COMMIT WORK AND WAIT.
    ENDIF.
  ENDIF.
* 刪除序列號
  CALL FUNCTION 'SERNR_DEL_FROM_PP'
    EXPORTING
      material              i_planning-
plnbez
      j_vorgang             'PMP2'
      ppaufnr               i_planning-aufnr
      ppposnr               p_posnr
    IMPORTING
      anzsn                 l_num_serno
*     ZEILEN_ID             =
*     SERIAL_COMMIT         =
    TABLES
      sernos                lt_sernos
    EXCEPTIONS
      serialnumber_errors   1
      serialnumber_warnings 2
      OTHERS                3.

  IF sy-subrc 0.
    CALL FUNCTION 'SERIAL_LISTE_POST_PP'
      EXPORTING
        memory_id_status 'SN_STATS'.
    IF sy-subrc 0.
      COMMIT WORK AND WAIT.
    ENDIF.
  ENDIF.
ENDIF.