AS01_创建资产主数据
一、功能介绍
-
使用事务码AS01创建资产主数据
二、程序代码
-
程序代码:
REPORT zfir002.TYPE-POOLS: slis, icon. TYPES: BEGIN OF ty_file,zanln TYPE anla-anln1, "资产编号anln2 TYPE anla-anln2, "资产次级编号bukrs TYPE anla-bukrs, "公司代码anlkl TYPE anla-anlkl, "资产分类txt50 TYPE anla-txt50, "资产描述txa50 TYPE anla-txa50, "附加资产描述sernr TYPE anla-sernr, "序列号invnr TYPE anla-invnr, "存货号 旧资产编号quantity TYPE bapi1022_feglg001-quantity, "数量base_uom TYPE bapi1022_feglg001-base_uom, "单位invzu TYPE anla-invzu, "库存备注aktiv TYPE anla-aktiv, "资产资本化日期kostl TYPE anlz-kostl, "成本中心kostlv TYPE anlz-kostlv, "责任成本中心caufn TYPE anlz-caufn, "内部订单ord41 TYPE anla-ord41, "变动方式ord42 TYPE anla-ord42, "使用状态ord43 TYPE anla-ord43, "经济用途lifnr TYPE lifnr, "供应商liefe TYPE anla-liefe, "供应商描述herst TYPE herst , "制造商afasl TYPE anlb-afasl, "折旧码ndjar TYPE anlb-ndjar, "计划年限ndper TYPE anlb-ndper, "计划月safbg TYPE anlb-safbg, "折旧开始日期kansw TYPE anlc-kansw, "购置价值knafa TYPE anlc-knafa, "以前年度折旧nafag TYPE anlc-nafag, "当期年度折旧schrw TYPE anlb-schrw, " 残值END OF ty_file,BEGIN OF ty_result.INCLUDE TYPE ty_file. TYPES: icon TYPE icon-id, "图标message TYPE string, "消息内容anln1 TYPE anla-anln1, "主资产号 * anln2 type anla-anln2, "资产次级编号mark TYPE as4flag, "选中行return TYPE bapiret2_t, "处理结果消息表END OF ty_result. DATA :ls_return TYPE bapiret2."处理结果消息工作区*----------------------------------------------------------------------* * 工作区定义 *----------------------------------------------------------------------* TABLES: sscrfields. DATA: wa_result TYPE ty_result,wa_fcat TYPE slis_fieldcat_alv,wa_layo TYPE slis_layout_alv. *----------------------------------------------------------------------* * 内表定义 *----------------------------------------------------------------------* DATA: it_result TYPE STANDARD TABLE OF ty_result,it_fcat TYPE slis_t_fieldcat_alv.*----------------------------------------------------------------------* * 变量定义 *----------------------------------------------------------------------* DATA: g_save_path TYPE string VALUE 'C:\'. *----------------------------------------------------------------------* * 宏定义 *----------------------------------------------------------------------* DEFINE macro_add_fieldcat.CLEAR: wa_fcat.wa_fcat-fieldname = &1.wa_fcat-reptext_ddic = &2.wa_fcat-seltext_l = &2.wa_fcat-seltext_m = &2.wa_fcat-seltext_s = &2.wa_fcat-ref_tabname = &3.wa_fcat-ref_fieldname = &4.APPEND wa_fcat TO it_fcat. END-OF-DEFINITION. *----------------------------------------------------------------------* * 选择屏幕 *----------------------------------------------------------------------* SELECTION-SCREEN: BEGIN OF BLOCK b0 WITH FRAME TITLE tit. SELECTION-SCREEN: FUNCTION KEY 1. PARAMETERS: p_file TYPE rlgrap-filename MEMORY ID fi02. *selection-screen skip. *parameters: p_skip type as4flag as checkbox default abap_true. SELECTION-SCREEN: END OF BLOCK b0. *----------------------------------------------------------------------* * INITIALIZATION *----------------------------------------------------------------------* INITIALIZATION.tit = '选择条件'.sscrfields-functxt_01 = '下载模板'.*----------------------------------------------------------------------* * AT SELECTION-SCREEN *----------------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.PERFORM frm_f4_filename CHANGING p_file. *----------------------------------------------------------------------* * AT SELECTION-SCREEN *----------------------------------------------------------------------* AT SELECTION-SCREEN.CASE sscrfields-ucomm.WHEN 'FC01'. "下载模板PERFORM frm_download_template.WHEN 'ONLI'. "执行ENDCASE. *----------------------------------------------------------------------* * START-OF-SELECTION *----------------------------------------------------------------------* START-OF-SELECTION. *&---检查文件格式PERFORM frm_check_filename.PERFORM frm_upload_file USING p_file. "上传文件*----------------------------------------------------------------------* * end-of-selection *----------------------------------------------------------------------* END-OF-SELECTION.PERFORM frm_display_result. "显示文件内容 *&---------------------------------------------------------------------* *& form frm_download_template *&---------------------------------------------------------------------* * 模板下载 *----------------------------------------------------------------------* FORM frm_download_template.DATA: lw_key TYPE wwwdatatab,l_down TYPE rlgrap-filename,l_name TYPE rlgrap-filename,l_path TYPE rlgrap-filename,l_path_s TYPE string,l_name_s TYPE string,l_path_f TYPE string,l_action TYPE i.CLEAR: lw_key.lw_key-relid = 'MI'.lw_key-objid = sy-repid.CALL METHOD cl_gui_frontend_services=>file_save_dialogEXPORTINGwindow_title = '选择位置'default_extension = 'xlsx'default_file_name = '固定资产期初导入模板'file_filter = 'Excel Files(2007/2010/2013)|*.xlsx|Excel Files(2003)|*.xls'initial_directory = g_save_pathCHANGINGfilename = l_name_spath = l_path_sfullpath = l_path_fuser_action = l_actionEXCEPTIONScntl_error = 1error_no_gui = 2not_supported_by_gui = 3invalid_default_file_name = 4OTHERS = 5.IF sy-subrc <> 0.MESSAGE ID sy-msgidTYPE sy-msgtyNUMBER sy-msgnoWITH sy-msgv1 sy-msgv2sy-msgv3 sy-msgv4.RETURN.ELSE.g_save_path = l_path_s.IF l_action EQ cl_gui_frontend_services=>action_cancel.MESSAGE s398(00) WITH '用户取消操作'.RETURN.ENDIF.ENDIF.l_down = l_path_f.CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'EXPORTINGkey = lw_keydestination = l_down.CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'EXPORTINGfull_name = l_downIMPORTINGstripped_name = l_namefile_path = l_path.CALL FUNCTION 'GUI_RUN'EXPORTINGcommand = 'EXCEL'parameter = l_namecd = l_path. ENDFORM. " FRM_DOWNLOAD_TEMPLATE *&---------------------------------------------------------------------* *& form frm_f4_filename *&---------------------------------------------------------------------* * 文件搜索 *----------------------------------------------------------------------* * <-- fc_path 文件路径 *----------------------------------------------------------------------* FORM frm_f4_filename CHANGING fc_path.DATA: l_path TYPE rlgrap-filename.CALL FUNCTION 'KD_GET_FILENAME_ON_F4'EXPORTINGstatic = abap_truemask = 'Excel Files(2007/2010/2013)|*.xlsx|Excel Files(2003)|*.xls'CHANGINGfile_name = l_path.fc_path = l_path. ENDFORM. " FRM_F4_FILENAME *&---------------------------------------------------------------------* *& form frm_upload_file *&---------------------------------------------------------------------* * 上传文件 *----------------------------------------------------------------------* * -->fu_file 文件名称 *----------------------------------------------------------------------* FORM frm_upload_file USING fu_file.DATA: * lt_return TYPE bapiret2_t, * ls_return TYPE LINE OF bapiret2_t,l_string TYPE string,ls_path TYPE rlgrap-filename.FIELD-SYMBOLS: <fs>.DATA:l_filename TYPE rlgrap-filename,l_endrow TYPE i.DATA:itab TYPE TABLE OF zalsmex_tabline WITH HEADER LINE.CLEAR: it_result.IF p_file IS INITIAL .MESSAGE '文件路径不存在' TYPE 'E'.ENDIF.* ls_path = p_file.l_filename = fu_file.l_endrow = 900000.CALL FUNCTION 'ZALSM_EXCEL_TO_INTERNAL_TABLE'EXPORTINGfilename = l_filenamei_begin_col = 1i_begin_row = 2i_end_col = 29i_end_row = l_endrowTABLESintern = itabEXCEPTIONSinconsistent_parameters = 1upload_ole = 2OTHERS = 3.IF sy-subrc <> 0.ENDIF.IF itab[] IS NOT INITIAL.LOOP AT itab.ON CHANGE OF itab-row.IF sy-tabix NE 1.APPEND wa_result TO it_result.CLEAR wa_result.ENDIF.ENDON.ASSIGN COMPONENT itab-col OF STRUCTURE wa_result TO <fs>.<fs> = itab-value.ENDLOOP.APPEND wa_result TO it_result.CLEAR wa_result.ENDIF.* DATA: lw_file TYPE ty_file, * lt_file TYPE STANDARD TABLE OF ty_file, * lt_return TYPE bapiret2_t, * ls_return TYPE LINE OF bapiret2_t. * DATA l_string TYPE string. * CALL FUNCTION 'Z_UPLOAD_FILE' * EXPORTING * i_filename = fu_file * i_skip = abap_true * TABLES * t_data = lt_file * t_return = lt_return. * * READ TABLE lt_return WITH KEY type = 'E' TRANSPORTING NO FIELDS. * IF sy-subrc EQ 0. * * LOOP AT lt_return INTO ls_return WHERE type = 'E'. * * CONCATENATE l_string ls_return-message INTO l_string SEPARATED BY space. * * ENDLOOP. * * MESSAGE l_string TYPE 'I' . * LEAVE LIST-PROCESSING. * * ENDIF. * * LOOP AT lt_file INTO lw_file. * MOVE-CORRESPONDING lw_file TO wa_result. * APPEND wa_result TO it_result. * ENDLOOP.ENDFORM. " FRM_UPLOAD_FILE *&---------------------------------------------------------------------* *& form frm_display_result *&---------------------------------------------------------------------* * 显示结果 *----------------------------------------------------------------------* FORM frm_display_result .PERFORM frm_build_layout.PERFORM frm_build_fieldcat.CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTINGi_callback_program = sy-repidi_callback_pf_status_set = 'FRM_STATUS_SET'i_callback_user_command = 'FRM_USER_COMMAND'is_layout = wa_layoit_fieldcat = it_fcati_save = 'A'TABLESt_outtab = it_resultEXCEPTIONSprogram_error = 1.IF sy-subrc NE 0.ENDIF. ENDFORM. " FRM_DISPLAY_RESULT *&---------------------------------------------------------------------* *& form frm_build_layout *&---------------------------------------------------------------------* * 创建显示布局 *----------------------------------------------------------------------* FORM frm_build_layout .wa_layo-box_fieldname = 'MARK'.wa_layo-zebra = abap_true.wa_layo-colwidth_optimize = abap_true. ENDFORM. " FRM_BUILD_LAYOUT *&---------------------------------------------------------------------* *& form frm_build_fieldcat *&---------------------------------------------------------------------* * 创建显示字段 *----------------------------------------------------------------------* FORM frm_build_fieldcat .macro_add_fieldcat:'ICON' '信号灯' 'ICON' 'ID','MESSAGE' '消息内容' space space, "消息内容'ANLN1' '主资产号' 'ANLA' 'ANLN1', "主资产号'ANLN2' '资产次级编号' 'ANLA' 'ANLN2', "资产次级编号'BUKRS' '公司代码' 'ANLA' 'BUKRS', "公司代码'ZANLN' '资产编号' 'ANLA' 'ANLN1', "资产编号'ANLKL' '资产分类' 'ANLA' 'ANLKL', "资产分类'TXT50' '资产描述' 'ANLA' 'TXT50', "资产描述'TXA50' '附加资产描述' 'ANLA' 'TXA50', "附加资产描述'SERNR' '序列号' 'ANLA' 'SERNR', "序列号'INVNR' '存货号 旧资产编号' 'ANLA' 'INVNR', "存货号'QUANTITY' '数量' '' '', "数量'BASE_UOM' '单位' '' '', "数量'INVZU' '库存备注' 'ANLA' 'INVZU', "库存备注'AKTIV' '资产资本化日期' 'ANLA' 'AKTIV', "资产资本化日期'KOSTL' '成本中心' 'ANLZ' 'KOSTL', "成本中心'KOSTLV' '责任成本中心' 'ANLZ' 'KOSTLV', "责任成本中心'CAUFN' '内部订单' 'ANLZ' 'CAUFN', "内部订单'ORD41' '变动方式' 'ANLA' 'ORD41', "变动方式'ORD42' '使用状态' 'ANLA' 'ORD42', "使用状态'ORD43' '经济用途' 'ANLA' 'ORD43', "经济用途'LIFNR' '供应商' 'ANLA' 'LIFNR', "供应商'LIEFE' '供应商描述' 'ANLA' 'LIEFE',"供应商描述'HERST' '制造商' 'ANLA' 'HERST', "制造商'AFASL' '折旧码' 'ANLB' 'AFASL', " 折旧码'NDJAR' '计划折旧年' 'ANLC' 'KANSW','NDPER' '计划折旧' 'ANLC' 'KNAFA','SAFBG' '折旧开始日期' 'ANLB' 'SAFBG','KANSW' '购置价值' 'ANLC' 'KANSW', "购置价值'KNAFA' '正常折旧' 'ANLC' 'KNAFA', "以前年度折旧'NAFAG' '已记正常折旧' 'ANLC' 'NAFAG', "当期年度折旧'SCHRW' '残值' 'ANLC' 'NAFAG'. " 残值ENDFORM. " FRM_BUILD_FIELDCAT *&---------------------------------------------------------------------* *& form frm_status_set *&---------------------------------------------------------------------* * gui状态设置 *----------------------------------------------------------------------* * --> fu_extab 排除的按钮 *----------------------------------------------------------------------* FORM frm_status_set USING fu_extab TYPE slis_t_extab.SET PF-STATUS 'STANDARD' EXCLUDING fu_extab. ENDFORM. " FRM_STATUS_SET*&---------------------------------------------------------------------* *& form frm_user_command *&---------------------------------------------------------------------* * 用户按键响应 *----------------------------------------------------------------------* * --> fu_ucomm 用户按键名 * --> FU_SELFIELD 选择的字段 *----------------------------------------------------------------------* FORM frm_user_command USING p_ucomm TYPE sy-ucommp_selfield TYPE slis_selfield.DATA: lo_grid TYPE REF TO cl_gui_alv_grid.CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'IMPORTINGe_grid = lo_grid.CALL METHOD lo_grid->check_changed_data.p_selfield-refresh = abap_true.p_selfield-col_stable = abap_true.p_selfield-row_stable = abap_true.CASE p_ucomm.WHEN '&IC1'.IF p_selfield-fieldname EQ 'MESSAGE'.READ TABLE it_result INTO wa_result INDEX p_selfield-tabindex.IF sy-subrc EQ 0.IF wa_result-return IS NOT INITIAL.ELSE.MESSAGE s001(00) WITH '无可用明细信息'.ENDIF.ENDIF.ENDIF.WHEN 'TESTRUN'.PERFORM frm_create_asset USING abap_true.WHEN '&RUN'.PERFORM frm_create_asset USING abap_false.ENDCASE. ENDFORM. " FRM_USER_COMMAND *&---------------------------------------------------------------------* *& form frm_create_asset *&---------------------------------------------------------------------* * 创建资产 *----------------------------------------------------------------------* * --> fu_test 测试执行 *----------------------------------------------------------------------* FORM frm_create_asset USING fu_test.DATA: l_asset TYPE bapi1022_1-assetmaino,l_subnumber TYPE bapi1022_1-assetsubno,lw_key TYPE bapi1022_key,lw_generaldata TYPE bapi1022_feglg001,lw_generaldatax TYPE bapi1022_feglg001x,lw_postinginformation TYPE bapi1022_feglg002,lw_postinginformationx TYPE bapi1022_feglg002x,lw_timedependentdata TYPE bapi1022_feglg003,lw_timedependentdatax TYPE bapi1022_feglg003x,lw_origin TYPE bapi1022_feglg009,lw_originx TYPE bapi1022_feglg009x,lw_allocations TYPE bapi1022_feglg004,lw_allocationsx TYPE bapi1022_feglg004x,lw_inventory TYPE bapi1022_feglg011,lw_inventoryx TYPE bapi1022_feglg011x,lw_cumulatedvalue TYPE bapi1022_cumval,lw_postedvalue TYPE bapi1022_postval,lw_transaction TYPE bapi1022_trtype,lw_depreciationareas TYPE bapi1022_dep_areas, "折旧范围数据lw_depreciationareasx TYPE bapi1022_dep_areasx,lt_depreciationareas TYPE STANDARD TABLE OF bapi1022_dep_areas,lt_depreciationareasx TYPE STANDARD TABLE OF bapi1022_dep_areasx,lt_cumulatedvalues TYPE STANDARD TABLE OF bapi1022_cumval,lt_postedvalues TYPE STANDARD TABLE OF bapi1022_postval,lt_transactions TYPE STANDARD TABLE OF bapi1022_trtype.DATA : l_meins TYPE meins.FIELD-SYMBOLS: <fs_result> TYPE ty_result.LOOP AT it_result ASSIGNING <fs_result> WHERE mark EQ abap_true.CHECK <fs_result>-anln1 IS INITIAL.CLEAR: l_asset,l_subnumber,lw_key,lw_generaldata,lw_generaldatax,lw_postinginformation,lw_postinginformationx,lw_timedependentdata,lw_timedependentdatax,lt_cumulatedvalues,lt_postedvalues,lt_transactions,lt_depreciationareas,lt_depreciationareasx,<fs_result>-return,<fs_result>-anln1.CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'EXPORTINGinput = <fs_result>-anlklIMPORTINGoutput = <fs_result>-anlkl.CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'EXPORTINGinput = <fs_result>-sernrIMPORTINGoutput = <fs_result>-sernr.lw_key-companycode = <fs_result>-bukrs. "公司代码lw_key-asset = |{ <fs_result>-zanln ALPHA = IN }|. "资产编号lw_key-subnumber = |{ <fs_result>-anln2 ALPHA = IN }|. "子编号lw_generaldata-assetclass = <fs_result>-anlkl. "资产分类lw_generaldata-descript = <fs_result>-txt50. "资产描述lw_generaldata-descript2 = <fs_result>-txa50. "附加资产描述lw_generaldata-serial_no = <fs_result>-sernr. "序列号lw_generaldata-invent_no = <fs_result>-invnr. "存货号lw_generaldata-quantity = <fs_result>-quantity."数量CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'EXPORTINGinput = <fs_result>-base_uomlanguage = sy-languIMPORTINGoutput = lw_generaldata-base_uomEXCEPTIONSunit_not_found = 1OTHERS = 2.IF sy-subrc <> 0. * Implement suitable error handling hereENDIF.lw_generaldatax-assetclass = abap_true.lw_generaldatax-descript = abap_true.lw_generaldatax-descript2 = abap_true.lw_generaldatax-main_descript = abap_true.lw_generaldatax-serial_no = abap_true.lw_generaldatax-invent_no = abap_true.lw_generaldatax-quantity = abap_true. "数量lw_generaldatax-base_uom = abap_true. "单位lw_postinginformation-cap_date = <fs_result>-aktiv."资产资本化日期lw_postinginformationx-cap_date = abap_true.lw_inventory-note = <fs_result>-invzu. "库存备注lw_inventoryx-note = abap_true.lw_timedependentdata-costcenter = <fs_result>-kostl. "成本中心lw_timedependentdata-intern_ord = <fs_result>-caufn. "内部订单lw_timedependentdata-resp_cctr = <fs_result>-kostlv. "责任成本中心lw_timedependentdatax-costcenter = abap_true. "成本中心lw_timedependentdatax-intern_ord = abap_true. "内部订单lw_timedependentdatax-resp_cctr = abap_true. "责任成本中心lw_depreciationareas-area = '01'.lw_depreciationareas-ulife_yrs = <fs_result>-ndjar ."计划使用年lw_depreciationareas-ulife_prds = <fs_result>-ndper ."计划使用月lw_depreciationareas-scrapvalue = <fs_result>-schrw ."残值lw_depreciationareas-dep_key = <fs_result>-afasl ."折旧码lw_depreciationareas-sdep_start_date = <fs_result>-safbg. "折旧开始日期lw_depreciationareasx-area = '01' .IF <fs_result>-ndjar <> 0 OR <fs_result>-ndper <> 0 .lw_depreciationareasx-ulife_yrs = abap_true .lw_depreciationareasx-ulife_prds = abap_true .ENDIF.IF <fs_result>-schrw <> 0 .lw_depreciationareasx-scrapvalue = abap_true .ENDIF.lw_depreciationareasx-dep_key = abap_true.APPEND lw_depreciationareas TO lt_depreciationareas.APPEND lw_depreciationareasx TO lt_depreciationareasx.IF <fs_result>-aktiv(4) LT sy-datum(4). "以住年份的数据CLEAR: lw_cumulatedvalue.lw_cumulatedvalue-fisc_year = '2019'. "年份lw_cumulatedvalue-area = '01'. "折旧范围lw_cumulatedvalue-acq_value = <fs_result>-kansw. "购置价值lw_cumulatedvalue-ord_dep = <fs_result>-knafa * -1."以前年度折旧lw_cumulatedvalue-currency = 'CNY'.APPEND lw_cumulatedvalue TO lt_cumulatedvalues.ELSE. "当年的数据CLEAR: lw_transaction.lw_transaction-fisc_year = '2019'. "年份lw_transaction-area = '01'.lw_transaction-current_no = '1'.lw_transaction-valuedate = <fs_result>-aktiv.lw_transaction-assettrtyp = '100'. "资产交易类型lw_transaction-amount = <fs_result>-kansw.lw_transaction-currency = 'CNY'.APPEND lw_transaction TO lt_transactions.ENDIF.IF <fs_result>-nafag IS NOT INITIAL.CLEAR: lw_postedvalue.lw_postedvalue-fisc_year = '2019'. "年份lw_postedvalue-area = '01'.lw_postedvalue-ord_dep = <fs_result>-nafag * -1."当期年度折旧lw_postedvalue-currency = 'CNY'.APPEND lw_postedvalue TO lt_postedvalues.ENDIF.lw_origin-vendor_no = |{ <fs_result>-lifnr ALPHA = IN }|. " 供应商lw_origin-vendor = <fs_result>-liefe.lw_origin-manufacturer = <fs_result>-herst."制造商lw_originx-vendor_no = abap_true.lw_originx-vendor = abap_true.lw_originx-manufacturer = abap_true.lw_allocations-evalgroup1 = <fs_result>-ord41." 变动方式lw_allocations-evalgroup2 = <fs_result>-ord42." 使用状态lw_allocations-evalgroup3 = <fs_result>-ord43." 经济用途lw_allocationsx-evalgroup1 = abap_true.lw_allocationsx-evalgroup2 = abap_true.lw_allocationsx-evalgroup3 = abap_true.CALL FUNCTION 'BAPI_FIXEDASSET_OVRTAKE_CREATE'EXPORTINGkey = lw_keytestrun = fu_testgeneraldata = lw_generaldatageneraldatax = lw_generaldataxpostinginformation = lw_postinginformationpostinginformationx = lw_postinginformationxtimedependentdata = lw_timedependentdatatimedependentdatax = lw_timedependentdataxorigin = lw_originoriginx = lw_originxallocations = lw_allocationsallocationsx = lw_allocationsxinventory = lw_inventoryinventoryx = lw_inventoryxIMPORTINGasset = l_assetsubnumber = l_subnumberTABLESdepreciationareas = lt_depreciationareasdepreciationareasx = lt_depreciationareasxcumulatedvalues = lt_cumulatedvaluespostedvalues = lt_postedvaluestransactions = lt_transactionsreturn = <fs_result>-return.<fs_result>-anln1 = l_asset.<fs_result>-anln2 = l_subnumber.READ TABLE <fs_result>-return WITH KEY type = 'E' TRANSPORTING NO FIELDS.IF sy-subrc NE 0.READ TABLE <fs_result>-return WITH KEY type = 'W' TRANSPORTING NO FIELDS.IF sy-subrc EQ 0.<fs_result>-icon = icon_led_yellow.ELSE.<fs_result>-icon = icon_led_green.ENDIF.<fs_result>-message = '资产创建成功'.IF fu_test IS INITIAL.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGwait = abap_true.ENDIF.ELSE.<fs_result>-icon = icon_led_red. * <fs_result>-message = '资产创建失败,双击查看明细'. * <fs_result>-message = '资产创建失败,双击查看明细'.LOOP AT <fs_result>-return INTO ls_return.CONCATENATE <fs_result>-message ls_return-id ls_return-number ls_return-messageINTO <fs_result>-message SEPARATED BY space.ENDLOOP.IF fu_test IS INITIAL.CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.ENDIF.ENDIF.ENDLOOP.IF sy-subrc NE 0.MESSAGE s001(00) WITH '请选择行进行操作'.ENDIF.ENDFORM. " FRM_CREATE_ASSET *&---------------------------------------------------------------------* *& Form FRM_CHECK_FILENAME *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_check_filename .DATA: lv_s1 TYPE string,lv_s2 TYPE string.SPLIT p_file AT '.' INTO lv_s1 lv_s2.TRANSLATE lv_s2 TO UPPER CASE.IF p_file IS INITIAL.MESSAGE '请输入数据路径!' TYPE 'S' DISPLAY LIKE 'W'.LEAVE LIST-PROCESSING.ENDIF. ENDFORM.