Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Download in background to excel format

Former Member
0 Kudos

Hi Team,

I have a requirement to download data to excel in background.I have around 10 standard or custom reports,  will be scheduled as batch jobs weekly/daily.Spools need to be downloaded to excel format and send it to users , these users dont have SAP access.

Please advice me to achieve this.

Thansk,

Jwala

1 ACCEPTED SOLUTION

Former Member
0 Kudos

One of the possible solutions:

In the report, use a simple WRITE statement, with TAB delimiter between the field. This is normally  done inside a LOOP (of your internal  table of the output data)

Schedule the job with Output Device: ASCIIPRINT AND specify a mail address

That's it - Assuming SAP email system has been configured and setup in the system. Otherwise go to Tcode SCOT to do this.

10 REPLIES 10

Former Member
0 Kudos

One of the possible solutions:

In the report, use a simple WRITE statement, with TAB delimiter between the field. This is normally  done inside a LOOP (of your internal  table of the output data)

Schedule the job with Output Device: ASCIIPRINT AND specify a mail address

That's it - Assuming SAP email system has been configured and setup in the system. Otherwise go to Tcode SCOT to do this.

0 Kudos

Hi Arfah,

Thanks for your response.Some of the reports are standard and ALV.I per my understanding we may not modify each and every standard report for this required.So looking for common solution. Please advise me.

0 Kudos

Yes,the solution still works for standard SAP report (ALV).

Give it a try for a standard SAP report, you will see what I mean:

Schedule a standard SAP report with Output Device: ASCIIPRINT AND specify an email address where you want to send the report to. That's it - Assuming SAP email system has been configured and setup in the system. Otherwise go to Tcode SCOT to do this.

Don't just look the spool created on SP01, but look at the end result: an email with an attachment. Then you just open the attachment with excel.

You also can change the file type to PDF if you want to using Output Device PDFPRINT AND specify an email address where you want to send the report to. (instead of using ASCIIPRINT) .

Email received:

0 Kudos

Hi,

Can we send email to multiple address's here?

0 Kudos

no only one email address, BUT you can create an email group at your mail server (Exchange, Lotus Notes, etc). When you send to that email group address, it automatically send to all the member in the group.

Former Member
0 Kudos

Hi Jwala,

As per my understand :

     Eg 1) In your case you have 3 Std SAP Program and 3 Custom 'Z' Program.

               (Std program is SAP1 SAP2 and SAP3  custom program is Z1 Z2 and Z3)

           2) You need schedule the job every Friday/or every day.

            3) You need download the data XLS sheet.

Am I right?      

          

If am right follow the below mentioned step.

Step 1:  Create one more 'Z' program for download Eg: 'ZJOB_DOWNLOAD'.

Step 2: Get the Spool number of your back ground job from  'TBTCP' table based on program name.

            Eg: Pass Program 'Z1' and 'Date'. and get LISTIDENT (JOB No/List ID).

Step 3: Pass Job number to FM : (RSPO_RETURN_ABAP_SPOOLJOB)

Step 4: You will get list of value of the report to 'BUFFER' internal table.

Step 5: Loop it and pass to you XLS internal table and

Step 6: Download to your desktop using (FM: Gui_download) or (Class : CL_GUI_FRONTEND_SERVICE )

If you use this FM : SO_NEW_DOCUMENT_SEND_API1 you can send XLS sheet as attachment to external mail.

I hope my logic will help you.

Reply me back for further clarification .

Regards,

Akshath.L.T

0 Kudos

Hi Akshath,

I have followed the steps as you mentioned but need help in the step5.I am able to read the spool data to BUFFER internal table. After that I need to format the data where I am facing problem.Please provide if you have any sample code.

Step 5: Loop it and pass to you XLS internal table and

Thanks in advance.

0 Kudos

Hi Jawala,

I hope you got all required value to your buffer internal table.

You this standard program for your reference 'J_1GSPOOL2CD'

Regards,

Akshath.L.T

matt
Active Contributor

I have written a program that reads the spool and converts it to XLSX (the latest Excel format). Use RSPO_RETURN_ABAP_SPOOLJOB to read the spool in text format, use abap2xlsx (and programming!) to get that as an excel spreadsheet: http://wiki.sdn.sap.com/wiki/display/ABAP/abap2xlsx

Abap2xlsx is an easy way of creating proper Excel files, that can also be used in background. All other solutions are makeshift and clunky in comparison and should be disregarded.

Former Member
0 Kudos

Hi Matthew,

Nice development, I will use this when i get any requirement.

Thanks

Aksahth.L.T