This website is not affiliated with, sponsored by, or approved by SAP AG.

Upload file for processing in background

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Upload file for processing in background

Postby Eggy » Thu Mar 17, 2016 4:19 am

The program works, we can upload an Excel workbook with multiple sheets, which gets converted to internal tables and then the data is processed (created, changed etc.). Awesome, so we're done! "Yeah well... when we upload 20.000 lines at once, the program ends up in a shortdump." -So don't do that! -But we want to! -Damned!

The only way around this is to have the program executed in background. Challenge there is to have the file from the user (local system) available to the program in the background. For that to happen we need to have it either on the application server or stored somewhere else in SAP, like for example the Business Document Server (BDS).

To read a workbook with multiple sheets, we make use of the office integration interfaces. To be more specific, to actually open the document we use method open_document of interface i_oi_document_proxy. This method takes an URL as file source, which works fine for local files by adding "FILE://" as a prefix. If we store an XLSX file in the BDS (done a POC, that works although we cannot open the document from trx OAOR), the prefixfor the url has to be "SAPR3://".

According to most manuals the BDS is mainly used to store templates, not completely populated files with data to be processed. And additional authorizations are required to be able to properly delete the files again when done. The most straight-forward way of getting the file available to the background program would be to store it on the application server. No problem, we can do that. However so far I haven't been able to access the file using an URL. Not with any prefix, not as plainly '//tmp/testfile.xlsx'.

Anyone have experience with a similar problem? How did you solve it? Thanks for the help :)
Eggy
 
Posts: 309
Joined: Wed Jan 11, 2006 8:50 am

Re: Upload file for processing in background

Postby Sharpshooter » Fri Mar 18, 2016 12:16 pm

Program a function on the selection screen for the user to upload the file before submitting in background. Chances are the timeout is caused by processing, not the file upload time!
Good luck!
Sharpshooter
 
Posts: 1171
Joined: Wed Mar 17, 2010 12:01 pm
Location: In the dark

Re: Upload file for processing in background

Postby Eggy » Sun Mar 20, 2016 1:57 pm

Hmmm let's see... so the user would have a screen to be able to upload the file, after which I would have to trigger a background process that actually processes the file contents. The background job however is a separate process that doesn't have access to the local user's files. The selection screen does not have a parameter type in which you can simply pass internal table data.

A possible workaround would be to use a shared memory table. Not really worked with those before and I know there are very good reasons to stay away from shared memory. However in this case, since I will be triggering the background process immediately after storing the information there, I think it could actually be a viable option.
Eggy
 
Posts: 309
Joined: Wed Jan 11, 2006 8:50 am

Re: Upload file for processing in background

Postby Sharpshooter » Wed Apr 27, 2016 10:52 am

You don't need a separate screen - just an Fcode (triggered by a button?) to upload the file to an internal table. Once the file is uploaded to the internal table, the user submits in background as normal.
Good luck!
Sharpshooter
 
Posts: 1171
Joined: Wed Mar 17, 2010 12:01 pm
Location: In the dark


Return to ABAP

Who is online

Users browsing this forum: Google [Bot] and 12 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.