728x90
*---Reversing goods movement document (Transaction VL09)
출고취소
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
i_vbeln = d_vbeln
i_budat = sy-datlo
i_tcode = c_vl09
i_vbtyp = d_vbtyp
TABLES
t_mesg = it_mesg
EXCEPTIONS
error_reverse_goods_issue = 1
OTHERS = 2.
1. 자재문서를 생성하여 입/출고 또는 자재이동, 이전전기를 수행할 때 사용
* BAPI
DATA : GS_GOODSMVT_HEADER LIKE BAPI2017_GM_HEAD_01,
GV_GOODSMVT_CODE LIKE BAPI2017_GM_CODE,
GT_GOODSMVT_ITEM LIKE BAPI2017_GM_ITEM_CREATE OCCURS 0 WITH HEADER LINE,
GT_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
GS_GOODSMVT_HEADRET LIKE BAPI2017_GM_HEAD_RET.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gs_goodsmvt_header
goodsmvt_code = gv_goodsmvt_code
IMPORTING
goodsmvt_headret = gs_goodsmvt_headret
TABLES
goodsmvt_item = gt_goodsmvt_item
return = gt_return.
IF gs_goodsmvt_headret-mat_doc IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
UPDATE likp SET zzmblnr = gs_goodsmvt_headret-mat_doc
WHERE vbeln = pv_vbeln_vl.
IF sy-dbcnt <> 1. ROLLBACK WORK. ENDIF.
pv_icon = c_icon_led_green.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
pv_icon = c_icon_led_red.
pv_message = `Z TO '배치(일반)' 이전전기 에러.`.
ENDIF.
2. 자재문서를 취소 ( 입/출고 취소 ) - 입고취소에 사용
두가지 케이스에 가장 많이 활용
- SAP CBO 프로그램을 활용한 입고취소처리
- I/F를 통한 Material Document 취소처리
CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'
EXPORTING
materialdocument = lv_materialdocument
matdocumentyear = lv_matdocumentyear
goodsmvt_pstng_date = lv_goodsmvt_pstng_date
documentheader_text = lv_documentheader_text
IMPORTING
goodsmvt_headret = ls_goodsmvt_headret
TABLES
return = lt_return.
IF ls_goodsmvt_headret-mat_doc IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CLEAR : p_mblnr.
p_icon = c_icon_led_green.
p_icon_sto = space.
p_message = |{ ls_goodsmvt_headret-mat_doc }{ '전기취소 완료' }|.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
READ TABLE lt_return WITH KEY type = 'E'.
p_icon = c_icon_led_red.
p_message = lt_return-message.
ENDIF.
3. 자재이동 취소 (출하문서 취소) - 화물 출고 취소에 사용
GR 취소
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
i_vbeln = p_vbeln_vl
i_budat = p_budat
i_vbtyp = lv_vbtyp
i_tcode = 'VL09'
IMPORTING
es_emkpf = ls_emkpf
TABLES
t_mesg = lt_mesg
EXCEPTIONS
error_reverse_goods_issue = 7.
IF ls_emkpf-mblnr IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CLEAR p_mblnr.
p_icon = c_icon_led_green.
p_budat = space.
p_icon_gr = space.
CONCATENATE '출고취소 :' ls_emkpf-mblnr INTO p_message
SEPARATED BY space.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
p_icon = c_icon_led_red.
p_message = '출고 취소시 에러...'.
ENDIF.
[실적정정]
728x90
'Ⅰ. ERP > 4. SD' 카테고리의 다른 글
[SAP SD] 청구문서 세금 분류 변경하는 2가지 방법 (0) | 2024.09.24 |
---|---|
[SAP SD] 위탁 프로세스 (1) | 2024.09.24 |
[SD-IMG] 출하지점, 플랜트, 저장위치 (0) | 2024.03.04 |