2013 Jun 18 9:02 PM
Hi all,
I have a report that can find a file and transfer it to an interface. The file suffix prevously has only two digits i.e filename22. Now it has four digits i.e filename9876
The actual code was using a code like this to find and transfer the file filename55:
sufx = 0
do x time
search file with filenamesufx that content data
if found give back the filename
else
sufx = sufx + 1
enddo
It will run 55 times before giving back the file name because the file exist in the sap directory.
Now I would like to implement it efficiently for 4 digits suffix. I would like to save the last suffix found each time to make the next search faster.
What are the efficient ways to save the suffix for the next search (in a database table i.e)? What are the efficients ways to write the new loop?
The suffix are now in the range : 0000 to 9999.
How can I implement the search without running the loop 9999 time in the worst case.
Thanks for your help.
Hi all,
I have a report that can find a file and transfer it to an interface. The file suffix prevously has only two digits i.e filename22. Now it has four digits i.e filename9876
The actual code was using a code like this to find and transfer the file filename55:
sufx = 0
do x time
search file with filenamesufx that content data
if found give back the filename
else
sufx = sufx + 1
enddo
It will run 55 times before giving back the file name because the file exist in the sap directory.
Now I would like to implement it efficiently for 4 digits suffix. I would like to save the last suffix found each time to make the next search faster.
What are the efficient ways to save the suffix for the next search (in a database table i.e)? What are the efficients ways to write the new loop?
The suffix are now in the range : 0000 to 9999.
How can I implement the search without running the loop 9999 time in the worst case.
Thanks for your help.
2013 Jun 19 3:44 AM
Hi,
You can use the FM EPS2_GET_DIRECTORY_LISTING with the with the input parameter FILE_MASK used ( say passing to filter value as filename* ) the get file list from the SAP directory. Then you can loop through the internal table that will have all the files with names starting with filename.
The pattern for the FM is:
CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING' "
EXPORTING
iv_dir_name = " eps2filnam
* file_mask = SPACE " epsf-epsfilnam
IMPORTING
dir_name = " epsf-epsdirnam
file_counter = " epsf-epsfilsiz
error_counter = " epsf-epsfilsiz
TABLES
dir_list = " eps2fili
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 "
. "
Cheers,
Arindam
2013 Jun 19 6:56 AM
Hi,
Use Function Module RZL_READ_DIR to check your all files at particular directory and Sort it, you will get latest file at top.
Regards,
Sujeet
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |