Правда, пока файлы загружать\выгружать можно лишь по одному:
*&---------------------------------------------------------------------*
*& Report ZNN_UPLOAD
*&
*&---------------------------------------------------------------------*
*& To Upload/Download file to the server
*& to download them them through the infopackage
*& the path to the server we read from TVARVC
*& variable_name = 'ZSV_INFOPACKAGE_FILE_PATH'
*&---------------------------------------------------------------------*
REPORT znn_upload_new.
TYPE-POOLS:
icon.
TABLES:
sscrfields.
DATA:
functxt TYPE smp_dyntxt,
path_name TYPE sapb-sappfad.
DATA:
gt_fieldvals TYPE TABLE OF dynpread,
gs_fieldval LIKE LINE OF gt_fieldvals.
*"----------------------------------------------------------------------
SELECTION-SCREEN
BEGIN OF BLOCK b1 WITH FRAME
TITLE text-001.
*" Выбор
PARAMETERS p_up RADIOBUTTON GROUP t001 DEFAULT 'X'. " Загрузка файла
PARAMETERS p_down RADIOBUTTON GROUP t001. " Выгрузка файла
SELECTION-SCREEN
END OF BLOCK b1.
SELECTION-SCREEN
BEGIN OF BLOCK b2 WITH FRAME
TITLE text-002.
*" Каталог на сервере
PARAMETERS p_path2 LIKE path_name LOWER CASE OBLIGATORY DEFAULT path_name.
*" Имя файла на сервере
SELECTION-SCREEN
BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) FOR FIELD p_path.
PARAMETERS:
p_path LIKE path_name LOWER CASE OBLIGATORY,
p_upper AS CHECKBOX.
SELECTION-SCREEN COMMENT (20) FOR FIELD p_upper.
SELECTION-SCREEN
END OF LINE.
SELECTION-SCREEN
END OF BLOCK b2.
SELECTION-SCREEN
BEGIN OF BLOCK b3 WITH FRAME
TITLE text-003.
*" Полное имя файла на локальной рабочей станции
PARAMETERS p_tpath LIKE path_name LOWER CASE OBLIGATORY.
SELECTION-SCREEN
END OF BLOCK b3.
*p_path = p_path2 && '/' && p_path.
*"----------------------------------------------------------------------
SELECTION-SCREEN FUNCTION KEY 1.
INITIALIZATION.
functxt-icon_id = icon_protocol.
functxt-quickinfo = 'AL11'.
functxt-icon_text = 'AL11'.
sscrfields-functxt_01 = functxt.
* break-point id break.
SELECT SINGLE low
FROM tvarvc
INTO path_name
WHERE name EQ 'ZSV_INFOPACKAGE_FILE_PATH'.
p_path2 = path_name.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN.
* BREAK-POINT id break.
CASE sy-ucomm.
WHEN 'FC01'.
SUBMIT rswatch0 AND RETURN. "AL11
ENDCASE.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_tpath.
PERFORM f_valreq_client_file.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN
ON VALUE-REQUEST FOR p_path2.
PERFORM f_valreq_server_file.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN
ON VALUE-REQUEST FOR p_path.
PERFORM f_valreq_server_file.
*"----------------------------------------------------------------------
START-OF-SELECTION.
DATA:
l_fullpath LIKE path_name,
l_file_exists TYPE abap_bool,
"For type conversion
l_file TYPE string.
IF p_upper = abap_true.
TRANSLATE p_path TO UPPER CASE.
ENDIF.
l_file = l_fullpath = p_path2 && '/' && p_path.
IF p_up EQ abap_true.
l_file_exists = cl_gui_frontend_services=>file_exist(
file = l_file
).
"Source file does not exists
IF l_file_exists = abap_false.
MESSAGE |File { l_fullpath } does not exists| TYPE 'I'.
RETURN.
ENDIF.
CALL FUNCTION 'ARCHIVFILE_CLIENT_TO_SERVER'
EXPORTING
*" Path + file name on client
path = p_tpath
*" Path + file name on application server
targetpath = l_fullpath.
ELSE.
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_CLIENT'
EXPORTING
*" Path + file name on application server
path = l_fullpath
*" Path + file name on client
targetpath = p_tpath.
ENDIF.
IF sy-subrc <> 0.
WRITE sy-subrc.
ELSE.
WRITE 'OK'.
ENDIF.
*"----------------------------------------------------------------------
*"----------------------------------------------------------------------
* Forms
*"----------------------------------------------------------------------
*"----------------------------------------------------------------------
* Value request for server file
*"----------------------------------------------------------------------
FORM f_valreq_server_file.
DATA:
l_server_path TYPE text200,
l_fname LIKE l_server_path,
l_server_fullpath LIKE l_server_path,
l_server_dir TYPE string,
l_server_filename TYPE string,
l_file_type LIKE epsf-epsfiltyp.
gt_fieldvals = VALUE #(
( fieldname = 'P_PATH2' )
( fieldname = 'P_PATH' )
).
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
translate_to_upper = abap_false
TABLES
dynpfields = gt_fieldvals.
"Get server file path
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_PATH2'
INTO gs_fieldval.
l_server_path = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Get server filename
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_PATH'
INTO gs_fieldval.
l_fname = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = l_server_path
filemask = '*'
IMPORTING
serverfile = l_server_fullpath
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc = 1.
MESSAGE 'User cancelled' TYPE 'S'.
RETURN.
ENDIF.
CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
EXPORTING
* FILE_NAME =
iv_long_file_name = l_server_fullpath
* DIR_NAME =
* IV_LONG_DIR_NAME =
IMPORTING
* FILE_SIZE =
* FILE_OWNER =
* FILE_MODE =
file_type = l_file_type
* FILE_MTIME =
* FILE_SIZE_LONG =
EXCEPTIONS
* READ_DIRECTORY_FAILED = 1
* READ_ATTRIBUTES_FAILED = 2
OTHERS = 3.
TRANSLATE l_file_type TO UPPER CASE.
IF l_file_type CP '*DIR*'.
l_server_dir = l_server_fullpath.
gs_fieldval = VALUE #( fieldname = 'P_PATH2' fieldvalue = l_server_dir ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH2'.
ELSE.
REPLACE ALL OCCURRENCES OF '/'
IN l_server_fullpath
WITH '\'
.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = l_server_fullpath
IMPORTING
stripped_name = l_server_filename
file_path = l_server_dir
EXCEPTIONS
x_error = 1
OTHERS = 2.
REPLACE ALL OCCURRENCES OF '\'
IN l_server_dir
WITH '/'
.
gs_fieldval = VALUE #( fieldname = 'P_PATH2' fieldvalue = l_server_dir ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH2'.
gs_fieldval = VALUE #( fieldname = 'P_PATH' fieldvalue = l_server_filename ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH'.
ENDIF.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = gt_fieldvals.
ENDFORM.
*"----------------------------------------------------------------------
* Value request for client file
*"----------------------------------------------------------------------
FORM f_valreq_client_file.
DATA:
l_default_fname TYPE string,
l_default_dir TYPE string,
l_fname TYPE string,
l_path TYPE string,
l_fullpath TYPE string,
l_action TYPE i,
lt_file_table TYPE filetable,
l_numfiles TYPE i.
DATA:
l_download TYPE abap_bool.
*-----------------------------------------------------------------------
* l_default_fname = p_tpath.
gt_fieldvals = VALUE #(
( fieldname = 'P_DOWN' )
( fieldname = 'P_PATH' )
( fieldname = 'P_TPATH' )
( fieldname = 'P_UPPER' )
).
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
translate_to_upper = abap_false
TABLES
dynpfields = gt_fieldvals.
"Get upload or download action type
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_DOWN'
INTO gs_fieldval.
l_download = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Get default filename
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_PATH'
INTO gs_fieldval.
l_default_fname = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Get default directory
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_TPATH'
INTO gs_fieldval.
l_default_dir = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Filename to upper
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_UPPER'
INTO gs_fieldval.
IF gs_fieldval-fieldvalue = abap_true.
TRANSLATE l_fname TO UPPER CASE.
ENDIF.
CLEAR gs_fieldval.
IF l_download = abap_true.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Select target file path'
default_extension = 'csv'
default_file_name = l_default_fname
initial_directory = l_default_dir
file_filter = cl_gui_frontend_services=>filetype_all
&& cl_gui_frontend_services=>filetype_text
&& `Csv files (*.csv)|*.csv|`
CHANGING
filename = l_fname
path = l_path
fullpath = l_fullpath
user_action = l_action
EXCEPTIONS
cntl_error = 1
OTHERS = 2. "#EC NOTEXT
CHECK sy-subrc = 0.
IF l_action = cl_gui_frontend_services=>action_ok.
"Modify screen
gs_fieldval = VALUE #( fieldname = 'P_TPATH' fieldvalue = l_fullpath ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_TPATH'.
ENDIF.
ELSE.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = `Select input file`
default_filename = l_default_fname
initial_directory = l_default_dir
multiselection = abap_false
CHANGING
file_table = lt_file_table
rc = l_numfiles
user_action = l_action
EXCEPTIONS
cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* invalid_default_file_name = 4
OTHERS = 5.
CHECK sy-subrc = 0.
IF l_action = cl_gui_frontend_services=>action_ok.
l_fullpath = lt_file_table[ 1 ]-filename.
"Modify screen
".Source file path
gs_fieldval = VALUE #( fieldname = 'P_TPATH' fieldvalue = l_fullpath ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_TPATH'.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = l_fullpath
IMPORTING
stripped_name = l_fname
* FILE_PATH =
EXCEPTIONS
x_error = 1
OTHERS = 2.
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_UPPER'
INTO gs_fieldval.
IF gs_fieldval-fieldvalue = abap_true.
TRANSLATE l_fname TO UPPER CASE.
ENDIF.
CLEAR gs_fieldval.
gs_fieldval = VALUE #( fieldname = 'P_PATH' fieldvalue = l_fname ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH'.
ELSE.
MESSAGE 'User cancelled' TYPE 'S'.
ENDIF.
ENDIF.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = gt_fieldvals.
CALL METHOD cl_gui_cfw=>flush.
ENDFORM.
*& Report ZNN_UPLOAD
*&
*&---------------------------------------------------------------------*
*& To Upload/Download file to the server
*& to download them them through the infopackage
*& the path to the server we read from TVARVC
*& variable_name = 'ZSV_INFOPACKAGE_FILE_PATH'
*&---------------------------------------------------------------------*
REPORT znn_upload_new.
TYPE-POOLS:
icon.
TABLES:
sscrfields.
DATA:
functxt TYPE smp_dyntxt,
path_name TYPE sapb-sappfad.
DATA:
gt_fieldvals TYPE TABLE OF dynpread,
gs_fieldval LIKE LINE OF gt_fieldvals.
*"----------------------------------------------------------------------
SELECTION-SCREEN
BEGIN OF BLOCK b1 WITH FRAME
TITLE text-001.
*" Выбор
PARAMETERS p_up RADIOBUTTON GROUP t001 DEFAULT 'X'. " Загрузка файла
PARAMETERS p_down RADIOBUTTON GROUP t001. " Выгрузка файла
SELECTION-SCREEN
END OF BLOCK b1.
SELECTION-SCREEN
BEGIN OF BLOCK b2 WITH FRAME
TITLE text-002.
*" Каталог на сервере
PARAMETERS p_path2 LIKE path_name LOWER CASE OBLIGATORY DEFAULT path_name.
*" Имя файла на сервере
SELECTION-SCREEN
BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) FOR FIELD p_path.
PARAMETERS:
p_path LIKE path_name LOWER CASE OBLIGATORY,
p_upper AS CHECKBOX.
SELECTION-SCREEN COMMENT (20) FOR FIELD p_upper.
SELECTION-SCREEN
END OF LINE.
SELECTION-SCREEN
END OF BLOCK b2.
SELECTION-SCREEN
BEGIN OF BLOCK b3 WITH FRAME
TITLE text-003.
*" Полное имя файла на локальной рабочей станции
PARAMETERS p_tpath LIKE path_name LOWER CASE OBLIGATORY.
SELECTION-SCREEN
END OF BLOCK b3.
*p_path = p_path2 && '/' && p_path.
*"----------------------------------------------------------------------
SELECTION-SCREEN FUNCTION KEY 1.
INITIALIZATION.
functxt-icon_id = icon_protocol.
functxt-quickinfo = 'AL11'.
functxt-icon_text = 'AL11'.
sscrfields-functxt_01 = functxt.
* break-point id break.
SELECT SINGLE low
FROM tvarvc
INTO path_name
WHERE name EQ 'ZSV_INFOPACKAGE_FILE_PATH'.
p_path2 = path_name.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN.
* BREAK-POINT id break.
CASE sy-ucomm.
WHEN 'FC01'.
SUBMIT rswatch0 AND RETURN. "AL11
ENDCASE.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_tpath.
PERFORM f_valreq_client_file.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN
ON VALUE-REQUEST FOR p_path2.
PERFORM f_valreq_server_file.
*"----------------------------------------------------------------------
AT SELECTION-SCREEN
ON VALUE-REQUEST FOR p_path.
PERFORM f_valreq_server_file.
*"----------------------------------------------------------------------
START-OF-SELECTION.
DATA:
l_fullpath LIKE path_name,
l_file_exists TYPE abap_bool,
"For type conversion
l_file TYPE string.
IF p_upper = abap_true.
TRANSLATE p_path TO UPPER CASE.
ENDIF.
l_file = l_fullpath = p_path2 && '/' && p_path.
IF p_up EQ abap_true.
l_file_exists = cl_gui_frontend_services=>file_exist(
file = l_file
).
"Source file does not exists
IF l_file_exists = abap_false.
MESSAGE |File { l_fullpath } does not exists| TYPE 'I'.
RETURN.
ENDIF.
CALL FUNCTION 'ARCHIVFILE_CLIENT_TO_SERVER'
EXPORTING
*" Path + file name on client
path = p_tpath
*" Path + file name on application server
targetpath = l_fullpath.
ELSE.
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_CLIENT'
EXPORTING
*" Path + file name on application server
path = l_fullpath
*" Path + file name on client
targetpath = p_tpath.
ENDIF.
IF sy-subrc <> 0.
WRITE sy-subrc.
ELSE.
WRITE 'OK'.
ENDIF.
*"----------------------------------------------------------------------
*"----------------------------------------------------------------------
* Forms
*"----------------------------------------------------------------------
*"----------------------------------------------------------------------
* Value request for server file
*"----------------------------------------------------------------------
FORM f_valreq_server_file.
DATA:
l_server_path TYPE text200,
l_fname LIKE l_server_path,
l_server_fullpath LIKE l_server_path,
l_server_dir TYPE string,
l_server_filename TYPE string,
l_file_type LIKE epsf-epsfiltyp.
gt_fieldvals = VALUE #(
( fieldname = 'P_PATH2' )
( fieldname = 'P_PATH' )
).
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
translate_to_upper = abap_false
TABLES
dynpfields = gt_fieldvals.
"Get server file path
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_PATH2'
INTO gs_fieldval.
l_server_path = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Get server filename
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_PATH'
INTO gs_fieldval.
l_fname = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = l_server_path
filemask = '*'
IMPORTING
serverfile = l_server_fullpath
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc = 1.
MESSAGE 'User cancelled' TYPE 'S'.
RETURN.
ENDIF.
CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
EXPORTING
* FILE_NAME =
iv_long_file_name = l_server_fullpath
* DIR_NAME =
* IV_LONG_DIR_NAME =
IMPORTING
* FILE_SIZE =
* FILE_OWNER =
* FILE_MODE =
file_type = l_file_type
* FILE_MTIME =
* FILE_SIZE_LONG =
EXCEPTIONS
* READ_DIRECTORY_FAILED = 1
* READ_ATTRIBUTES_FAILED = 2
OTHERS = 3.
TRANSLATE l_file_type TO UPPER CASE.
IF l_file_type CP '*DIR*'.
l_server_dir = l_server_fullpath.
gs_fieldval = VALUE #( fieldname = 'P_PATH2' fieldvalue = l_server_dir ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH2'.
ELSE.
REPLACE ALL OCCURRENCES OF '/'
IN l_server_fullpath
WITH '\'
.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = l_server_fullpath
IMPORTING
stripped_name = l_server_filename
file_path = l_server_dir
EXCEPTIONS
x_error = 1
OTHERS = 2.
REPLACE ALL OCCURRENCES OF '\'
IN l_server_dir
WITH '/'
.
gs_fieldval = VALUE #( fieldname = 'P_PATH2' fieldvalue = l_server_dir ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH2'.
gs_fieldval = VALUE #( fieldname = 'P_PATH' fieldvalue = l_server_filename ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH'.
ENDIF.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = gt_fieldvals.
ENDFORM.
*"----------------------------------------------------------------------
* Value request for client file
*"----------------------------------------------------------------------
FORM f_valreq_client_file.
DATA:
l_default_fname TYPE string,
l_default_dir TYPE string,
l_fname TYPE string,
l_path TYPE string,
l_fullpath TYPE string,
l_action TYPE i,
lt_file_table TYPE filetable,
l_numfiles TYPE i.
DATA:
l_download TYPE abap_bool.
*-----------------------------------------------------------------------
* l_default_fname = p_tpath.
gt_fieldvals = VALUE #(
( fieldname = 'P_DOWN' )
( fieldname = 'P_PATH' )
( fieldname = 'P_TPATH' )
( fieldname = 'P_UPPER' )
).
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
translate_to_upper = abap_false
TABLES
dynpfields = gt_fieldvals.
"Get upload or download action type
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_DOWN'
INTO gs_fieldval.
l_download = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Get default filename
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_PATH'
INTO gs_fieldval.
l_default_fname = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Get default directory
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_TPATH'
INTO gs_fieldval.
l_default_dir = gs_fieldval-fieldvalue.
CLEAR gs_fieldval.
"Filename to upper
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_UPPER'
INTO gs_fieldval.
IF gs_fieldval-fieldvalue = abap_true.
TRANSLATE l_fname TO UPPER CASE.
ENDIF.
CLEAR gs_fieldval.
IF l_download = abap_true.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Select target file path'
default_extension = 'csv'
default_file_name = l_default_fname
initial_directory = l_default_dir
file_filter = cl_gui_frontend_services=>filetype_all
&& cl_gui_frontend_services=>filetype_text
&& `Csv files (*.csv)|*.csv|`
CHANGING
filename = l_fname
path = l_path
fullpath = l_fullpath
user_action = l_action
EXCEPTIONS
cntl_error = 1
OTHERS = 2. "#EC NOTEXT
CHECK sy-subrc = 0.
IF l_action = cl_gui_frontend_services=>action_ok.
"Modify screen
gs_fieldval = VALUE #( fieldname = 'P_TPATH' fieldvalue = l_fullpath ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_TPATH'.
ENDIF.
ELSE.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = `Select input file`
default_filename = l_default_fname
initial_directory = l_default_dir
multiselection = abap_false
CHANGING
file_table = lt_file_table
rc = l_numfiles
user_action = l_action
EXCEPTIONS
cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* invalid_default_file_name = 4
OTHERS = 5.
CHECK sy-subrc = 0.
IF l_action = cl_gui_frontend_services=>action_ok.
l_fullpath = lt_file_table[ 1 ]-filename.
"Modify screen
".Source file path
gs_fieldval = VALUE #( fieldname = 'P_TPATH' fieldvalue = l_fullpath ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_TPATH'.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = l_fullpath
IMPORTING
stripped_name = l_fname
* FILE_PATH =
EXCEPTIONS
x_error = 1
OTHERS = 2.
READ TABLE gt_fieldvals
WITH KEY fieldname = 'P_UPPER'
INTO gs_fieldval.
IF gs_fieldval-fieldvalue = abap_true.
TRANSLATE l_fname TO UPPER CASE.
ENDIF.
CLEAR gs_fieldval.
gs_fieldval = VALUE #( fieldname = 'P_PATH' fieldvalue = l_fname ).
MODIFY gt_fieldvals
FROM gs_fieldval
TRANSPORTING fieldvalue
WHERE fieldname = 'P_PATH'.
ELSE.
MESSAGE 'User cancelled' TYPE 'S'.
ENDIF.
ENDIF.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = gt_fieldvals.
CALL METHOD cl_gui_cfw=>flush.
ENDFORM.
Код для инфо-пакета:
program filename_routine.
* Global code
*$*$ begin of global - insert your declaration only below this line *-*
* Enter here global variables and type declarations
* as well as additional form routines, which you may call from the
* main routine COMPUTE_FLAT_FILE_FILENAME below
*TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
form compute_flat_file_filename
using p_request type RSREQUID
p_infopackage type rslogdpid
p_datasource type rsoltpsourcer
p_logsys type rsslogsys
changing p_filename type RSFILENM
p_subrc like sy-subrc.
*$*$ begin of routine - insert your code only below this line *-*
*"----------------------------------------------------------------------
*" ZDAY_OTM.CSV
data:
file_name type string,
path_name type string.
*-----------------------------------------------------------------------
file_name = `ZDAY_OTM.CSV`.
select single low
from tvarvc
into path_name
where name eq 'ZSV_INFOPACKAGE_FILE_PATH'.
if sy-subrc ne 0.
message 'Incorrect variable value' type 'E'.
endif.
p_filename = path_name && file_name.
p_subrc = 0.
*-----------------------------------------------------------------------
*$*$ end of routine - insert your code only before this line *-*
endform.
* Global code
*$*$ begin of global - insert your declaration only below this line *-*
* Enter here global variables and type declarations
* as well as additional form routines, which you may call from the
* main routine COMPUTE_FLAT_FILE_FILENAME below
*TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
form compute_flat_file_filename
using p_request type RSREQUID
p_infopackage type rslogdpid
p_datasource type rsoltpsourcer
p_logsys type rsslogsys
changing p_filename type RSFILENM
p_subrc like sy-subrc.
*$*$ begin of routine - insert your code only below this line *-*
*"----------------------------------------------------------------------
*" ZDAY_OTM.CSV
data:
file_name type string,
path_name type string.
*-----------------------------------------------------------------------
file_name = `ZDAY_OTM.CSV`.
select single low
from tvarvc
into path_name
where name eq 'ZSV_INFOPACKAGE_FILE_PATH'.
if sy-subrc ne 0.
message 'Incorrect variable value' type 'E'.
endif.
p_filename = path_name && file_name.
p_subrc = 0.
*-----------------------------------------------------------------------
*$*$ end of routine - insert your code only before this line *-*
endform.
Комментариев нет:
Отправить комментарий