BDC必备函数
IT_BDCDATA TYPE STANDARD TABLE OF BDCDATA,
WA_BDC TYPE TY_BDC,
IT_MSEG TYPE STANDARD TABLE OF BDCMSGCOLL, "BDC信息反馈表
IT_BAPIRETURN TYPE STANDARD TABLE OF BAPIRET2.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
ENDFORM.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
使用:
LOOP AT IT_BDC INTO WA_BDC.
PERFORM BDC_DYNPRO USING 'SAPLCPDI' '1010'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RC27M-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RC27M-MATNR'
WA_BDC-MATNR.
PERFORM BDC_FIELD USING 'RC27M-WERKS'
WA_BDC-WERKS.
PERFORM BDC_FIELD USING 'RC271-PLNNR'
WA_BDC-PLNNR.
PERFORM BDC_FIELD USING 'RC271-STTAG'
WA_BDC-DATUV.
NOBINPT-DISMODE = 'N'.
CALL TRANSACTION 'CA02' USING IT_BDCDATA OPTIONS FROM NOBINPT MESSAGES INTO IT_MSEG.
“将BDC错误文本信息回写到IT_BAPIRETURN里面
CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2'"
TABLES
IMT_BDCMSGCOLL = IT_MSEG
EXT_RETURN = IT_BAPIRETURN.
CLEAR IT_BDCDATA.
CLEAR IT_MSEG.
CLEAR IT_BAPIRETURN.
ENDLOOP.