08-18-2006 10:50 AM
Hi Experts,
Is there any FM in ABAP to read a directory from local server.?If so Can any body give me with an example.
SSure of reward points.
08-18-2006 11:00 AM
hi Ravi,
Check out this hope it works..
REPORT zsritest3.
TABLES: file_table.
DATA: lt_file_names TYPE FILETABLE,
lwa_file_name TYPE FILE_TABLE,
lv_subrc TYPE i.
SELECT-OPTIONS: so_file FOR file_table NO INTERVALS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_file-low.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
INITIAL_DIRECTORY = 'C:Temp'
MULTISELECTION = 'X'
CHANGING
file_table = lt_file_names[]
rc = lv_subrc
* USER_ACTION =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
others = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
so_file-sign = 'I'.
so_file-option = 'EQ'.
LOOP AT lt_file_names INTO lwa_file_name.
so_file-low = lwa_file_name.
APPEND so_file.
ENDLOOP.
START-OF-SELECTION.
LOOP AT so_file.
WRITE: / so_file-low.
ENDLOOP.
08-18-2006 10:53 AM
From local PC: use fm GUI_UPLOAD.
From application server use.
open dataset/transfer/close dataset commands.
if you can use the methods:
CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
Regards,
Ravi
08-18-2006 10:58 AM
Hi Thanks for response.
But What i mean to ask is I want to read a directory from my local server programatically..and i have to read files one by one from that directory..and then i have to use GUI_UPLOAD.Becaus ei have to run my pgm in back ground.
So i don't want to use file dialouge and hardcode the path in my pgm.
i know there is a fm RZL_READ_DIR..but i am not able to exicute this.
Any suggessions on these..
08-18-2006 11:00 AM
chk this prog RSRZLST1 where the FM RZL_READ_DIR u had specified had been used
08-18-2006 11:32 AM
Follow the code given below and customize ur code in accordance with this. I will execute and hope ur problem resolves.
Define the variables in accordance with the function module field data types.
PARAMETER: p_file(128) LOWER CASE DEFAULT '/appl//data/fedexp/' OBLIGATORY.
DATA: v_dir_path LIKE sxpgcolist-parameters,
i_dir_files LIKE salfldir OCCURS 0 WITH HEADER LINE.
v_dir_path = p_file.
CALL FUNCTION 'RZL_READ_DIR'
EXPORTING
name = v_dir_path
TABLES
file_tbl = i_dir_files
EXCEPTIONS
argument_error = 1
not_found = 2
send_error = 3
system_failure = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
STOP.
ENDIF.
Reward points, if my solution found to be good.
Regards,
Chandhan
08-21-2006 10:16 AM
Hi ,
Thanks for response.Can you tell me what is '/appl//data/fedexp/' in Parameters statement?
Regards
08-18-2006 10:56 AM
08-18-2006 10:57 AM
DATA: l_dirname LIKE epsf-epsdirnam,
l_filemask LIKE epsf-epsfilnam.
l_dirname = p_dir.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = l_dirname
file_mask = l_filemask
* IMPORTING
* DIR_NAME =
* FILE_COUNTER =
* ERROR_COUNTER =
TABLES
dir_list = pi_filelist
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8
08-18-2006 11:12 AM
Hi All,
Thanks for your replies.
As i said i don't want to open with file dialouge or delcare a parameter or no hardcode path in pgm.I want to run my pgm in back ground.
In that case how can i open a directory?
08-18-2006 11:00 AM
hi Ravi,
Check out this hope it works..
REPORT zsritest3.
TABLES: file_table.
DATA: lt_file_names TYPE FILETABLE,
lwa_file_name TYPE FILE_TABLE,
lv_subrc TYPE i.
SELECT-OPTIONS: so_file FOR file_table NO INTERVALS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_file-low.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILENAME =
* FILE_FILTER =
INITIAL_DIRECTORY = 'C:Temp'
MULTISELECTION = 'X'
CHANGING
file_table = lt_file_names[]
rc = lv_subrc
* USER_ACTION =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
others = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
so_file-sign = 'I'.
so_file-option = 'EQ'.
LOOP AT lt_file_names INTO lwa_file_name.
so_file-low = lwa_file_name.
APPEND so_file.
ENDLOOP.
START-OF-SELECTION.
LOOP AT so_file.
WRITE: / so_file-low.
ENDLOOP.
08-18-2006 11:02 AM
08-18-2006 11:03 AM
Hi,
You can use fm F4_FILENAME to navigate to local directory,
Rgds,
08-18-2006 11:03 AM
Hi
Check this class: CL_GUI_FRONTEND_SERVICES which can be helpful for you.
Kind Regards
Eswar