Skip to Content
Author's profile photo Former Member

Program to extract any ALV in background to Excel

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

Image.png

Then in the second select options we enter the variants with which we want each run of the program to be executed

Image.png

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.

Image.png

Then once we execute we have a file that looks like this:Image.png

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.

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ivan Femia
      Ivan Femia

      Hi Jamie Hentall MacCuish,

      abap2xlsx project is shared on github (www.abap2xlsx.org) and it is supposed to be in a stable version.

      Best

      Ivan

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Ivan,

      Yes I know I have downloaded it and got halfway through the installation process before being called away by other priorities. As I said I'd like to add xlsx to the program using this project but I still thought this little program I'm sharing could be useful to someone as it allows functional colleges to run any alv report in the background and extract the data in an excel openable format without knowing any ABAP. As far as I understand the abap2xlsx project offers some really powerful classes to work with xlsx documents but I wasn't aware it offered a pre-built program to extract ALVs to xlsx in the background but I am only going by what I've read as I haven't finished installing it yet. Either way, I'm guessing it would be a relatively straightforward task to build a program along similar lines exporting the list to memory and then emailing the results or saving them to the server but using abap2xlsx instead of xml for excel.

      Jamie.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      I just releasied that your one of the owners of the abap2xlsx project. So I just wanted to add thanks for developing what looks like a really nice add on. I look forward to using it.

      Author's profile photo Former Member
      Former Member

      This is exactly what I was just looking for.

      Made a quick test and it worked, many thanks.

      Author's profile photo Magdalena Czatrowska
      Magdalena Czatrowska

      I was looking for sth like this exactly! Thank you very much! 🙂

      Author's profile photo Former Member
      Former Member

      Thanx a lot! It works great!!!

      Author's profile photo Ann-Sophie Nollet
      Ann-Sophie Nollet

      Nice program!!! Thanks a lot!!! 🙂

      Author's profile photo Jochen Müller
      Jochen Müller

      Hi Jamie

      that looks very interesting!

      You write "Anyway, for anyone whose interested the code is attached as three text files" but I am unable to identify these - is that due to the SCN Changes that attachments are lost or am I just overlooking something so that I don´t find the mentioned attachments?

      Thanks in advance for sharing the solution!
      Jochen

      Author's profile photo Former Member
      Former Member

      Like Jochen, I too would be interested in this functionality but I don't see any attachments which can be downloaded.

      Thanks
      Charles 

      Author's profile photo Former Member
      Former Member

      Hi Can anyone please share this code . I do not see any code attached in this blog.

      Author's profile photo Alexandre Pereira
      Alexandre Pereira

      Hi.
      Is there a way to share this coding ?
      I am needing something like this.
      Thanks.

      Author's profile photo Roshan Mathew
      Roshan Mathew

      Could you please share the code.. I am not able to find the attached files !

      Author's profile photo Former Member
      Former Member

      is it possible to have the code of ZSP_BOREPORT   ?

       

      Thanks a lot