cancel
Showing results for 
Search instead for 
Did you mean: 

SAP query trigerring spool-require it in EXCEL

former_member208541
Participant
0 Kudos

Hello,

We have a batch job which calls a query. The batch when compeleted stores the output in a spool.

Now customer need a change that when the batch job is finished, an excel file is also stored with the same output as spool output.

How to achieve this ?. Can Through ABAP, we can read spool and convert it into excel. If yes, how to code this and where ?

regards

Sonu

Accepted Solutions (0)

Answers (2)

Answers (2)

Sandra_Rossi
Active Contributor

You have the extension SQUE0001 (function module EXIT_RSAQEXCE_001, include ZXQUEU01) to process the SAP query output at the moment it is generated. It receives a table with columns from the SAP query, so it's much more simple to process than the spool data which is not structured.

You may also use the function module RSAQ_REMOTE_QUERY_CALL with parameter DATA_TO_MEMORY = 'X'.

Maybe you can intercept the ALV data produced by the query, by using the class CL_SALV_BS_RUNTIME_INFO.

Jelena
Active Contributor
0 Kudos

Even better. Didn't know about it. Thanks for sharing!

former_member208541
Participant
0 Kudos

thanks sandra

former_member476626
Participant
0 Kudos

Hello Sandra,

Instead of using the exit which you mentioned. Can we use the download option and use convert to excel. Save it as a variant and call variant from batch job ?

regards

sachin

Sandra_Rossi
Active Contributor
0 Kudos

Sachin Arora Try intercepting the query data with CL_SALV_BS_RUNTIME_INFO, and call CL_SALV_BS_TT_UTIL=>IF_SALV_BS_TT_UTIL~TRANSFORM to generate the Excel file. Search the forum for examples.

Jelena
Active Contributor
0 Kudos

It's feasible to read a spool in ABAP and it's feasible to create an Excel file. This can be easily confirmed in Google.

However, at this time you might want to start questioning whether this approach is still a good idea or you'd be better off just converting query into a custom ABAP program.

If for some odd reason you'd prefer to stick with a query and a "wrapper" program to create a file then, technically, you don't have to go through spool. Query is generated as an ABAP report too, so technically you could just run it from a program, read the created list from memory and then create Excel thus avoiding all the spool overhead. Use Google.

former_member208541
Participant
0 Kudos

Thanks Jelena. My ABAP resource says that it is not possible to create an Excel from Spool. Only PDF can be created from Spool.

Pls can you advise which is the optimum way to create an excel sheet. we need to store excel sheet ina directory. I have heard that excel sheet will not come in proper format ?

rgds

sachin

Jelena
Active Contributor
0 Kudos

sachin.arora4 - Google -> "read spool into internal table site:sap.com" -> hundreds of hits.

Sorry, I don't understand the inquiry about "excel sheet". Sheet is part of a worksheet in Excel and the whole worksheet is written into a file.

I'd suggest to get a knowledgeable ABAP consultant on this. It's not a matter of a quick SCN question. Please also note Sandra's answer.

DoanManhQuynh
Active Contributor
0 Kudos

sachin.arora4 : not possible to direct convert from spool to excel, but like Jelena said first read spool then use it to create excel, then it posssible. Anw, the solution provided by Sandra is much more better.