-
Post a transaction and the appropriate status to the IDoc.
On inbound function modules processing IDocs the following template can be used to post a transaction and the appropriate status to the IDoc.
*---- Data definition -------------------------------------------------
DATA: BEGIN OF BDCDATA OCCURS 5.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
DATA: C_TCODE LIKE BKPF-TCODE VALUE 'FB01'.
DATA BEGIN OF MESSTAB OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF MESSTAB.
*---- Call transaction ------------------------------------------------
FORM Main_Program
REFRESH BDCDATA.
PERFORM APPEND_BDC USING 'SAPMF05A' '0100' ' ' ' '.
PERFORM APPEND_BDC USING ' ' ' ' 'BKPF-BLDAT' '09031998'.
PERFORM APPEND_BDC USING ' ' ' ' 'BDC_OKCODE' '/00'.
PERFORM APPEND_BDC USING 'SAPMF05A' '0300' ' ' ' '.
PERFORM APPEND_BDC USING ' ' ' ' 'BSEG-WRBTR' '*'.
PERFORM APPEND_BDC USING ' ' ' ' 'BDC_OKCODE' 'BU'.
CALL TRANSACTION 'FB01' USING BDCDATA MODE 'N' UPDATE 'S'.
PERFORM UPDATE_IDOC_STATUS.
ENDFORM.
*--- Call transaction with errors to BDC -----------------------------
REFRESH MESSTAB.
CALL TRANSACTION C_TCODE USING BDCDATA MODE 'N' UPDATE 'S'
MESSAGES INTO MESSTAB.
RETURN_CODE = SY-SUBRC.
IF RETURN_CODE = 0.
LOOP AT MESSTAB.
IF MESSTAB-MSGTYP = 'E'.
RETURN_CODE = MESSTAB-MSGNR.
SY-MSGID = 'B1'.
SY-MSGNO = 999.
SY-MSGV1 = 'Error: Check BDC'.
ENDIF.
ENDLOOP.
ENDIF.
*--- Here we check the return code, if there was an error, we put the
* transaction in a BDC session for the user to review and correct.
IF RETURN_CODE NE 0.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'ZKJW'
USER = SY-UNAME
KEEP = 'X'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = C_TCODE
TABLES
DYNPROTAB = BDCDATA.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
ENDIF.
*--- Append BDCDATA internal table ------------------------------------
FORM APPEND_BDC USING VALUE(P_PROG)
VALUE(P_SCREEN)
VALUE(P_NAM)
VALUE(P_VAL).
CLEAR BDCDATA.
IF P_PROG NE SPACE.
BDCDATA-PROGRAM = P_PROG.
BDCDATA-DYNPRO = P_SCREEN.
BDCDATA-DYNBEGIN = 'X'.
BDCDATA-FNAM = P_NAM.
BDCDATA-FVAL = P_VAL.
ELSE.
BDCDATA-FNAM = P_NAM.
BDCDATA-FVAL = P_VAL.
ENDIF.
APPEND BDCDATA.
ENDFORM.
*&---------------------------------------------------------------------*
FORM UPDATE_IDOC_STATUS.
*--- Now we check the CALL TRANSACTION return code and set IDOC status
CLEAR IDOC_STATUS.
IF RETURN_CODE = 0.
WORKFLOW_RESULT = '0'.
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-STATUS = '53'.
IDOC_STATUS-UNAME = SY-UNAME.
IDOC_STATUS-REPID = SY-REPID.
IDOC_STATUS-MSGTY = SY-MSGTY.
IDOC_STATUS-MSGID = SY-MSGID.
IDOC_STATUS-MSGNO = SY-MSGNO.
IDOC_STATUS-MSGV1 = SY-MSGV1.
IDOC_STATUS-MSGV2 = SY-MSGV2.
IDOC_STATUS-MSGV3 = SY-MSGV3.
IDOC_STATUS-MSGV4 = SY-MSGV4.
RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
APPEND RETURN_VARIABLES.
ELSE.
WORKFLOW_RESULT = '99999'.
IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
IDOC_STATUS-STATUS = '51'.
IDOC_STATUS-UNAME = SY-UNAME.
IDOC_STATUS-REPID = SY-REPID.
IDOC_STATUS-MSGTY = SY-MSGTY.
IDOC_STATUS-MSGID = SY-MSGID.
IDOC_STATUS-MSGNO = SY-MSGNO.
IDOC_STATUS-MSGV1 = SY-MSGV1.
IDOC_STATUS-MSGV2 = SY-MSGV2.
IDOC_STATUS-MSGV3 = SY-MSGV3.
IDOC_STATUS-MSGV4 = SY-MSGV4.
RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
APPEND RETURN_VARIABLES.
ENDIF.
APPEND IDOC_STATUS.
ENDFORM. " UPDATE_IDOC_STATUS
-
相关阅读:
springboot之静态资源路径配置
window使用结束进程
MyBatis动态sql语句归纳
Mybatis——实体类属性名和数据库字段名不同时的解决方案
oracle 查看被锁表 及解除锁定
Eclipse设置软tab(用4个空格字符代替)及默认utf-8文件编码(unix)
navicat和 plsql 连接oracle数据库 总结
eclipse 快捷键Open Implementation 直接退出
linux centos 安装mysql
拦截器 过滤器 监听器 的区别
-
原文地址:https://www.cnblogs.com/xiaomaohai/p/6157435.html
Copyright © 2020-2023
润新知