SHDB批导注意事项
PARAMETERS: p_typ TYPE ctu_mode AS LISTBOX OBLIGATORY DEFAULT 'N' VISIBLE LENGTH 20, p_upd TYPE ctu_update AS LISTBOX OBLIGATORY DEFAULT 'S' VISIBLE LENGTH 20, * p_racom TYPE c AS CHECKBOX, p_werks TYPE mard-werks. DATA: lt_bdcdata TYPE TABLE OF bdcdata, "全局变量 lt_bdcmsg TYPE TABLE OF bdcmsgcoll WITH HEADER LINE, l_opt TYPE ctu_params. DATA:bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE. DATA:lt_bdcmsgcoll TYPE TABLE OF bdcmsgcoll WITH HEADER LINE. DATA:lt_bapireturn TYPE TABLE OF bapiret2 WITH HEADER LINE. REFRESH: bdcdata[]. CLEAR:bdcdata. "初始屏幕 PERFORM bdc_dynpro USING 'SAPMWBE3' '0101'. PERFORM bdc_field USING 'BDC_OKCODE' '=ENTR'. PERFORM bdc_field USING 'WR02D-LOCNR' p_werks. PERFORM bdc_field USING 'WR02D-BETRP' 'Z002'. PERFORM bdc_field USING 'WR02D-REF_WKFIL' 'DS99'. "进入后点保存 PERFORM bdc_dynpro USING 'SAPMWBE3' '0401'. PERFORM bdc_field USING 'BDC_OKCODE' '=UPDA'. PERFORM bdc_field USING 'WR02D-SITE_BP' p_werks. PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPMWBE3 5100SUB1'. PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPMWBE3 2100ORGA'. PERFORM bdc_field USING 'T001K-BUKRS' '2000'. PERFORM bdc_field USING 'T001W-EKORG' '3000'. PERFORM bdc_field USING 'T001W-VKORG' '2000'. PERFORM bdc_field USING 'T001W-VTWEG' '20'. PERFORM bdc_field USING 'T001W-SPART' '10'. "弹窗点否 PERFORM bdc_dynpro USING 'SAPLSPO1' '0100'. PERFORM bdc_field USING 'BDC_OKCODE' '=NO'. PERFORM bdc_dynpro USING 'SAPLPLANT_DISPLAY_CUSTOMIZING' '1000'. PERFORM bdc_field USING 'BDC_OKCODE' '=BSTV'. PERFORM bdc_dynpro USING 'SAPLSPO2' '0301'. PERFORM bdc_field USING 'BDC_OKCODE' '=OPT1'. * DATA: l_opt TYPE ctu_params. . l_opt-racommit = 'X'. l_opt-dismode = p_typ. l_opt-updmode = p_upd. CALL TRANSACTION 'WB01' USING bdcdata[] "传入的BDC数据 * MODE p_typ * UPDATE p_upd OPTIONS FROM l_opt * MODE 'N' * UPDATE 'S' MESSAGES INTO lt_bdcmsgcoll[]. "将结果放在LT_BDCMSGCOLL[]输出 CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2' TABLES imt_bdcmsgcoll = lt_bdcmsgcoll ext_return = lt_bapireturn. READ TABLE lt_bapireturn WITH KEY type = 'E'. IF sy-subrc NE 0. * gs_data-msgtp = 'S'. * IF gs_data-msg IS INITIAL. * gs_data-msg = '工厂创建成功'. * ELSE . * CONCATENATE gs_data-msg '工厂创建成功' INTO gs_data-msg. * ENDIF. ELSE. LOOP AT lt_bapireturn WHERE type = 'E'. * gs_data-msgtp = 'E'. * CONCATENATE gs_data-msg lt_bapireturn-message INTO gs_data-msg SEPARATED BY '/'. ENDLOOP. ENDIF. *----------------------------------------------------------------------* * Start new screen * *----------------------------------------------------------------------* FORM bdc_dynpro USING program dynpro. DATA: ls_bdc TYPE bdcdata. ls_bdc-program = program. ls_bdc-dynpro = dynpro. ls_bdc-dynbegin = 'X'. APPEND ls_bdc TO bdcdata. ENDFORM. *----------------------------------------------------------------------* * Insert field * *----------------------------------------------------------------------* FORM bdc_field USING fnam fval. DATA: ls_bdc TYPE bdcdata. ls_bdc-fnam = fnam. ls_bdc-fval = fval. CONDENSE ls_bdc-fval . APPEND ls_bdc TO bdcdata. ENDFORM.