BAPI_GOODSMVT_CREATE - 자재 문서 생성 (예제 코드 포함)

2023. 2. 16. 10:18ABAP/BAPI

728x90
반응형

안녕하세요 파피킴입니다.

ABAP 프로그래밍을 하다 보면 IM 재고를 이고해기 위해 해당 펑션을 사용하시게 될 텐데요~

아래 예제는 311 이동유형을 이용한 플랜트 내 저장위치 간 이동입니다.

 

DATA : ls_header       TYPE bapi2017_gm_head_01,
            ls_code           TYPE bapi2017_gm_code,
            lt_item             TYPE TABLE OF bapi2017_gm_item_create WITH HEADER LINE,
            ls_header_ret TYPE bapi2017_gm_head_ret,
            lt_return          TYPE TABLE OF bapiret2 WITH HEADER LINE.

***<<< 헤더 설정
ls_header-pstng_date = sy-datum. " 전기일
ls_header-doc_date    = sy-datum.     " 증빙일
***>>> 헤더 설정

***<<< gm_code 설정
* GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order
*                                          02 - MB31 - Goods Receipts for Prod Order
*                                          03 - MB1A - Goods Issue
*                                          04 - MB1B - Transfer Posting
*                                          05 - MB1C - Enter Other Goods Receipt
*                                          06 - MB11
ls_code-gm_code = '04'.
***>>> gm_code 설정

***<<< 아이템 설정
lt_item-move_type  = '311'.         " MM 이동유형
lt_item-material       = '자재번호'. " 자재번호
lt_item-plant            = '플랜트'.     " 플랜트
lt_item-stge_loc      = '저장위치'.  " 원시 저장위치
lt_item-move_stloc = '저장위치'.  " 목적 저장위치
lt_item-entry_qnt     = '10'.            " 수량
lt_item-entry_uom   = 'KG'.          " 단위
APPEND lt_item.
CLEAR lt_item.
***>>> 아이템 설정

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
        goodsmvt_header  = ls_header
        goodsmvt_code     = ls_code
    IMPORTING
        goodsmvt_headret = ls_header_ret
    TABLES
        goodsmvt_item       = lt_item

        return                       = lt_return.

IF ls_header_ret IS NOT INITIAL.
    MESSAGE s000 WITH 'SUCCESS' ls_header_ret-mat_doc.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
            wait = 'X'.
ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    READ TABLE lt_return WITH KEY type = 'E'.
    MESSAGE s000 WITH lt_return-message DISPLAY LIKE 'E'.
ENDIF.

 

아마 조금만 수정하시면 다른 이동유형으로도 사용 가능하실 거예요~

궁금하신 사항은 댓글로 부탁드립니다.

이상 쌥가능의 파피킴이었습니다.

728x90
반응형