在这个项目整了个体力活,自动化。说白了就是全部录制BDC。一直用系统生成源代码的方式去写BDC。第一次看到这个,觉得挺不错。
写写就发现问题,因为项目全部程序都是录制BDC,一个模块几十个。导致复制黏贴字段十分费劲,还容易出问题。
总的来说,做一两个,用这种方式还挺好的,和SHDB录制结果步骤界面一样。
但是量多的话还是标准源代码合适,毕竟全部复制黏贴。人为失误会少很多。
截图
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
*&---------------------------------------------------------------------* *& Form FRM_BDC_MM03 *&---------------------------------------------------------------------* *& 创建采购组织 *&---------------------------------------------------------------------* *& --> PU_BDCLOG *& --> PU_REQNO *&---------------------------------------------------------------------* FORM frm_bdc_mm03 USING pu_bdclog TYPE ztbcauto_bdclog pu_reqno. DATA:lt_return TYPE STANDARD TABLE OF bapiret2, ls_return TYPE bapiret2, lv_message TYPE string, lt_bdcdata TYPE TABLE OF bdcdata. CLEAR:gt_msgtab, lt_return. LOOP AT gt_mm05 INTO gw_mm05 WHERE succ_flg = ''. lt_bdcdata = VALUE #( ( program = 'SAPL0ORG' dynpro = '0120' dynbegin = 'X' fnam = 'BDC_CURSOR' fval = 'V_T024E-EKOTX(01)' ) "公司名变量 ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=NEWL' ) ( program = 'SAPL0ORG' dynpro = '0120' dynbegin = 'X' fnam = 'BDC_SUBSCR' fval = 'V_T024E-EKOTX(01)' ) " ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=SAVE' ) " ( program = '' dynpro = '' dynbegin = '' fnam = 'V_T024E-EKORG(01)' fval = gw_mm05-mm_ekorg ) "采购组织 ( program = '' dynpro = '' dynbegin = '' fnam = 'V_T024E-EKOTX(01)' fval = gw_mm05-mm_ekotx ) " ( program = 'SAPLSTRD' dynpro = '0300' dynbegin = 'X' fnam = 'BDC_CURSOR' fval = 'KO008-TRKORR' ) ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=LOCK' ) ( program = '' dynpro = '' dynbegin = '' fnam = 'KO008-TRKORR' fval = pu_reqno ) ( program = 'SAPL0ORG' dynpro = '0120' dynbegin = 'X' fnam = 'BDC_SUBSCR' fval = 'V_T024E-EKORG(02)' ) ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=SAVE' ) ( program = 'SAPL0ORG' dynpro = '0120' dynbegin = 'X' fnam = 'BDC_SUBSCR' fval = 'V_T024E-EKORG(02)' ) ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=BACK' ) ( program = 'SAPL0ORG' dynpro = '0120' dynbegin = 'X' fnam = 'BDC_SUBSCR' fval = 'V_T024E-EKORG(02)' ) ( program = '' dynpro = '' dynbegin = '' fnam = 'BDC_OKCODE' fval = '=BACK' ) ). CALL TRANSACTION 'OX08' USING lt_bdcdata MODE p_bdcmd UPDATE 'S' MESSAGES INTO gt_msgtab. WAIT UP TO 1 SECONDS. CLEAR:lt_return,lv_message. CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2' TABLES imt_bdcmsgcoll = gt_msgtab ext_return = lt_return. LOOP AT lt_return INTO ls_return WHERE type CA 'AEX'. IF lv_message IS INITIAL. lv_message = ls_return-message. ELSE. lv_message = lv_message && ls_return-message. ENDIF. ENDLOOP. IF lv_message IS NOT INITIAL. pu_bdclog-message = 'MM模块OX08执行失败,原因:' && lv_message. pu_bdclog-chuser = sy-uname. pu_bdclog-chdate = sy-datum. pu_bdclog-chtime = sy-uzeit. gv_errflg = 'X'. ELSE. "判断表里存在与否 SELECT COUNT(*) FROM t024e WHERE ekorg = gw_mm05-mm_ekorg AND ekotx = gw_mm05-mm_ekotx. IF sy-subrc = 0. pu_bdclog-message = '配置执行成功'. "最后一个模块配置完提示成功 pu_bdclog-proc_flg = 'X'. pu_bdclog-chtime = sy-uzeit. "更新mm表 UPDATE ztbcauto_mm05 SET succ_flg = 'X' WHERE pjnum = gw_mm05-pjnum AND mknam = gw_mm05-mknam AND mm_ekorg = gw_mm05-mm_ekorg. ELSE. pu_bdclog-message = 'MM模块OX08执行失败,原因:' && 'T024E表中没产生数据'. pu_bdclog-chuser = sy-uname. pu_bdclog-chdate = sy-datum. pu_bdclog-chtime = sy-uzeit. gv_errflg = 'X'. ENDIF. ENDIF. ENDLOOP. ENDFORM. |