Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the contents of a Application Server directory

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.

like image 427
Chris Carruthers Avatar asked Sep 30 '08 12:09

Chris Carruthers


People also ask

Where can I find SAP application server details?

Open the transaction “os01”. Click on “Application server”. The host name is now displayed. If the IP address is not yet displayed, also click on “Change View”.

How do I read all files in a directory in ABAP?

data: ifile type table of salfldir with header line. parameters: p_path type salfile-longname default '/usr/sap/TST/DVEBMGS01/data/'. call function 'RZL_READ_DIR_LOCAL' exporting name = p_path tables file_tbl = ifile exceptions argument_error = 1 not_found = 2 others = 3. loop at ifile.


2 Answers

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

like image 141
Mark Avatar answered Sep 20 '22 04:09

Mark


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.

like image 42
Chris Carruthers Avatar answered Sep 21 '22 04:09

Chris Carruthers