07-23-2009 10:30 AM
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.
07-24-2009 10:28 AM
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.
07-24-2009 10:28 AM
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.
08-05-2009 4:14 PM
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.