screen 读取文件F4 功能
方式1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM sub_file_path USING p_file.
AT SELECTION-SCREEN.
IF p_file is initial.
MESSAGE '请指定文件路径' type 'E'.
ENDIF.
v_len1 = STRLEN( p_file ).
v_len2 = v_len1 - 3.
IF p_file+v_len2 <> 'XLS' AND p_file+v_len2 <> 'xls'.
MESSAGE '导入的文件名必须以(xls)或者(XLS)为后缀' type 'E'.
ENDIF.
form SUB_FILE_PATH using p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ''
def_path = ''
mask = ',*.xls.'
mode = '0'
title = '请选择要导入的Excel文件.'
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
endform. " SUB_FILE_PATH
方式2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = p_file
CHANGING
rc = rc
file_table = filetab[].
READ TABLE filetab INDEX 1.
IF sy-subrc EQ 0.
p_file = filetab-filename.
ENDIF.
后台JOBFM
DATA: global_job LIKE tbtcjob.
DATA: global_start_date LIKE tbtcstrt.
DATA: global_step_tbl LIKE tbtcstep OCCURS 0 WITH HEADER LINE.
DATA: time LIKE sy-uzeit.
DATA: report LIKE sy-repid, "执行后台作业程序
variant LIKE raldb-variant. "执行变式
GET TIME.
time = sy-uzeit + 60.
CONCATENATE 'ZTEST2' sy-datum sy-uzeit INTO global_job-jobname .
"作业名
global_job-sdlstrtdt = sy-datum. "作业开始日期
global_job-sdlstrttm = time. "作业开始时间
global_job-jobclass = 'A'.
global_job-newflag = 'O'.
global_job-sdluname = sy-uname.
global_step_tbl-program = 'ZTEST2'.
global_step_tbl-typ = 'A'.
global_step_tbl-status = 'P'.
global_step_tbl-authcknam = sy-uname.
APPEND global_step_tbl.
"程序 名 + 变式
report = 'ZTEST2'.
variant = ''.
*定义后台作业
CALL FUNCTION 'BP_JOB_CREATE'
EXPORTING
job_cr_dialog = 'N'
job_cr_head_inp = global_job
IMPORTING
job_cr_head_out = global_job
job_cr_stdt_out = global_start_date
TABLES
job_cr_steplist = global_step_tbl
EXCEPTIONS
cant_create_job = 1
invalid_dialog_type = 2
invalid_job_data = 3
job_create_canceled = 4
OTHERS = 5.
*执行后台作业
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
authcknam = sy-uname
jobcount = global_job-jobcount
jobname = global_job-jobname
report = report
variant = variant.
后台作业FM