BAPI_OUTB_DELIVERY_CONFIRM_DEC
该BAPI主要用于修改与过账。
交货单过账相关代码示例:
DATA: I_VBPOK_TAB TYPE TABLE OF VBPOK WITH HEADER LINE, I_VBKOK TYPE VBKOK. DATA: LT_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE. DATA: LS_RETURN TYPE BAPIRET2 . DATA: LV_APPID TYPE CHAR12. DATA: LV_GARG TYPE SEQG3-GARG. DATA: LT_ENQ TYPE TABLE OF SEQG3, LS_ENQ TYPE SEQG3. DATA: LV_WBSTK TYPE WBSTK. DATA: LV_MATNR TYPE MATNR. DATA: LV_BOLNR TYPE BOLNR. DATA: LV_KUNNR TYPE KUNNR. DATA: LV_VGBEL TYPE VGBEL. DATA: LV_VLSTK TYPE VLSTK.*&---发货过账 DATA: WA_HEADER_DATA TYPE BAPIOBDLVHDRCON, WA_HEADER_CONTROL TYPE BAPIOBDLVHDRCTRLCON. CLEAR: GS_LIKP,LT_LOG. CLEAR: GS_BAPI. LOOP AT GT_LIKP INTO GS_LIKP. CLEAR: RETURN. REFRESH: RETURN. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING INPUT = GS_LIKP-VBELN IMPORTING OUTPUT = GS_LIKP-VBELN.*********************************************判断锁********************************* "判断锁机制 CONCATENATE SY-MANDT GS_LIKP-VBELN INTO LV_GARG. "如果当前项目正在被修改,就在前端给报错-- CALL FUNCTION 'ENQUEUE_READ' EXPORTING GCLIENT = SY-MANDT GNAME = 'LIKP' GARG = LV_GARG GUNAME = '' TABLES ENQ = LT_ENQ EXCEPTIONS COMMUNICATION_FAILURE = 1 SYSTEM_FAILURE = 2 OTHERS = 3. IF SY-SUBRC <> 0.* Implement suitable error handling here ENDIF. IF LT_ENQ[] IS INITIAL. ELSE. READ TABLE LT_ENQ INTO LS_ENQ INDEX 1 . IF SY-SUBRC EQ 0. RETURN-TYPE = 'E'. RETURN-MESSAGE = '交货单被对象锁定'. APPEND RETURN. ENDIF. ENDIF.*********************************************判断锁********************************* IF RETURN IS INITIAL.***********************************************更新+过账**********************************&--检查是否可以过账 CLEAR: LV_WBSTK,LV_VLSTK,LV_BOLNR,GS_BAPI. READ TABLE GT_BAPI INTO GS_BAPI WITH KEY VBELN = GS_LIKP-VBELN. IF SY-SUBRC EQ 0. LV_BOLNR = GS_BAPI-BOLNR."提单 ENDIF. SELECT SINGLE WBSTK INTO LV_WBSTK FROM VBUK WHERE VBELN = GS_LIKP-VBELN. IF LV_WBSTK NE 'C'. CLEAR: WA_HEADER_DATA,WA_HEADER_CONTROL,GS_BAPI.*&---交货抬头数据 WA_HEADER_DATA-DELIV_NUMB = GS_LIKP-VBELN. WA_HEADER_DATA-BILLOFLADING = LV_BOLNR."提单 WA_HEADER_CONTROL-DELIV_NUMB = GS_LIKP-VBELN. WA_HEADER_CONTROL-POST_GI_FLG = 'X'. WA_HEADER_CONTROL-VOLUME_FLG = 'X'. CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC' EXPORTING HEADER_DATA = WA_HEADER_DATA HEADER_CONTROL = WA_HEADER_CONTROL DELIVERY = GS_LIKP-VBELN TABLES RETURN = RETURN. ENDIF. ENDIF.****************************************过账**************************************************************返回消息************************** CLEAR: LV_MATNR,LV_KUNNR,LV_VGBEL. SELECT SINGLE MATNR FROM LIPS INTO LV_MATNR WHERE VBELN = GS_LIKP-VBELN. "物料* SELECT SINGLE BOLNR FROM LIKP INTO LV_BOLNR WHERE VBELN = GS_LIKP-VBELN."提单 SELECT SINGLE VBAK~KUNNR "客户编号 FROM LIPS JOIN VBAK ON VBAK~VBELN = LIPS~VGBEL INTO LV_KUNNR WHERE LIPS~VBELN = GS_LIKP-VBELN . SELECT SINGLE VGBEL INTO LV_VGBEL FROM LIPS WHERE VBELN = GS_LIKP-VBELN."asn READ TABLE RETURN WITH KEY TYPE = 'E'. IF SY-SUBRC = 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. CLEAR: LS_LOG. LS_LOG-MANDT = SY-MANDT. LS_LOG-VBELN = GS_LIKP-VBELN."asn LS_LOG-VGBEL = LV_VGBEL."asn LS_LOG-KUNNR = LV_KUNNR. LS_LOG-MATNR = LV_MATNR. LS_LOG-BOLNR = LV_BOLNR."提单 LS_LOG-ZFILE = GV_FILE. LS_LOG-UNAME = SY-UNAME. LS_LOG-DATUM = SY-DATUM. LS_LOG-UZEIT = SY-UZEIT. LS_LOG-STATUS = '0'. LS_LOG-MESSAGE = RETURN-MESSAGE. APPEND LS_LOG TO LT_LOG. LV_FLAG = 'X'. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING WAIT = 'X'* IMPORTING* RETURN = . UPDATE LIKP SET VLSTK = '' ANZPK = '0' WHERE VBELN = GS_LIKP-VBELN." 处理分配状态(分散仓库处理)标志 便于vl09冲销 IF SY-SUBRC = 0. COMMIT WORK AND WAIT. ELSE. ROLLBACK WORK. ENDIF. MESSAGE '成功' TYPE 'S'. CLEAR: LS_LOG. LS_LOG-MANDT = SY-MANDT. LS_LOG-VBELN = GS_LIKP-VBELN. LS_LOG-VGBEL = LV_VGBEL."asn LS_LOG-KUNNR = LV_KUNNR. LS_LOG-MATNR = LV_MATNR. LS_LOG-BOLNR = LV_BOLNR."提单 LS_LOG-ZFILE = GV_FILE. LS_LOG-UNAME = SY-UNAME. LS_LOG-DATUM = SY-DATUM. LS_LOG-UZEIT = SY-UZEIT. LS_LOG-STATUS = '1'. LS_LOG-MESSAGE = '处理成功'. APPEND LS_LOG TO LT_LOG. ENDIF.************************************返回消息************************** ENDLOOP.