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: 

Call ABAP program from Unix script passing dynamic filename

Former Member
0 Kudos

Hi,

Does anyone know if it is possible to call an ABAP program from a Unix script passing a dynamic filename to the ABAP program?

We are receiving a file from an external company and on receipt of the file want to call an ABAP program passing the filename. The filename is made up of File ID, Date and Time which we need to read in the ABAP program. We usually use Events to trigger a program which is fine when the filename if static however since this filename will be dynamic we cannot do this. In addition we cannot just rename the file to a static name in the Unix script as we need to know the value of the date and time from the file ID in the ABAP program. I can change the ABAP program to check our /in directory for a Filename that starts with the fixed File ID however I thought there must be a better way of doing this. We want the external company to put this information in a file header record but they don't want to change the file contents. Any ideas would be appreciated.

Thanks,

Sinead.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You could follow the following method

1.Let the external file reside in the SAP application layer in a defined path e.g. /usr/sap/tmp/interface/working/

2.Write an ABAP program which will include the following steps:-

i) read all files in the file path using function module EPS_GET_DIRECTORY_LISTING

ii) Read the data from files existing in the directory using OPEN_DATASET statement

iii) After the files have been read move the files to another directory e.g. /usr/sap/tmp/interface/backup/ or you can delete the file.

3.Schedule this program to be executed depending on the frequency of the external file being generated.

2 REPLIES 2

Former Member
0 Kudos

You could follow the following method

1.Let the external file reside in the SAP application layer in a defined path e.g. /usr/sap/tmp/interface/working/

2.Write an ABAP program which will include the following steps:-

i) read all files in the file path using function module EPS_GET_DIRECTORY_LISTING

ii) Read the data from files existing in the directory using OPEN_DATASET statement

iii) After the files have been read move the files to another directory e.g. /usr/sap/tmp/interface/backup/ or you can delete the file.

3.Schedule this program to be executed depending on the frequency of the external file being generated.

0 Kudos

Thanks for the response. I have found that you can pass a parameter when you raise the SAP event from a Unix script. The format is:

sapevt <sap event> -p $1

where $1 will contain the filename. In the ABAP program you then call function module 'GET_JOB_RUNTIME_INFO' to get the value of the parameter as follows:

CALL FUNCTION 'GET_JOB_RUNTIME_INFO'

IMPORTING

eventparm = l_fileid

EXCEPTIONS

no_runtime_info = 1

OTHERS = 2.