Get the contents of a Application Server directory

33,854

Solution 1

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

Solution 2

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.

Solution 3

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.

Share:
33,854

Related videos on Youtube

Chris Carruthers
Author by

Chris Carruthers

Experience primarily in Java software development including standard and J2EE, plus associated technologies such as Spring, Hibernate, Maven, Ant, and Tomcat. Also front-end technologies (a personal passion), including HTML, CSS, and Javascript, and associated technologies such as jQuery and JSP. Finally, SAP, focusing on ABAP development and change management.

Updated on July 09, 2022

Comments

  • Chris Carruthers
    Chris Carruthers over 1 year

    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.

  • Chris Carruthers
    Chris Carruthers about 15 years
    Thanks, I didn't know about that function, but it doesn't seem to work with UNC paths, which I need.
  • Armand Maree
    Armand Maree over 5 years
    Bless you, sir! Was looking for one all over the place that could take filenames larger than 40 characters. This solved my problem.
  • Cutter
    Cutter over 2 years
    RZL_READ_DIR_LOCAL returns sub-directories as well as filenames. How to separate directories from files ?
  • Chris Carruthers
    Chris Carruthers over 2 years
    Sorry @Cutter I no longer have access to SAP so I'm not sure.

Related