Skip to Content
0

How to execute a report in background whenever any file is uploaded in particular SAP-Directories?

Aug 06, 2017 at 07:47 PM

334

avatar image
Former Member

Hi,

I'm developing a report which will fetch data from .txt file from SAP-Directories (AL11) and will do the needful processing.

What I want is that whenever any file is uploaded into my directory in AL11, that report should execute in background.

Please help.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Domi Bigl Aug 06, 2017 at 09:01 PM
2

I don`t think there is an automatic trigger for file changed/added!

I´d poll the directory for new files with an periodic background job or, if it`s more time critical, use some external trigger like RFC function module or HTTP request.

kr

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Dominik

Can you please elaborate how to use some external trigger or HTTP request ?

0

When the process that sends the data writes it to the file system, it should raise an event, or run a program on the receiving system. There are many and varied ways of doing this - e.g. web services. If you search you will find.

But it you're able call a webservice - then you can send the data directly using that, rather than using a file.

2
Former Member
Matthew Billingham

Thank you Matthew.
You have suggested a good approach. But since I had developed my report and all the process I cannot move into web services. Is there any other solution to trigger event from AL11?

0

If you properly write your program as a layered application, it should not be an issue implementing another interface (i.e. wrapping a web service around it). If it isn't a simple job, then that suggests you need to redesign your report.

0

Or, if the interface does not need to be near real time then the upload program should be run as a batch.

0
Former Member
Richard Harper

Hi Richard,

This is my main concern, I want my interface to be realtime.

0

Real Time processing is a fallacy. Near Real Time is a more accurate description.

If you want this to be real time then you need to either use SAPEVT or change the source program (ie source for the data) to use an RFC call into SAP, otherwise you are reduced to polling a directory on a periodic basis. You may be able to raise an event if you have or use an FTP server control program or PI but other than that you'll be a bit stuck.

1
Rashid Javed Aug 08, 2017 at 02:08 PM
0

Well this is not complete answer but i hope it helps you.

I remember in good old days there was an SAP program called sapevt.exe that resides on application server (i am talking about Windows OS). What this program can do was to trigger a background event (transaction code SM62, SM64) in application server.

so the idea was that we have a background job scheduled whose trigger was background event lets assume ZEVT1. now on application server our system administrator has written a script that check the directory for new files and if it finds the file, it calls sapevt.exe with required parameters to trigger the background event (script runs on the OS level, can't remember if this was a bat file or VBscript).

Once the event is triggered, the background job would start on application server (that was bind with this event) and in the job the program process the file.

So much time has passed since then, i hope some new method will be available now to address this issue :-)

Show 11 Share
10 |10000 characters needed characters left characters exceeded

However, this means modifying the source program. If you do not have access to that (or the files are not delivered by a postman like ftp service which possible could call sapevt).

You could, of course do as you suggested with a scheduled vbscript, but having said that, what is the difference with that and a scheduled batch job ? On top of that you would need to change the script for each interface you add assuming that it has a different inbound firectory.

0

I don't get it, why do this means modifying source program?? Assuming the user already has an ABAP program that can read a file from Application server and process it; all i am suggesting is to change the background job scheduling. Instead of starting it on some Date/Time you link it with a background event. No change in the original program.

With ref to other comment about scheduled vbscript, well i think that was not the case. If i remember our system admin mentioned he was relying on some file system event to trigger the sapevt.exe so I assumed it was not polling regularly but instead waiting for some file system event to happen.

0

"I don't get it, why do this means modifying source program?? Assuming the user already has an ABAP program that can read a file from Application server and process it;".

You are talking about sapevt which is an external program used to raise an event in SAP. What is the point of raising that event in the program that reads the interface file ? It needs to be raised at the end of the program writing that file. So, avoiding the the VbScript option, that means that some one has to have access to the write program to changing to to call sapevt.

"scheduled vbscript, well i think that was not the case."

Then why mention it ?

0

I think we are talking very different things here.

1: The original question that user asked is about he has a report that can read data from a file from application server and his requirement is that whenever a file is uploaded in the directory this program should execute (supposedly to read data from that file and do something with it).

2: The solution i suggested was to schedule the background job based on an event (as a periodic job) AND from the OS side the system admin would write a script that checks the directory for new file and if new file found trigger the background event through his script(that will happen by calling sapevt.exe with specific parameters). This way the background job linked with this event will get triggered. Hope now it is clear to you.

3: Refer to your comment

[["scheduled vbscript, well i think that was not the case."

Then why mention it ? ]]

I am really speechless here. You are the one who used this term "scheduled vbscript" Refer to your first comment above. I am just explaining to you that this was not the case. Yet here you are blaming me that why i use the term???? I did not. I am just explaining that it was not "scheduled" vbscript.

0

Hi Rashid,

Don't think so...

1. I fully understand what the OP is on about.

2. "The solution i suggested was to schedule the background job based on an event (as a periodic job)"

Event driven jobs are not periodic jobs. Totally different startup conditions. My original comment: "Or, if the interface does not need to be near real time then the upload program should be run as a batch." is more of a periodic job. Why if it is an event driven job does it need to be scheduled periodically as a batch job ????

3. "has written a script that check the directory for new files....... can't remember if this was a bat file or VBscript)."

Your words.

0

Hi Richard

1: Thanks. Finally we agree on something.

2: Yes event driven job can be periodic. Refer to screenshot below. That checkbox of Periodic Job. we do it because otherwise the job gets triggered and finish. So next time the event is triggered there is no job to run. By choosing periodic we ensure that this job stays in released state and whenever this event is triggered the job starts.

3: So how does [has written a script that check the directory for new files....... can't remember if this was a bat file or VBscript)] turns into [scheduled vbscript (Your words)]. You assumed it and i clarified that i was based on file system events.

job.png (30.9 kB)
0

In that case Rashid I have learnt something new! thanks for pushing the point!

0
Former Member

Sapevt is still the way to go if you have to trigger an event from OS level. it's not only available for Windows. On Unix/Linux, you will typically find it in /usr/sap/<SAPSID>/SYS/exe/run/sapevt. Of course for a file transfer scenario this will only ever be an option if you have access to modify the application that generates the file or if that application allows you to run post-processing scripts.

0

See my comment above....

0
Former Member

Hi Rashid,

so the idea was that we have a background job scheduled whose trigger was background event lets assume ZEVT1. now on application server our system administrator has written a script that check the directory for new files and if it finds the file, it calls sapevt.exe with required parameters to trigger the background event (script runs on the OS level, can't remember if this was a bat file or VBscript).

Can you please tell me how to acheive this in details?

0
0
Kenneth Moore Aug 09, 2017 at 02:21 PM
0

There is a function module 'EPS_GET_DIRECTORY_LISTING' which will read a file directory and bring back any file names in the directory. You can create a report to poll the directory and set up a job with this report to run periodically.

Share
10 |10000 characters needed characters left characters exceeded