zoukankan
html css js c++ java
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
查看全文
相关阅读:
11 2
10 29
10 22
dp的本质
笛卡尔树小结
Gitlab 备份迁移恢复报错gtar: .: Cannot mkdir: No such file or directory
升级Jenkins版本
当linux中的所有指令突然不能使用的时候
合并范围
每股收益列报计算
原文地址:https://www.cnblogs.com/xiaomaohai/p/6157435.html
最新文章
register
express
关于0
编辑距离问题
long long or int
English trip -- VC(情景课)4 D
English trip -- MC(情景课)3 D
English trip -- VC(情景课)4 C My feet hurt 我脚痛
windows 命令巧用(持续更新)
浅触selinux(持续更新)
热门文章
转:Too many systemd: Created slice !
English trip -- VC(情景课)4 B Parts of the body 身体部位
dd 命令常用功能收集(ing...)
English trip -- VC(情景课)4 A Health
English trip -- VC(情景课)3 D Reading
NTT学习笔记
常见错误总结
bzoj 题目选做
一些计划
最后的复习
Copyright © 2011-2022 走看看