Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function Module To read all the Files in a Given UNIX directory.

Former Member
0 Kudos

Can anyone provide me with a FUNCTION MODULE which reads all the files available in a UNIX directory?

I have the UNIX directory given. I need to find all the files available in that particular Directory so that I can choose and process accordingly. Probably I can store all files in an Internal Table.

Thanks in advance.

Sunil

1 ACCEPTED SOLUTION

ThomasZloch
Active Contributor
0 Kudos

SUBST_GET_FILE_LIST is what you want!

11 REPLIES 11

Former Member
0 Kudos

Hi,

Function module /SAPDMC/LSM_F4_SERVER_FILE is probably a bit more interactive than you want, as it displays a popup with the directory content. However if you drill into the code you can see how this reads the operating system and you could reuse the code in it.

Regards,

Nick

0 Kudos

Hi Nick,

Thankyou very much for the response.

The Function Module /SAPDMC/LSM_F4_SERVER_FILE is interactive wherein we can select only one file.

But my requirement is I need to collect (probably in an internal table) all the files exixting in the given UNIX directory.

Can you please find in that direction. I would be very grateful.

Thanks.

Sunil

0 Kudos

Hi Sunil,

Yes, that is what I said in my post. The function module is interactive, but if you look at the code in the function module you can see how it reads the directories.

I don't know of a function module that just gives you what you ask, but there is a function module that can help you build something to meet your requirement.

Regards,

Nick

ThomasZloch
Active Contributor
0 Kudos

SUBST_GET_FILE_LIST is what you want!

0 Kudos

Hi Thomas, Thankyou very much for the reply.

Can you please tell me what should be given for FILENM parameter. This is a mandatory parameter. I am looking for storing all the files available in the given UNIX directory DIRNAME.

Can you please help.

Thanks.

Sunil

0 Kudos

No problem. If you fill just an asterisk * in FILEN, it will return all files and directories in the given directory. You could also use a search pattern like "INPUT*", returning all files/directories that start with INPUT...

You get the idea.

Cheers

Thomas

0 Kudos

Hi Thomas,

I have given all the parameters as you mentioned. I gave '' for FILNM and filled PATTERN with 'A'. Still I dont find solution to my problem. I am getting exception ACCESS_ERROR. Sy-subrc became 1. I have access to AL11. I can see all the files and directories in application server.

Can you please help.

Thanks.

Sunil

0 Kudos

Hi Thomas,

Thankyou very much for the answer. My problem got solved. Initially I got exception ACCESS_ERROR because I entered the name in uppercase. Dirname should be lower case.

Anyhow Thanks Once Again!!!

Sunil

0 Kudos

yes, you have to observe capitalization on unix file systems.

Glad it worked OK.

Greetings

Thomas

0 Kudos

Hi Thomas,

I got a problem with the Function Module SUBST_GET_FILE_LIST. It is working fine but when the UNIX directory is more than 40 characters it is not working as importing parameter DIRNAME only allows 40 chars. I have to retain the functionality, but can be able to enter UNIX dirctoey more than 40 characters.

Kindly provide me with the solution.

Thanks in advance.

Sunil

0 Kudos

copy the FM subst_get_file_list to your own Z FM ,then modify the parameters