ABAP 批导创建银行代码
【摘要】 通过批导创建银行代码主要是通过 BAPI_BANK_CREATE 这个 BAPI 调用来实现相同的操作。CALL FUNCTION 'BAPI_BANK_CREATE' EXPORTING bank_ctry = gs_excel-banks bank_key = gs_excel-bankl bank_address = ...
通过批导创建银行代码
主要是通过 BAPI_BANK_CREATE
这个 BAPI 调用来实现相同的操作。
CALL FUNCTION 'BAPI_BANK_CREATE'
EXPORTING
bank_ctry = gs_excel-banks
bank_key = gs_excel-bankl
bank_address = lt_bank_address
* BANK_METHOD =
* BANK_FORMATTING =
* BANK_ADDRESS1 =
* I_XUPDATE = 'X'
* I_CHECK_BEFORE_SAVE =
* BANK_IBAN_RULE =
* BANK_B2B_SUPPORTED =
* BANK_COR1_SUPPORTED =
* BANK_R_TRANSACTION_SUPPORTED =
IMPORTING
return = lt_return
* BANKCOUNTRY =
bankkey = l_bankkey.
前台界面提供了 Excel 模版下载,实现了银行信息导入和查询的两个功能,如下:
查询 ALV 的显示结果如图:
完整的代码如下:
REPORT zfiu063.
TABLES: bnka, sscrfields.
TYPE-POOLS: icon.
"可变表
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data.
FIELD-SYMBOLS: <fs_out_tab> TYPE STANDARD TABLE,
<fs_out>.
DATA: gs_layo TYPE lvc_s_layo,
gt_fcat TYPE lvc_t_fcat,
gs_fcat TYPE lvc_s_fcat.
DATA: gs_stbl TYPE lvc_s_stbl.
" FI01 事务码的前端创建银行初始界面
DATA: BEGIN OF gs_excel,
sel TYPE c,
banks TYPE bnka-banks, " 银行国家
bankl TYPE bnka-bankl, " 银行代码
banka TYPE bnka-banka, " 银行名称
ort01 TYPE bnka-ort01, " 城市
bnklz TYPE bnka-bnklz, " 银行编号
swift TYPE bnka-swift, " SWIFT/BIC
brnch TYPE bnka-brnch, " 分行
stras TYPE bnka-stras, " 街道/住宅
erdat TYPE bnka-erdat, " 创建日期
msg(128) TYPE c,
icon(10) TYPE c,
END OF gs_excel.
DATA: gt_excel LIKE STANDARD TABLE OF gs_excel.
DATA: gs_zbnka LIKE zbnka_history,
gt_zbnka LIKE STANDARD TABLE OF gs_zbnka.
DATA: BEGIN OF gs_out.
INCLUDE TYPE zbnka_history.
DATA: sel TYPE c,
icon(10) TYPE c,
END OF gs_out,
gt_out LIKE STANDARD TABLE OF gs_out.
DATA: is_layout TYPE lvc_s_layo,
gs_fieldcat TYPE lvc_s_fcat,
gt_fieldcat TYPE lvc_t_fcat.
TYPES: BEGIN OF ty_field,
index TYPE int4,
fieldname TYPE fieldname,
tablename TYPE tabname,
fieldtext TYPE char40,
END OF ty_field.
DATA: gt_field TYPE TABLE OF ty_field WITH HEADER LINE,
gt_header TYPE TABLE OF ty_field WITH HEADER LINE.
DATA: lt_bank_address LIKE bapi1011_address OCCURS 0 WITH HEADER LINE,
l_msg_bk(255) TYPE c,
l_bankkey TYPE bnka-bankl,
lt_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE. " 返回参数
DATA: g_function_key TYPE smp_dyntxt. "功能按钮
DATA: zcheck TYPE char1.
*----------------------------------------------------------------------*
* SELECTION-SCREEN *
*----------------------------------------------------------------------*
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN:BEGIN OF SCREEN 9001 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK blk01 WITH FRAME TITLE text001.
PARAMETERS p_file LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK blk01.
SELECTION-SCREEN BEGIN OF BLOCK blk02 WITH FRAME TITLE text002.
SELECTION-SCREEN:
COMMENT /2(75) t1.
SELECTION-SCREEN END OF BLOCK blk02.
SELECTION-SCREEN:END OF SCREEN 9001.
SELECTION-SCREEN:BEGIN OF SCREEN 9002 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text003.
SELECT-OPTIONS:
s_banks FOR bnka-banks, " bank country
* s_bankl FOR bnka-bankl MATCHCODE OBJECT bkk_f4_country_bankkeys. " bank key
s_bankl FOR bnka-bankl MATCHCODE OBJECT zbkk_f4_country_bankkeys, " bank key
s_erdat FOR bnka-erdat.
PARAMETERS s_loevm TYPE bnka-loevm AS CHECKBOX USER-COMMAND isdelete. " isDelete
SELECTION-SCREEN END OF BLOCK b4.
SELECTION-SCREEN:END OF SCREEN 9002.
SELECTION-SCREEN BEGIN OF TABBED BLOCK tabscr FOR 11 LINES.
SELECTION-SCREEN:
TAB (20) button1 USER-COMMAND push1 DEFAULT SCREEN 9001,
TAB (20) button2 USER-COMMAND push2 DEFAULT SCREEN 9002.
SELECTION-SCREEN END OF BLOCK tabscr.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
INITIALIZATION.
IF sy-langu = '1'.
text001 = '文件选择'.
text002 = '程序提示'.
text003 = '选择参数'.
button1 = '导入银行数据'.
button2 = '查询银行数据'.
ELSE.
text001 = 'File Selection'.
text002 = 'Program Notes'.
text003 = 'Select Options'.
button1 = 'Import Bank Info'.
button2 = 'Query Bank Info'.
ENDIF.
* 工具栏添加下载模板按钮
CLEAR g_function_key.
g_function_key-icon_id = icon_read_file.
IF sy-langu = '1'.
g_function_key-icon_text = '银行批量导入模版下载'.
g_function_key-quickinfo = '银行批量导入模版下载'.
ELSE.
g_function_key-icon_text = 'Bank Info Excel Template Download'.
g_function_key-quickinfo = 'Bank Info Excel Template Download'.
ENDIF.
sscrfields-functxt_01 = g_function_key.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN OUTPUT *
*----------------------------------------------------------------------*
*显示注释
AT SELECTION-SCREEN OUTPUT.
IF sy-langu = '1'.
MOVE '1、请选择正确的模板填写数据!' TO t1.
ELSE.
MOVE '1. Please fill in the correct data in the template!' TO t1.
ENDIF.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
* 下载数据导入模板
IF sscrfields-ucomm = 'FC01'.
PERFORM frm_excel_down.
sscrfields-ucomm = ''.
ENDIF.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* 选择文件搜索帮助
PERFORM frm_set_file_f4 USING p_file.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
CASE tabscr-dynnr.
WHEN '9001'.
* 文件必输校验
PERFORM frm_file_obligatory.
* 批量导入数据
PERFORM frm_upload_data.
CLEAR zcheck.
PERFORM frm_check_data CHANGING zcheck.
* alv显示
PERFORM frm_display_data.
WHEN '9002'.
PERFORM frm_get_bank_info.
PERFORM frm_count_data.
PERFORM frm_set_layout.
PERFORM frm_set_fieldcat.
PERFORM frm_show_alv.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form FRM_SET_STATUS
*&---------------------------------------------------------------------*
* 设定状态栏
*----------------------------------------------------------------------*
FORM frm_set_status USING extab TYPE slis_t_extab.
"SET PF-STATUS 'S1000'.
SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.
ENDFORM. " FRM_SET_STATUS
*&---------------------------------------------------------------------*
*& Form FRM_EXCEL_DOWN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_excel_down .
* 相关变量定义
DATA:lo_objdata LIKE wwwdatatab,
lo_mime LIKE w3mime,
lc_filename TYPE string VALUE 'Bank Info Batch Template.xlsx',
lc_fullpath TYPE string VALUE 'D:\',
lc_path TYPE string VALUE 'D:\',
ls_destination LIKE rlgrap-filename,
ls_objnam TYPE string,
l_rc LIKE sy-subrc,
ls_errtxt TYPE string,
l_objid TYPE wwwdatatab-objid,
l_dest LIKE sapb-sappfad.
* 模版上传的对象名
l_objid = 'ZFIU066'.
* 模板下载路径名
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = '模板下载'
default_extension = 'XLSX'
default_file_name = lc_filename
CHANGING
filename = lc_filename
path = lc_path
fullpath = lc_fullpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
invalid_default_file_name = 4
OTHERS = 5.
* 没有选择路径
IF lc_fullpath = ''.
IF sy-langu = '1'.
MESSAGE '请选择正确的路径!' TYPE 'E'.
RETURN.
ELSE.
MESSAGE 'Please select the correct path!' TYPE 'E'.
RETURN.
ENDIF.
ELSE.
*- 路径名
l_dest = lc_fullpath.
SELECT SINGLE
relid "IMPORT/EXPORT 记录中的区域
objid "SAP WWW 网关对象名
FROM wwwdata
INTO CORRESPONDING FIELDS OF lo_objdata
WHERE srtf2 = 0
AND relid = 'MI'
AND objid = l_objid.
IF sy-subrc <> 0 OR lo_objdata-objid IS INITIAL.
IF sy-langu = '1'.
MESSAGE '没有获得模板数据' TYPE 'E'.
ELSE.
MESSAGE 'Cannot open exel' TYPE 'E'.
ENDIF.
ENDIF.
ls_destination = l_dest.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
key = lo_objdata
destination = ls_destination
IMPORTING
rc = l_rc.
IF l_rc <> 0.
IF sy-langu = '1'.
MESSAGE '模板下载失败' TYPE 'E'.
ELSE.
MESSAGE 'Template download failed' TYPE 'E'.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_FILE_F4
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM frm_set_file_f4 USING p_file TYPE rlgrap-filename.
** 局部变量-文件名定义
* DATA l_filename TYPE rlgrap-filename.
* CLEAR l_filename.
** 选择文件搜索帮助
* CALL FUNCTION 'WS_FILENAME_GET'
* EXPORTING
* def_path = i_file
* mask = ',*.xlsx,*.XLSX,*.xls,*.XLS.'
* mode = '0'
* title = TEXT-002
* IMPORTING
* filename = l_filename
* EXCEPTIONS
* inv_winsys = 1
* no_batch = 2
* selection_cancel = 3
* selection_error = 4
* OTHERS = 5.
** 如果选择了文件
* IF sy-subrc = 0 AND l_filename IS NOT INITIAL.
* p_file = l_filename.
* ENDIF.
CALL FUNCTION 'F4_FILENAME' "取得文件路径
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_FILE_OBLIGATORY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_file_obligatory .
* 文件必输校验
IF p_file IS INITIAL.
IF sy-langu EQ '1'.
MESSAGE '请选择导入的文件' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
MESSAGE 'Please select the file to be imported' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_upload_data .
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 0
text = 'Loading data, please wait......'.
" 参照类型有标准的调整为ZALSMEX_TABLINE_LINE。
DATA: lt_excel TYPE TABLE OF zalsmex_tabline WITH HEADER LINE.
DATA: ls_excel TYPE zalsmex_tabline.
CLEAR gt_excel.
" 选择文件后做后续处理
CHECK p_file IS NOT INITIAL.
" 把文件的数据变成内表
CALL FUNCTION 'Z_ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 1
i_end_col = 200
i_end_row = 65536
TABLES
intern = lt_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
DATA: lv_count TYPE int4.
FIELD-SYMBOLS: <fs_v> TYPE any.
LOOP AT lt_excel.
lv_count = lt_excel-col.
IF lt_excel-row = 1.
"第一行为字段描述行
CLEAR: gt_header.
gt_header-index = lv_count.
gt_header-fieldtext = lt_excel-value.
APPEND gt_header.
ELSEIF lt_excel-row = 2.
"第2行为字段名行,根据字段名确认每行数据每列字段对应位置
CLEAR: gt_field.
gt_field-index = lv_count.
gt_field-fieldname = to_upper( lt_excel-value ).
READ TABLE gt_header WITH KEY index = lv_count.
IF sy-subrc EQ 0.
gt_field-fieldtext = gt_header-fieldtext.
ENDIF.
APPEND gt_field.
ELSE.
"数据行
READ TABLE gt_field WITH KEY index = lt_excel-col.
IF sy-subrc EQ 0.
UNASSIGN <fs_v>.
ASSIGN COMPONENT gt_field-fieldname OF STRUCTURE <fs_out> TO <fs_v>.
IF sy-subrc EQ 0.
<fs_v> = lt_excel-value.
ENDIF.
ENDIF.
ENDIF.
AT END OF row.
IF lt_excel-row = 2.
"根据第2行字段名称行,构建OUT结构
PERFORM frm_set_out_struct.
ELSEIF lt_excel-row > 2.
APPEND <fs_out> TO <fs_out_tab>.
CLEAR: <fs_out>.
ENDIF.
CLEAR: lv_count.
ENDAT.
ENDLOOP.
DELETE gt_field WHERE fieldname = '' OR fieldname IS INITIAL.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_display_data .
PERFORM frm_set_layo.
PERFORM frm_alv_display.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_USER_COMMAND
*&---------------------------------------------------------------------*
* 命令按钮
*----------------------------------------------------------------------*
* -->I_UCOMM 命令按钮
* -->I_SELFIELD 选择值
*----------------------------------------------------------------------*
FORM frm_user_command USING i_ucomm LIKE sy-ucomm
i_selfield TYPE slis_selfield.
i_selfield-refresh = 'X'.
CASE i_ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'IMPORT'.
PERFORM frm_data_import. " 银行批量创建
WHEN 'HISTORY'.
PERFORM frm_bnka_history.
PERFORM frm_count_data.
PERFORM frm_set_layout.
PERFORM frm_set_fieldcat.
PERFORM frm_show_alv.
WHEN OTHERS.
ENDCASE.
ENDFORM. " FRM_USER_COMMAND
*&---------------------------------------------------------------------*
*& Form FRM_DATA_IMPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_data_import .
IF zcheck = 'E'.
MESSAGE 'Data is Incorrect,Please Check First!' TYPE 'E' DISPLAY LIKE 'E'.
ENDIF.
CHECK zcheck <> 'E'.
DATA: lv_answer TYPE c,
lv_msg TYPE string,
lv_bankl TYPE bnka-bankl.
DATA: c_str TYPE string.
DATA: ls_bnka LIKE bnka,
lt_bnka LIKE STANDARD TABLE OF ls_bnka.
CALL METHOD cl_gui_frontend_services=>get_user_name
CHANGING
user_name = c_str
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2.
DATA: opcode_usr_attr(1) TYPE x VALUE 5,
terminal TYPE usr41-terminal.
CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_usr_attr
ID'TERMINAL' FIELD terminal.
IF <fs_out_tab>[] IS ASSIGNED.
REFRESH gt_excel[].
CLEAR gs_excel.
UNASSIGN <fs_out>.
LOOP AT <fs_out_tab>[] ASSIGNING <fs_out>.
MOVE-CORRESPONDING <fs_out> TO gs_excel.
APPEND gs_excel TO gt_excel.
ENDLOOP.
ENDIF.
READ TABLE gt_excel INTO gs_excel WITH KEY sel = 'X'.
IF sy-subrc NE 0.
IF sy-langu = '1'.
MESSAGE '请选择保存的数据!' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
MESSAGE 'Please Choose data first!' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
RETURN.
ENDIF.
CLEAR: gs_excel, lv_answer, lv_bankl, gs_zbnka.
LOOP AT gt_excel INTO gs_excel WHERE sel = 'X' AND banks IS NOT INITIAL.
IF gs_excel-banks EQ 'UK'.
gs_excel-banks = 'GB'.
ENDIF.
IF gs_excel-swift IS NOT INITIAL.
TRANSLATE gs_excel-swift TO UPPER CASE.
SELECT SINGLE bankl FROM bnka INTO lv_bankl WHERE banks = gs_excel-banks
AND swift = gs_excel-swift
AND banka = gs_excel-banka
AND loevm <> 'X'.
IF lv_bankl IS NOT INITIAL.
IF sy-langu = '1'.
lv_msg = 'Swift编号: ' && gs_excel-swift && '已有银行信息,确定新建吗?'.
ELSE.
lv_msg = 'Swift: ' && gs_excel-swift && 'is already exist, Create New One?'.
ENDIF.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
* TITLEBAR = ' '
* DIAGNOSE_OBJECT = ' '
text_question = lv_msg
text_button_1 = '新建'(001)
icon_button_1 = 'ICON_CREATE'
text_button_2 = '修改'(002)
icon_button_2 = 'ICON_CHANGE'
* DEFAULT_BUTTON = '1'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = lv_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
ENDIF.
CASE lv_answer.
WHEN 'A'.
RETURN.
CLEAR gs_excel.
WHEN '1'.
CALL FUNCTION 'ZAUTO_CREATE_BANK_KEY'
EXPORTING
bank_ctry = gs_excel-banks
* bank_name = gs_excel-banka
* bank_swift = gs_excel-swift
IMPORTING
bank_key = gs_excel-bankl.
gs_excel-msg = 'Swfit Dupplicated'.
* gs_zbnka-erdat = sy-datum.
WHEN '2'.
CALL FUNCTION 'ZAUTO_CREATE_BANK_KEY'
EXPORTING
bank_ctry = gs_excel-banks
bank_name = gs_excel-banka
bank_swift = gs_excel-swift
IMPORTING
bank_key = gs_excel-bankl.
SELECT SINGLE banks bankl banka ort01 swift brnch stras
FROM bnka INTO CORRESPONDING FIELDS OF ls_bnka
WHERE banks = gs_excel-banks
AND bankl = gs_excel-bankl.
IF gs_excel-banks = ls_bnka-banks AND
gs_excel-bankl = ls_bnka-bankl AND
gs_excel-banka = ls_bnka-banka AND
gs_excel-ort01 = ls_bnka-ort01 AND
gs_excel-swift = ls_bnka-swift AND
gs_excel-brnch = ls_bnka-brnch AND
gs_excel-stras = ls_bnka-stras.
gs_excel-msg = 'The bank info is consistent, cannot be modify!'.
MESSAGE gs_excel-msg TYPE 'E' DISPLAY LIKE 'I'.
RETURN.
ELSE.
gs_excel-msg = 'New'.
ENDIF.
WHEN OTHERS.
CALL FUNCTION 'ZAUTO_CREATE_BANK_KEY'
EXPORTING
bank_ctry = gs_excel-banks
bank_name = gs_excel-banka
bank_swift = gs_excel-swift
IMPORTING
bank_key = gs_excel-bankl.
gs_excel-msg = 'New'.
* gs_zbnka-erdat = sy-datum.
ENDCASE.
ENDIF.
lt_bank_address-bank_name = gs_excel-banka.
* lt_bank_address-region = i_banka.
lt_bank_address-street = gs_excel-stras.
lt_bank_address-city = gs_excel-ort01.
lt_bank_address-swift_code = gs_excel-swift.
lt_bank_address-bank_no = gs_excel-bnklz.
lt_bank_address-bank_branch = gs_excel-brnch.
APPEND lt_bank_address.
CLEAR: lt_return,lt_return[],l_bankkey.
CALL FUNCTION 'BAPI_BANK_CREATE'
EXPORTING
bank_ctry = gs_excel-banks
bank_key = gs_excel-bankl
bank_address = lt_bank_address
* BANK_METHOD =
* BANK_FORMATTING =
* BANK_ADDRESS1 =
* I_XUPDATE = 'X'
* I_CHECK_BEFORE_SAVE =
* BANK_IBAN_RULE =
* BANK_B2B_SUPPORTED =
* BANK_COR1_SUPPORTED =
* BANK_R_TRANSACTION_SUPPORTED =
IMPORTING
return = lt_return
* BANKCOUNTRY =
bankkey = l_bankkey.
CLEAR l_msg_bk. "20160721新增
LOOP AT lt_return WHERE type = 'E' OR type = 'A'. " OR TYPE = 'W'.
CONCATENATE lt_return-message l_msg_bk INTO l_msg_bk SEPARATED BY ';'.
CONDENSE l_msg_bk.
ENDLOOP.
IF l_msg_bk = '' OR l_msg_bk IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "commit--信息提交
EXPORTING
wait = 'X'. "银行创建提交
gs_excel-icon = icon_okay.
gs_excel-erdat = sy-datum.
IF sy-subrc EQ 0.
MESSAGE 'Save Success!' TYPE 'S'.
ENDIF.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
gs_excel-msg = l_msg_bk.
gs_excel-icon = icon_cancel.
gs_excel-erdat = sy-datum.
IF sy-subrc EQ 0.
MESSAGE 'Save Failure!' TYPE 'E'.
ENDIF.
ENDIF.
MOVE-CORRESPONDING gs_excel TO gs_zbnka.
gs_zbnka-bname = c_str.
gs_zbnka-terminal = terminal.
gs_zbnka-crdat = sy-datum. " 保存日期
gs_zbnka-erzet = sy-uzeit. " 保存时间
gs_zbnka-ernam = sy-uname.
APPEND gs_zbnka TO gt_zbnka.
MODIFY gt_excel FROM gs_excel.
CLEAR gs_excel.
ENDLOOP.
DATA: lv_tabix TYPE sy-tabix.
CLEAR lv_tabix.
CLEAR gs_excel.
LOOP AT <fs_out_tab>[] ASSIGNING <fs_out>.
lv_tabix = sy-tabix.
READ TABLE gt_excel INTO gs_excel INDEX lv_tabix.
IF sy-subrc = 0.
MOVE-CORRESPONDING gs_excel TO <fs_out>.
ENDIF.
ENDLOOP.
IF gt_zbnka IS NOT INITIAL.
MODIFY zbnka_history FROM TABLE gt_zbnka.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_OUT_STRUCT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_set_out_struct .
" 添加SEL字段
CLEAR: gs_fcat.
gs_fcat-fieldname = 'SEL'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 1.
APPEND gs_fcat TO gt_fcat.
" 添加ICON字段
CLEAR: gs_fcat.
gs_fcat-fieldname = 'ICON'.
gs_fcat-coltext = 'Msg Light'.
gs_fcat-icon = 'X'.
gs_fcat-domname = 'CHAR10'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 10.
APPEND gs_fcat TO gt_fcat.
" 添加TYPE字段
CLEAR: gs_fcat.
gs_fcat-fieldname = 'TYPE'.
gs_fcat-coltext = ''.
gs_fcat-domname = 'CHAR01'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 1.
APPEND gs_fcat TO gt_fcat.
" 添加Bank Country
CLEAR: gs_fcat.
gs_fcat-fieldname = 'BANKS'.
gs_fcat-coltext = 'Bank Country'.
gs_fcat-domname = 'LAND1'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 3.
APPEND gs_fcat TO gt_fcat.
" 添加Bank Key
CLEAR: gs_fcat.
gs_fcat-fieldname = 'BANKL'.
gs_fcat-coltext = 'Bank Key'.
gs_fcat-domname = 'BANKK'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 10.
APPEND gs_fcat TO gt_fcat.
" 添加 Bank Name
CLEAR: gs_fcat.
gs_fcat-fieldname = 'BANKA'.
gs_fcat-coltext = 'Bank Name'.
gs_fcat-domname = 'TEXT60'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 60.
APPEND gs_fcat TO gt_fcat.
" 添加 Bank City
CLEAR: gs_fcat.
gs_fcat-fieldname = 'ORT01'.
gs_fcat-coltext = 'Bank City'.
gs_fcat-domname = 'TEXT35'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 35.
APPEND gs_fcat TO gt_fcat.
" 添加 Bank Number
CLEAR: gs_fcat.
gs_fcat-fieldname = 'BNKLZ'.
gs_fcat-coltext = 'Bank Number'.
gs_fcat-domname = 'BANKL'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 15.
APPEND gs_fcat TO gt_fcat.
" 添加 Swift
CLEAR: gs_fcat.
gs_fcat-fieldname = 'SWIFT'.
gs_fcat-coltext = 'Swift/BIC'.
gs_fcat-domname = 'SWIFT'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 11.
APPEND gs_fcat TO gt_fcat.
" 添加银行分支
CLEAR: gs_fcat.
gs_fcat-fieldname = 'BRNCH'.
gs_fcat-coltext = 'Bank Branch'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 40.
APPEND gs_fcat TO gt_fcat.
" 添加银行街道
CLEAR: gs_fcat.
gs_fcat-fieldname = 'STRAS'.
gs_fcat-coltext = 'Bank Street'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-domname = 'TEXT35'.
gs_fcat-intlen = 35.
APPEND gs_fcat TO gt_fcat.
"添加MSG字段
CLEAR: gs_fcat.
gs_fcat-fieldname = 'MSG'.
gs_fcat-coltext = 'Return Msg.'.
gs_fcat-domname = 'CHAR128'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 128.
APPEND gs_fcat TO gt_fcat.
"添加创建日期
CLEAR: gs_fcat.
gs_fcat-fieldname = 'ERDAT'.
gs_fcat-coltext = 'Create Date'.
gs_fcat-domname = 'DATUM'.
gs_fcat-datatype = 'CHAR'.
gs_fcat-intlen = 8.
APPEND gs_fcat TO gt_fcat.
*创建表的动态内表.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <fs_out_tab>.
CREATE DATA dy_line LIKE LINE OF <fs_out_tab>.
ASSIGN dy_line->* TO <fs_out>.
DELETE gt_fcat WHERE fieldname = 'SEL' OR fieldname = 'TYPE'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_LAYO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_set_layo .
gs_layo-box_fname = 'SEL'.
gs_layo-zebra = 'X'.
gs_layo-cwidth_opt = 'X'.
gs_fcat-no_zero = 'X'.
MODIFY gt_fcat FROM gs_fcat TRANSPORTING no_zero WHERE inttype = 'P' OR inttype = 'I'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_SET_STATUS'
i_callback_user_command = 'FRM_USER_COMMAND'
i_save = 'A'
is_layout_lvc = gs_layo
it_fieldcat_lvc = gt_fcat[]
TABLES
t_outtab = <fs_out_tab>[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)