BDC 代码设置
录频 T-CODE : SHDB -> 在生成程序中设置相关代码
DATA:
TBL_BDCDATA TYPE TABLE OF BDCDATA,
WORK_TCODE TYPE CHAR10 VALUE 'ZE001',
WORK_UPTYP TYPE CHAR1 VALUE 'S',
WORK_MOKDE TYPE CHAR1 VALUE 'N'.
* BDC设置,--DYNPRO
FORM SET_BDC_DYNPRO_RNT USING P_PROGRAM TYPE ANY
P_DYNPRO TYPE ANY.
DATA: L_REC_BDCDATA TYPE BDCDATA.
CLEAR : L_REC_BDCDATA.
L_REC_BDCDATA-DYNBEGIN = 'X'.
L_REC_BDCDATA-PROGRAM = P_PROGRAM.
L_REC_BDCDATA-DYNPRO = P_DYNPRO.
APPEND L_REC_BDCDATA TO TBL_BDCDATA.
ENDFORM.
* BDC设置,--项目
FORM SET_BDC_FIELD_RTN USING P_FNAM TYPE ANY
P_FVAL TYPE ANY.
DATA : L_REC_BDCDATA TYPE BDCDATA.
L_REC_BDCDATA-FNAM = P_FNAM.
L_REC_BDCDATA-FVAL = P_FVAL.
APPEND L_REC_BDCDATA TO TBL_BDCDATA.
ENDFORM.
FORM PUR_CONTRACT_MODIFY.
DATA:
L_TBL_BDCMSG TYPE TABLE OF BDCMSGCOLL,
L_REC_INFILE TYPE TYP_INFILE,
L_REC_BDCMSG TYPE BDCMSGCOLL,
L_REC_LOG TYPE TYP_LOG,
L_WORK_MSGTXT TYPE STRING.
CLEAR : CTR_CRECT.
LOOP AT TBL_INFILE INTO L_REC_INFILE.
* BDCDATA的编辑
PERFORM SET_BDC_DYNPRO_RTN USING 'SAPMZE030010' '9002'.
PERFORM SET_BDC_FIELD_RTN USING 'BDC_CURSOR' 'ZR9002_3'.
PERFORM SET_BDC_FIELD_RTN USING 'BDC_OKCODE' '=KHELP'.
PERFORM SET_BDC_FIELD_RTN USING 'ZTTE03004-ZKANRINO'
L_REC_INFILE-ZKANRINO.
PERFORM SET_BDC_FIELD_RTN USING 'ZR9002_3' 'X'.
PERFORM SET_BDC_DYNPRO_RTN USING 'SAPMZE030010' '9002'.
PERFORM SET_BDC_FIELD_RTN USING 'BDC_CURSOR' 'ZTTE03004-ZKANRINO'.
PERFORM SET_BDC_FIELD_RTN USING 'BDC_OKCODE' '=ENTR'.
PERFORM SET_BDC_FIELD_RTN USING 'ZTTE03004-ZKANRINO' L_REC_INFILE-ZKANRINO.
PERFORM SET_BDC_FILED_RTN USING 'ZR9002_3' 'X'.
PERFORM SET_BDC_DYNPRO_RTN USING 'SAPMZE030010' '9003'.
PERFORM SET_BDC_FIELD_RTN USING 'BDC_CURSOR' 'ZTTE03006-ZKNKJUKYMD'.
PERFORM SET_BDC_FIELD_RTN USING 'BDC_OKCODE' '=KSAV'.
PERFORM SET_BDC_FIELD_RTN USING 'ZTTE03006-ZKNKJUKKSYMD' P_DECDT.
PERFORM SET_BDC_FIELD_RTN USING 'ZTTE03006-ZKNKJUKKSCD' L_REC_ZKNKJUKKSCD.
PERFORM SET_BDC_FIELD_RTN USING 'ZTTE03006-ZKNKJUKYMD' P_RELDT.
PERFORM SET_BDC_DYNPRO_RTN USING 'SAPLSP01' '0500'.
PERFORM SET_BDC_FIELD_RTN USING 'BDC_OKCODE' '=OPT1'.
CALL TRANSACTION WORK_TCODE USING TBL_BDCDATA
MODE WORK_MODE
UPDATE WORK_UPTYP
MESSAGE INTO L_TBL_BDCMSG.
LOOP AT L_TBL_BDCMSG INTO L_REC_BDCMSG
WHERE MSGTYP = 'E'
OR MSGTYP = 'A'.
EXIT.
ENDLOOP.
IF SY-SUBRC = 0.
MESSAGE
ID L_REC_BDCMSG-MSGID
TYPE L_REC_BDCMSG-MSGTYP
NUMBER L_REC_BDCMSG-MSGNR
WITH L_REC_BDCMSG-MSGV1
L_REC_BDCMSG-MSGV2
L_REC_BDCMSG-MSGV3
L_REC_BDCMSG-MSGV4.
ENDIF.
ENDLOOP.
ENDFORM.