07-15-2010 5:32 AM
Hello Experts,
How to check whether files are existing or not from the perticular directory in AL11.
Thanks in advance.
Indra
07-15-2010 5:57 AM
Use the FM EPS_GET_DIRECTORY_LISTING to get list of files in directory and
then check if your file exists or not.
07-15-2010 5:57 AM
Use the FM EPS_GET_DIRECTORY_LISTING to get list of files in directory and
then check if your file exists or not.
07-15-2010 6:37 AM
Use 'EPS2_GET_DIRECTORY_LISTING' This f.m. gives you provision to provide a larger path.
Regards,
Birendra
07-15-2010 6:40 AM
You can simple use
OPEN DATASET <your filename> FOR INPUT ....
If the file doesn't exist, you will get SY-SUBRC = 8. [http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_ACCESS.htm#!ABAP_ALTERNATIVE_1@1@]
Cheers,
Suhas
PS: If the file does not exist you cannot read it
09-28-2015 9:14 AM
Simple and efficient way to check an existing file. Thanks ..
07-15-2010 7:46 AM
Hi,
Try the belwo FM
c_cmd TYPE sxpglogcmd VALUE 'WWI_GET_DIR'
V_PARAM = directory Path
c_sys TYPE syopsys VALUE 'ANYOS'.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = c_cmd
additional_parameters = v_param
operatingsystem = c_sys
stdout = c_x
stderr = c_x
terminationwait = c_x
TABLES
exec_protocol = i_command
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
OTHERS = 15.
The Internal table I_COMMAND will be having all the files which is uploaded to the folder.
DELETE i_command INDEX 1. " Always delete the first record from I_Command
Below Code Represents how to take the Exact File name from the I_COMMAND internal table
Store the File names into one Internal Table.
LOOP AT i_command INTO wa_command.
v_strlen = wa_command-length - 1.
CLEAR: v_check.
WHILE v_check IS INITIAL.
v_char = wa_command-message+v_strlen.
IF v_char = space.
v_check = c_x.
ELSE.
v_strlen = v_strlen - 1.
CONCATENATE v_char wa_filename-file INTO wa_filename-file.
ENDIF.
IF v_strlen LE 0.
v_check = c_x.
ENDIF.
ENDWHILE.
APPEND wa_filename TO i_filename.
CLEAR wa_filename.
ENDLOOP.
Inoder to read the Contents of the File
Loop at the File Name Internal Table
Before Reading file Concatenate <Directory Path> and File name then use
OPEN DATASET
READ DATASET
and CLOSE DATA .
Regards,
Shrikanth
07-15-2010 8:01 AM
Thanks for the inputs.
I have solved my issue with them.
Thread closed.
Indra
07-15-2010 8:02 AM
07-15-2010 8:02 AM
Hi,
try the function module RZL_READ_DIR.
Then check in the results FILE_TBL[ ] if your file exists or not.
Very very simple.
Regards,
Andrea