2 weeks ago
Dear sir/Madam,
I am reqeusting to help the code for picking the file from AL11 based on TIMESTAMP,
I am having the files in AL11 like LASTCHANGEDON LASTCHANGEAT FILENAME
ZABFEED_202510230638.csv
ZABFEED_20250411140333.csv
ZABFEED_20250411170135.csv
ZABFEED_20250411194548.csv
ZABFEED_20250411202941.csv
Could anyone please help with the code to picke the files based on latest timestamp,
Regards
2 weeks ago
Could you please help in sharing your inputs will be really helps
2 weeks ago
Hi,
Please check below code it will help you.
DATA: lt_dirlist TYPE STANDARD TABLE OF epsfili,
lv_directory TYPE epsf-epsdirnam,
lv_filename TYPE epsf-filename,
lv_fullpath TYPE string,
lv_latest_file TYPE epsfili,
lv_time TYPE sy-uzeit.
FIELD-SYMBOLS: <fs_file> TYPE epsfili.
" Set your AL11 path (Logical path must be maintained in transaction FILE or actual server path)
lv_directory = '/usr/sap/tmp'. " <-- Change to your AL11 directory
CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'
EXPORTING
iv_dir_name = lv_directory
TABLES
dir_list = lt_dirlist
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 = 7
OTHERS = 8.
IF sy-subrc = 0.
SORT lt_dirlist BY mod_date DESCENDING mod_time DESCENDING. " Sort by last modified timestamp
READ TABLE lt_dirlist ASSIGNING <fs_file> INDEX 1.
IF sy-subrc = 0.
lv_filename = <fs_file>-name.
lv_fullpath = lv_directory && '/' && lv_filename.
WRITE: / 'Latest File:', lv_filename.
" Now open and read this file
DATA: lv_line TYPE string,
lt_file_data TYPE STANDARD TABLE OF string.
OPEN DATASET lv_fullpath FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
WHILE sy-subrc = 0.
READ DATASET lv_fullpath INTO lv_line.
IF sy-subrc = 0.
APPEND lv_line TO lt_file_data.
ENDIF.
ENDWHILE.
CLOSE DATASET lv_fullpath.
ELSE.
WRITE: / 'Unable to open file:', lv_fullpath.
ENDIF.
ENDIF.
ELSE.
WRITE: / 'Failed to list directory'.
ENDIF.
2 weeks ago - last edited 2 weeks ago
Please check below two function modules.
1. /SDF/GET_FILE_INFO - It will give you list of all files in AL11 directory along with DATE and TIME. SORT it as per your requirement and find the workaround.
2. EPS2_GET_DIRECTORY_LISITING - It will give you timestamp along with filename. SORT it as per your requirement and find the workaround.
Wednesday
Dear Sir/Mam,
I have a requirement to help with the programme to shift the files from one folder to other folder from AL11 Folder. i request to help with the code
Thank you
Wednesday
Requesting to please help with the logic or code that really helps