The standard behavior of ECC when running a ALV report in background of sending the output to spool, which of course can be converted to a html table or plain text file, is slightly frustrating. What most end user would like is the results in a spread sheet. Of course many solutions are possible but the approach I most recently took was to develop a ALV scheduler program by which I mean a program that will run any other program that outputs an ALV and save the ALV contents to an excel readable format. This new program then either saves this content to the server or emails it to a specified address. As the program is quiet versatile, being able to extract any ALV, I thought I could share it as it may be of use to others.
The file format I have used is the xml for excel format and the reason for this choice was the easy integration of this format using the class CL_SALV_EXPORT_DB_STORAGE. Although, xml may not be the first format the springs to mind when you think spreadsheet I found that most users don’t really care as long as the file open with excel and this is what will happen with the xml excel file due to the processing instructions given you have a fairly standard windows setup with office. In the future I would like to add the option to save the output to xlsx using the really nice looking set of classes from abap2xlsx – ABAP Development – SCN Wiki but I’m not sure when it will be finished.
Anyway, for anyone whose interested the code is attached as three text files. One for the main program, one for the top include and one for the forms. I had also wanted to attach a Nugget file generated using SAPlink but I’m getting an error that they content type is not permitted.
So here’s an example of how it works. In this example, I want to run the same program ZSP_BOREPORT twice but with different variants. So I enter my program name twice in the first select options
Then in the second select options we enter the variants with which we want each run of the program to be executed
Then on the rest of the selection screen we specify that we want the output of the different ALVs saved as sheets of one file rather than separate files and also that we want the sheets named after the variants. We also give a name to our file. Finally in the lowest box we specify that we want to save to the server rather than email out the results and we specify the path where we would like the file saved.
Of course the point of this program is not to run it in foreground but to run it in the background. This does add another level of abstraction or complexity as we have to schedule this ALV background program to run other program to extract their data in the background. However, I have found that the slight increase in complexity is more than compensated for by the user friendly format the data comes out in.
That’s about everything. I hope it is of use to someone.