본문 바로가기
SD

[SD] Order-Serial number Mapping BAPI

by clode 2023. 2. 27.
728x90
반응형

SERNR_ADD_TO_AU

오더를 생성한뒤 해당 오더에 자재 일련번호를 매핑해주는 작업을 수행한다.

FORM ADD_SERIAL_NUMBER TABLES ORDER_SERNR_IN STRUCTURE ZSSD00170
                        USING SALESDOCUMENT.

  DATA: LV_KWMENG TYPE RISA0-ANZAHL.

  SELECT AK~VBELN,
         AP~POSNR,
         AP~SERAIL,
         AK~KUNNR,
         AK~VBTYP,
         AK~AUART,
         AP~PSTYV,
         AP~KWMENG
  FROM VBAK AS AK INNER JOIN VBAP AS AP
  ON AK~VBELN EQ AP~VBELN
  WHERE AK~VBELN EQ @SALESDOCUMENT
  INTO TABLE @DATA(LT_SER02).

  IF ORDER_SERNR_IN[] IS NOT INITIAL.
    LOOP AT ORDER_SERNR_IN.
      READ TABLE LT_SER02 INTO DATA(LS_SER02) WITH KEY POSNR = ORDER_SERNR_IN-ITM_NUMBER.
      LV_KWMENG = LS_SER02-KWMENG.

      CALL FUNCTION 'SERNR_ADD_TO_AU'
        EXPORTING
          SERNR     = ORDER_SERNR_IN-SERNR
          PROFILE   = LS_SER02-SERAIL
          MATERIAL  = ORDER_SERNR_IN-MATERIAL
          QUANTITY  = LV_KWMENG
          DOCUMENT  = SALESDOCUMENT
          ITEM      = LS_SER02-POSNR
          DEBITOR   = LS_SER02-KUNNR
          VBTYP     = LS_SER02-VBTYP
          SD_AUART  = LS_SER02-AUART
          SD_POSTYP = LS_SER02-PSTYV.


      CALL FUNCTION 'SERIAL_LISTE_POST_AU'.
      COMMIT WORK AND WAIT.

      CLEAR: LV_KWMENG.
    ENDLOOP.
  ENDIF.

ENDFORM.
728x90
반응형

'SD' 카테고리의 다른 글

[SD] 대금청구 Billing  (0) 2023.03.10
[SD] 출고 Shipping  (0) 2023.03.09
[SD] 판매오더 Sales order  (1) 2023.03.09
[SD] 조직 및 기준정보 Master data  (0) 2023.03.09
[SD] 판매오더 생성 BAPI  (0) 2023.02.27

댓글