定义
DATA: gt_bdcdata TYPE TABLE OF bdcdata, gs_bdcdata TYPE bdcdata.
子程序
FORM bdc_dynpro USING program dynpro. gs_bdcdata-program = program. gs_bdcdata-dynpro = dynpro. gs_bdcdata-dynbegin = 'X'. APPEND gs_bdcdata TO gt_bdcdata. CLEAR gs_bdcdata. ENDFORM. *----------------------------------------------------------------------* * Insert field * *----------------------------------------------------------------------* FORM bdc_field USING fnam fval. gs_bdcdata-fnam = fnam. gs_bdcdata-fval = fval. APPEND gs_bdcdata TO gt_bdcdata. CLEAR gs_bdcdata. ENDFORM.
调用
DATA: lv_mode TYPE char1 VALUE 'N', lv_update TYPE char1 VALUE 'S', lv_msg TYPE string. DATA: lt_messtab TYPE TABLE OF bdcmsgcoll, ls_messtab TYPE bdcmsgcoll, lt_return TYPE TABLE OF bapiret2.
CALL TRANSACTION 'AIBU' USING gt_bdcdata MODE lv_mode UPDATE lv_update MESSAGES INTO lt_messtab.
消息读取
CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2' TABLES imt_bdcmsgcoll = lt_messtab ext_return = lt_return.
参考代码如下:
LOOP AT lt_head ASSIGNING FIELD-SYMBOL(<fs_head>). PERFORM bdc_dynpro USING 'SAPMA12B' '0100'. PERFORM bdc_field USING 'BDC_CURSOR' 'LKO74-TESTLAUF'. PERFORM bdc_field USING 'BDC_OKCODE' '=AUSF'. PERFORM bdc_field USING 'ANLA-BUKRS' <fs_head>-bukrs."record-bukrs_001. PERFORM bdc_field USING 'ANLA-ANLN1' <fs_head>-anln1."record-anln1_002. PERFORM bdc_field USING 'ANLA-ANLN2' <fs_head>-anln2."record-anln2_003. PERFORM bdc_field USING 'ANEK-BLDAT' p_budat."record-bldat_004. PERFORM bdc_field USING 'ANEP-BZDAT' p_budat."record-bzdat_005. PERFORM bdc_field USING 'ANEK-BUDAT' p_budat."record-budat_006. PERFORM bdc_field USING 'ANBZ-MONAT' '01'."record-monat_007. PERFORM bdc_field USING '*KOMK3-SGTXT' <fs_head>-c_sgtxt."record-sgtxt_008. PERFORM bdc_field USING '*KOMK1-BLART' 'AA'."record-blart_009. PERFORM bdc_field USING 'LKO74-TESTLAUF' ' '."record-testlauf_010. PERFORM bdc_field USING 'LKO74-LIST' 'X'."record-list_011. CALL TRANSACTION 'AIBU' USING gt_bdcdata MODE lv_mode UPDATE lv_update MESSAGES INTO lt_messtab. CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2' TABLES imt_bdcmsgcoll = lt_messtab ext_return = lt_return. READ TABLE lt_messtab INTO ls_messtab WITH KEY msgtyp = 'S'. IF sy-subrc = 0. READ TABLE lt_return INTO DATA(ls_return) INDEX 1. CLEAR gs_excel-aiab_msg. gs_excel-aibu_msg = '过账成功'. MODIFY gt_excel FROM gs_excel TRANSPORTING aibu_msg WHERE bukrs = <fs_head>-bukrs AND anln1 = <fs_head>-anln1 AND anln2 = <fs_head>-anln2. ELSE. CLEAR lv_msg. LOOP AT lt_return INTO ls_return WHERE type = 'E'. lv_msg = lv_msg && ls_return-message . ENDLOOP. CLEAR gs_excel-aiab_msg. gs_excel-aibu_msg = '过账失败:' && lv_msg. MODIFY gt_excel FROM gs_excel TRANSPORTING aibu_msg WHERE bukrs = <fs_head>-bukrs AND anln1 = <fs_head>-anln1 AND anln2 = <fs_head>-anln2. ENDIF. CLEAR :gt_bdcdata, lt_messtab, lt_return. ENDLOOP.
标签:gs,bdc,BDC,PERFORM,汇总,问题,field,USING,bdcdata From: https://www.cnblogs.com/Anyohh233/p/18059341