FUNCTION Y_GL_M_GOODS_ISSUE_AND_CANCEL.
*"----------------------------------------------------------------------
*"*"ローカルインタフェース:
*" IMPORTING
*" VALUE(IS_ISSUE_CONF) TYPE YSGL2024
*" EXPORTING
*" VALUE(RETURN) TYPE BAPIRET2
*"----------------------------------------------------------------------
*-----------------------------------------------------------------------
* DATA
*-----------------------------------------------------------------------
* 変数
DATA:
L_H_TBL_LIPS TYPE TYP_LIPS,
L_MSG(17) TYPE C,
L_NUM(03) TYPE C,
*-> 出庫汎用モジュールWS_DELIVERY_UPDATE_2使用変数
L_H_TBL_VBKOK TYPE VBKOK,
L_H_TBL_VBPOK TYPE VBPOK,
L_TBL_VBPOK TYPE TYP_TBL_VBPOK,
L_ERFLG TYPE XFELD,
L_TBL_PROT TYPE TYP_TBL_PROT,
*-> 出庫取消汎用モジュールWS_REVERSE_GOODS_ISSUE使用変数
L_ERFLG2 TYPE EMKPF,
L_TBL_MESG TYPE TYP_TBL_MESG,
*-> BAPI_TRANSACTION_COMMIT使用変数
L_H_TBL_RETURN TYPE BAPIRET2.
*----------------------------------------------------------------------*
* インポートパラメータチェック
*----------------------------------------------------------------------*
*->出庫日付の設定
IF IS_ISSUE_CONF-WADAT IS INITIAL.
MOVE SY-DATUM TO IS_ISSUE_CONF-WADAT.
ENDIF.
*->処理区分のチェック
IF IS_ISSUE_CONF-DBEKZ <> CNS_DBEKZ_1 AND
IS_ISSUE_CONF-DBEKZ <> CNS_DBEKZ_2.
PERFORM RETURN_MSG USING 'E' 'DMC_RT_MSG' '010' 'DBEKZ' IS_ISSUE_CONF-DBEKZ '' '' RETURN.
RETURN.
ENDIF.
*->出荷伝票番号の入力
IF IS_ISSUE_CONF-VBELN IS INITIAL.
PERFORM RETURN_MSG USING 'E' 'CLAIM' '205' '' '' '' '' RETURN.
RETURN.
ENDIF.
*->出荷明細番号の入力
IF IS_ISSUE_CONF-POSNR IS INITIAL.
PERFORM RETURN_MSG USING 'E' 'VK' '002' '' '' '' '' RETURN.
RETURN.
ENDIF.
*->品目コードの入力
IF IS_ISSUE_CONF-MATNR IS INITIAL.
PERFORM RETURN_MSG USING 'E' 'VZ' '007' '' '' '' '' RETURN.
RETURN.
ENDIF.
*->プラントの入力
IF IS_ISSUE_CONF-WERKS IS INITIAL.
PERFORM RETURN_MSG USING 'E' 'VELO' '453' '' '' '' '' RETURN.
RETURN.
ENDIF.
*->数量の入力
IF IS_ISSUE_CONF-LFIMG IS INITIAL.
PERFORM RETURN_MSG USING 'E' '06' '070' '' '' '' '' RETURN.
RETURN.
ENDIF.
*----------------------------------------------------------------------*
* 出庫確認・取消処理 開始
*----------------------------------------------------------------------*
CLEAR:L_H_TBL_LIPS.
*->出荷伝票検索
SELECT A~MATNR
A~LFIMG
A~WERKS
A~VRKME
A~VGBEL
B~WBSTA
INTO L_H_TBL_LIPS
FROM LIPS AS A
INNER JOIN VBUP AS B
ON A~VBELN = B~VBELN AND
A~POSNR = B~POSNR
UP TO 1 ROWS
WHERE A~VBELN = IS_ISSUE_CONF-VBELN AND
A~POSNR = IS_ISSUE_CONF-POSNR.
ENDSELECT.
IF SY-SUBRC <> 0.
CONCATENATE IS_ISSUE_CONF-VBELN '-' IS_ISSUE_CONF-POSNR INTO L_MSG.
PERFORM RETURN_MSG USING 'E' 'L3' '123'
L_MSG '' '' '' RETURN.
RETURN.
ENDIF.
IF IS_ISSUE_CONF-WERKS <> L_H_TBL_LIPS-WERKS.
PERFORM RETURN_MSG USING 'E' 'YGL01' '017'
IS_ISSUE_CONF-WERKS L_H_TBL_LIPS-WERKS '' '' RETURN.
RETURN.
ENDIF.
IF IS_ISSUE_CONF-MATNR <> L_H_TBL_LIPS-MATNR.
CONCATENATE IS_ISSUE_CONF-VBELN '-' IS_ISSUE_CONF-POSNR INTO L_MSG.
PERFORM RETURN_MSG USING 'E' 'IS' '147'
IS_ISSUE_CONF-MATNR L_MSG '' '' RETURN.
RETURN.
ENDIF.
IF IS_ISSUE_CONF-VRKME IS INITIAL.
MOVE L_H_TBL_LIPS-VRKME TO IS_ISSUE_CONF-VRKME.
ELSE.
IF IS_ISSUE_CONF-VRKME <> L_H_TBL_LIPS-VRKME.
PERFORM RETURN_MSG USING 'E' 'IPPECIF' '180' '' '' '' '' RETURN.
RETURN.
ENDIF.
ENDIF.
*- VBAK ロック
DO CNS_RETRY TIMES.
CALL FUNCTION 'ENQUEUE_EVVBAKE'
EXPORTING
MODE_VBAK = 'E'
MANDT = SY-MANDT
VBELN = L_H_TBL_LIPS-VGBEL
_SCOPE = '1'
* _WAIT = 'X'
EXCEPTIONS:
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2.
IF SY-SUBRC <> 0.
IF SY-INDEX = CNS_RETRY.
PERFORM RETURN_MSG USING 'E' '5B' '051' 'VBAK' '' '' '' RETURN.
RETURN.
ELSE.
WAIT UP TO 1 SECONDS.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
*- LIKP ロック
DO CNS_RETRY TIMES.
CALL FUNCTION 'ENQUEUE_EVVBLKE'
EXPORTING
MODE_LIKP = 'E'
MANDT = SY-MANDT
VBELN = IS_ISSUE_CONF-VBELN
_SCOPE = '1'
* _WAIT = 'X'
EXCEPTIONS:
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2.
IF SY-SUBRC <> 0.
IF SY-INDEX = CNS_RETRY.
PERFORM RETURN_MSG USING 'E' '5B' '051' 'LIKP' '' '' '' RETURN.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
RETURN.
ELSE.
WAIT UP TO 1 SECONDS.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
*-> 出庫確認・取消処理
CASE IS_ISSUE_CONF-DBEKZ.
WHEN CNS_DBEKZ_1. "出庫確認
IF L_H_TBL_LIPS-WBSTA = 'C'.
PERFORM RETURN_MSG USING 'E' 'VL' '602' '' '' '' '' RETURN.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ENDIF.
IF IS_ISSUE_CONF-LFIMG > L_H_TBL_LIPS-LFIMG.
PERFORM RETURN_MSG USING 'E' 'VLA' '201' '' '' '' '' RETURN.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ELSEIF IS_ISSUE_CONF-LFIMG < L_H_TBL_LIPS-LFIMG.
PERFORM RETURN_MSG USING 'E' 'VL' '019' '' '' '' '' RETURN.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ENDIF.
CLEAR L_H_TBL_VBKOK.
MOVE IS_ISSUE_CONF-VBELN TO L_H_TBL_VBKOK-VBELN_VL.
MOVE 'X' TO L_H_TBL_VBKOK-WABUC.
MOVE IS_ISSUE_CONF-WADAT TO L_H_TBL_VBKOK-WADAT_IST.
CLEAR: L_H_TBL_VBPOK,
L_TBL_VBPOK.
MOVE IS_ISSUE_CONF-VBELN TO L_H_TBL_VBPOK-VBELN_VL.
MOVE IS_ISSUE_CONF-POSNR TO L_H_TBL_VBPOK-POSNR_VL.
MOVE 'X' TO L_H_TBL_VBPOK-LIANP.
MOVE IS_ISSUE_CONF-LFIMG TO L_H_TBL_VBPOK-LFIMG.
MOVE '1' TO L_H_TBL_VBPOK-UMVKZ.
MOVE '1' TO L_H_TBL_VBPOK-UMVKN.
MOVE IS_ISSUE_CONF-VRKME TO L_H_TBL_VBPOK-VRKME.
APPEND L_H_TBL_VBPOK TO L_TBL_VBPOK.
CALL FUNCTION 'WS_DELIVERY_UPDATE_2'
EXPORTING
VBKOK_WA = L_H_TBL_VBKOK
SYNCHRON = 'X'
COMMIT = ' '
DELIVERY = IS_ISSUE_CONF-VBELN
NICHT_SPERREN_1 = 'X'
IF_DATABASE_UPDATE_1 = '1'
IF_ERROR_MESSAGES_SEND = ' '
IMPORTING
EF_ERROR_ANY = L_ERFLG
TABLES
VBPOK_TAB = L_TBL_VBPOK
PROT = L_TBL_PROT.
IF L_ERFLG = 'X'.
MOVE SY-MSGNO TO L_NUM.
PERFORM RETURN_MSG
USING 'E'
SY-MSGID L_NUM
SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
RETURN.
PERFORM FN_ROLLBACK.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ENDIF.
WHEN CNS_DBEKZ_2. "出庫確認取消
IF L_H_TBL_LIPS-WBSTA <> 'C'.
CONCATENATE IS_ISSUE_CONF-VBELN '-' IS_ISSUE_CONF-POSNR INTO L_MSG.
PERFORM RETURN_MSG USING 'E' 'VL' '623' L_MSG '' '' '' RETURN.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ENDIF.
IF IS_ISSUE_CONF-LFIMG <> L_H_TBL_LIPS-LFIMG.
PERFORM RETURN_MSG USING 'E' 'YGL01' '015' '' '' '' '' RETURN.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ENDIF.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
I_VBELN = IS_ISSUE_CONF-VBELN
I_BUDAT = IS_ISSUE_CONF-WADAT
I_TCODE = 'VL09'
I_VBTYP = 'J'
IMPORTING
ES_EMKPF = L_ERFLG2
TABLES
T_MESG = L_TBL_MESG
EXCEPTIONS
ERROR_REVERSE_GOODS_ISSUE = 1
ERROR_MESSAGE = 2
OTHERS = 9.
IF SY-SUBRC <> 0.
MOVE SY-MSGNO TO L_NUM.
PERFORM RETURN_MSG USING
SY-MSGTY SY-MSGID L_NUM
SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 RETURN.
PERFORM FN_ROLLBACK.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ENDIF.
ENDCASE.
*-> COMMIT.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = L_H_TBL_RETURN.
IF L_H_TBL_RETURN-TYPE = 'E'.
MOVE L_H_TBL_RETURN-NUMBER TO L_NUM.
PERFORM RETURN_MSG USING
L_H_TBL_RETURN-TYPE L_H_TBL_RETURN-ID L_NUM
L_H_TBL_RETURN-MESSAGE_V1 L_H_TBL_RETURN-MESSAGE_V2
L_H_TBL_RETURN-MESSAGE_V3 L_H_TBL_RETURN-MESSAGE_V4
RETURN.
PERFORM FN_ROLLBACK.
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
RETURN.
ENDIF.
*-> テーブルアンロック
PERFORM F_DEQUEUE_VBAK USING L_H_TBL_LIPS-VGBEL.
PERFORM F_DEQUEUE_LIKP USING IS_ISSUE_CONF-VBELN.
*-> 終了メッセージ
PERFORM RETURN_MSG USING 'S' 'KD' '207' '' '' '' '' RETURN.
ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Form FN_ROLLBACK
*&---------------------------------------------------------------------*
* ロールバック
*----------------------------------------------------------------------*
FORM FN_ROLLBACK.
*----------------------------------------------------------------------*
DATA FU_RETURN TYPE BAPIRET2. "処理結果テーブル
*----------------------------------------------------------------------*
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
IMPORTING
RETURN = FU_RETURN.
ENDFORM. "FN_ROLLBACK
*&---------------------------------------------------------------------*
*& Form RETURN_MSG
*&---------------------------------------------------------------------*
* メッセージ編集
*----------------------------------------------------------------------*
FORM RETURN_MSG USING
FU_TYPE TYPE BAPIRETURN-TYPE "メッセージタイプ
FU_CL TYPE SY-MSGID "メッセージID
FU_NUMBER TYPE C "メッセージ番号
FU_PAR1 TYPE C "TEXT
FU_PAR2 TYPE C "TEXT
FU_PAR3 TYPE C "TEXT
FU_PAR4 TYPE C "TEXT
FU_RESULT TYPE BAPIRET2. "処理結果
*----------------------------------------------------------------------*
DATA:L_MSGV1 TYPE SY-MSGV1,
L_MSGV2 TYPE SY-MSGV2,
L_MSGV3 TYPE SY-MSGV3,
L_MSGV4 TYPE SY-MSGV4,
L_NUMBER TYPE SY-MSGNO.
*----------------------------------------------------------------------*
MOVE:FU_PAR1 TO L_MSGV1,
FU_PAR2 TO L_MSGV2,
FU_PAR3 TO L_MSGV3,
FU_PAR4 TO L_MSGV4,
FU_NUMBER TO L_NUMBER.
CALL FUNCTION 'BALW_BAPIRETURN_GET2'
EXPORTING
TYPE = FU_TYPE
CL = FU_CL
NUMBER = L_NUMBER
PAR1 = L_MSGV1
PAR2 = L_MSGV2
PAR3 = L_MSGV3
PAR4 = L_MSGV4
IMPORTING
RETURN = FU_RESULT.
ENDFORM. "RETURN_MSG
*&---------------------------------------------------------------------*
*& Form F_DEQUEUE_VBAK
*&---------------------------------------------------------------------*
* VBAK アンロック
*----------------------------------------------------------------------*
FORM F_DEQUEUE_VBAK USING FU_VBELN TYPE VBELN_VA.
CALL FUNCTION 'DEQUEUE_EVVBAKE'
EXPORTING
MODE_VBAK = 'E'
MANDT = SY-MANDT
VBELN = FU_VBELN
_SCOPE = '1'.
ENDFORM. "F_DEQUEUE_VBAK
*&---------------------------------------------------------------------*
*& Form F_DEQUEUE_LIKP
*&---------------------------------------------------------------------*
* LIKP アンロック
*----------------------------------------------------------------------*
FORM F_DEQUEUE_LIKP USING FU_VBELN TYPE VBELN_VL.
CALL FUNCTION 'DEQUEUE_EVVBLKE'
EXPORTING
MODE_LIKP = 'E'
MANDT = SY-MANDT
VBELN = FU_VBELN
_SCOPE = '1'.
ENDFORM. "F_DEQUEUE_LIKP
2019年9月4日星期三
订阅:
博文评论 (Atom)
Customer Characteristic
Characteristic Descriptions are stored in the table - CABNT - Language - SPRAS - Characteristic description - ATBEZ Characteristic Values ...
-
REPORT ZBPADD2 . DATA : L_PARTN_CAT TYPE BAPIBUS1006_HEAD - PARTN_CAT , LS_CENTRAL TYPE BAPIBUS1006_CENTRAL , ...
-
HEADER: ADD Customer Fields to structure of IMKPF and BAPI_TE_XMKPF. Items: ADD Customer Fields to structure of IMSEG and BAPI_TE_XMSEG....
-
FUNCTION:SD_SALESDOCUMENT_CREATE Append fiels to Structure below. BAPE_VBAP BAPE_VBAPX VBAPKOZ VBAPKOZX No need to append fields to Struc...
没有评论:
发表评论