流水号操作(二)- Number Range 清零
1.通过录制BDC操作,录制清空Number Range 对象值。
2.创建后台作业任务,定时操作。
录制BDC的TCode为:SHDB.
后台作业操作TCode为:SM36.
后台程序(其中BDC部分可录制后,再放进去):
1 REPORT zbc_number_range_zeroing. 2 3 4 ************************************************************************ 5 * I N C L U D E * 6 ************************************************************************ 7 INCLUDE zbdcrecx1. 8 9 10 ************************************************************************ 11 * S E L E C T I O N S C R E E N * 12 ************************************************************************ 13 SELECTION-SCREEN BEGIN OF BLOCK block1. 14 15 PARAMETERS: cb_auto TYPE c AS CHECKBOX. 16 17 SELECTION-SCREEN END OF BLOCK block1. 18 ************************************************************************ 19 * I N I T I A L I Z A T I O N * 20 ************************************************************************ 21 INITIALIZATION. 22 23 ************************************************************************ 24 * T O P O F P A G E * 25 ************************************************************************ 26 27 ************************************************************************ 28 * S T A R T O F S E L E C T I O N * 29 ************************************************************************ 30 START-OF-SELECTION. 31 32 * 外箱条码归零 33 PERFORM frm_data_process using 'ZBC_BOX'. 34 35 * 产品条码归零 36 PERFORM frm_data_process using 'ZBC_CODE'. 37 38 ************************************************************************ 39 * E N D O F S E L E C T I O N * 40 ************************************************************************ 41 END-OF-SELECTION. 42 43 44 *&---------------------------------------------------------------------* 45 *& Form frm_data_process 46 *&---------------------------------------------------------------------* 47 * text 48 *----------------------------------------------------------------------* 49 FORM frm_data_process USING pv_object. 50 51 PERFORM bdc_dynpro USING 'SAPMSNRO' '0150'. 52 PERFORM bdc_field USING 'BDC_CURSOR' 53 'NRIV-OBJECT'. 54 PERFORM bdc_field USING 'BDC_OKCODE' 55 '=IUPD'. 56 PERFORM bdc_field USING 'NRIV-OBJECT' 57 pv_object. "'ZBC_CODE'. "对象名称 58 PERFORM bdc_dynpro USING 'SAPMSNUM' '0100'. 59 PERFORM bdc_field USING 'BDC_OKCODE' 60 '=LUPD'. 61 PERFORM bdc_dynpro USING 'SAPLSNR0' '0503'. 62 PERFORM bdc_field USING 'BDC_CURSOR' 63 'INRDP-NRLEVEL(01)'. 64 PERFORM bdc_field USING 'BDC_OKCODE' 65 '=SAVE'. 66 PERFORM bdc_field USING 'INRDP-NRLEVEL(01)' 67 '0'. 68 PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'. 69 PERFORM bdc_field USING 'BDC_OKCODE' 70 '=DBAC'. 71 PERFORM bdc_dynpro USING 'SAPLSNR0' '0503'. 72 PERFORM bdc_field USING 'BDC_CURSOR' 73 'INRDP-FROMNUMBER(01)'. 74 PERFORM bdc_field USING 'BDC_OKCODE' 75 '=ENDA'. 76 PERFORM bdc_dynpro USING 'SAPMSNRO' '0150'. 77 PERFORM bdc_field USING 'BDC_CURSOR' 78 'NRIV-OBJECT'. 79 PERFORM bdc_field USING 'BDC_OKCODE' 80 '=ENDA'. 81 PERFORM bdc_field USING 'NRIV-OBJECT' 82 pv_object. "'ZBC_CODE'. "对象名称 83 PERFORM bdc_transaction USING 'SNRO' 'N'. 84 * ENDIF. 85 86 87 ENDFORM. "frm_data_process
在后台程序中,用到的自定义BDC Include 文件程序(ZBDCRECX1):
1 *&---------------------------------------------------------------------* 2 *& 包括 ZBDCRECX1 3 *&---------------------------------------------------------------------* 4 5 *----------------------------------------------------------------------* 6 * data definition 7 *----------------------------------------------------------------------* 8 * Batchinputdata of single transaction 9 DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE. 10 * messages of call transaction 11 DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE. 12 * error session opened (' ' or 'X') 13 DATA: e_group_opened. 14 * message texts 15 TABLES: t100. 16 17 *----------------------------------------------------------------------* 18 * Start new transaction according to parameters * 19 *----------------------------------------------------------------------* 20 FORM bdc_transaction USING tcode ctumode. 21 DATA: l_mstring(480). 22 DATA: l_subrc LIKE sy-subrc. 23 24 REFRESH messtab. 25 CALL TRANSACTION tcode USING bdcdata 26 MODE ctumode "跟踪显示 N不显示 E仅显示错误 27 UPDATE 'A' "A异步 B同步 L本地更新 28 MESSAGES INTO messtab. 29 l_subrc = sy-subrc. 30 WRITE: / 'CALL_TRANSACTION', 31 tcode, 32 'returncode:'(i05), 33 l_subrc, 34 'RECORD:', 35 sy-index. 36 LOOP AT messtab. 37 SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra 38 AND arbgb = messtab-msgid 39 AND msgnr = messtab-msgnr. 40 IF sy-subrc = 0. 41 l_mstring = t100-text. 42 IF l_mstring CS '&1'. 43 REPLACE '&1' WITH messtab-msgv1 INTO l_mstring. 44 REPLACE '&2' WITH messtab-msgv2 INTO l_mstring. 45 REPLACE '&3' WITH messtab-msgv3 INTO l_mstring. 46 REPLACE '&4' WITH messtab-msgv4 INTO l_mstring. 47 ELSE. 48 REPLACE '&' WITH messtab-msgv1 INTO l_mstring. 49 REPLACE '&' WITH messtab-msgv2 INTO l_mstring. 50 REPLACE '&' WITH messtab-msgv3 INTO l_mstring. 51 REPLACE '&' WITH messtab-msgv4 INTO l_mstring. 52 ENDIF. 53 CONDENSE l_mstring. 54 WRITE: / messtab-msgtyp, l_mstring(250). 55 ELSE. 56 WRITE: / messtab. 57 ENDIF. 58 ENDLOOP. 59 REFRESH bdcdata. 60 ENDFORM. "BDC_TRANSACTION 61 62 *----------------------------------------------------------------------* 63 * Start new screen * 64 *----------------------------------------------------------------------* 65 FORM bdc_dynpro USING program dynpro. 66 CLEAR bdcdata. 67 bdcdata-program = program. 68 bdcdata-dynpro = dynpro. 69 bdcdata-dynbegin = 'X'. 70 APPEND bdcdata. 71 ENDFORM. "BDC_DYNPRO 72 73 *----------------------------------------------------------------------* 74 * Insert field * 75 *----------------------------------------------------------------------* 76 FORM bdc_field USING fnam fval. 77 CLEAR bdcdata. 78 bdcdata-fnam = fnam. 79 bdcdata-fval = fval. 80 APPEND bdcdata. 81 ENDFORM. "BDC_FIELD