Get the contents of a server-side directory in SAP ABAP

隐身守侯 提交于 2019-11-27 03:31:03

问题


I need to get a listing of a server-side directory inside SAP. How do I achieve this in ABAP? Are there any built-in SAP functions I can call?

Ideally I want a function which I can pass a path as input, and which will return a list of filenames in an internal table.


回答1:


After reading the answers of Chris Carrthers and tomdemuyt I would say:

1) Use RZL_READ_DIR_LOCAL if you need simple list of filenames.

2) EPS_GET_DIRECTORY_LISTING is more powerfull - it can also list subdirectories.

Thanks You both!

With best Regards Niki Galanov




回答2:


EPS2_GET_DIRECTORY_LISTING does the same thing as EPS_GET_DIRECTORY_LISTING BUT retunrs the file names up to 200 chars!




回答3:


Call function RZL_READ_DIR_LOCAL:

FUNCTION RZL_READ_DIR_LOCAL.
*"----------------------------------------------------------------------
*"Lokale Schnittstelle:
*"       IMPORTING
*"             NAME LIKE SALFILE-LONGNAME
*"       TABLES
*"             FILE_TBL STRUCTURE SALFLDIR
*"       EXCEPTIONS
*"             ARGUMENT_ERROR
*"             NOT_FOUND
*"----------------------------------------------------------------------

Place the path in the NAME import parameter, and then read the directory listing from FILE_TBL after it returns.

RZL_READ_DIR_LOCAL can handle normal local paths as well as UNC paths.

The only downside is it only gives you access to the first 32 chars of each filename. However, you can easily create a new function based on the RZL_READ_DIR_LOCAL code, and change the way the C program output is read, as the first 187 characters of each filename are actually available.




回答4:


the answer is calling function module EPS_GET_DIRECTORY_LISTING. DIR_NAME -> Name of directory FILE_MASK -> Pass '*' to get all files.

Note: This does not deal with really large file names (80 characters+), it truncates the name.




回答5:


Take a look at transaction AL11 source code: RSWATCH0 form fill_file_list There you can get all information about files.

Hope this helps!



来源:https://stackoverflow.com/questions/152919/get-the-contents-of-a-server-side-directory-in-sap-abap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!