cancel
Showing results for 
Search instead for 
Did you mean: 

Creating an XLS file and Zip it

anand_nidamanuru
Active Participant
0 Kudos

Hi All,

we have a requirement where in we have to create an XLS file from internal table. This xls file then has to be zipped and mailed.

If anyone knows how to create an xls file and zip it in WebDynpro, without using OPEN, CLOSE DATA SET etc, Please let us know. It will be of great help.

Thanks,

Anand

Accepted Solutions (0)

Answers (5)

Answers (5)

uday_gubbala2
Active Contributor
0 Kudos

Hi Anand,

Try out the approach below:

1) Convert the internal table data into string format.

2) Convert the STRING format to XSTRING format by using the FM SCMS_STRING_TO_XSTRING.

3) Use the method COMPRESS_BINARY of class CL_ABAP_GZIP to compress the XSTRING file.

4) Use the method SEND_WEB_MAIL of class CL_HRRCF_SERVICES_MAIL to mail across the zipped contents.

Regards,

Uday

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>2) Convert the STRING format to XSTRING format by using the FM SCMS_STRING_TO_XSTRING.

Actually you should use CL_BCS_CONVERT=>STRING_TO_XSTRING now.

>3) Use the method COMPRESS_BINARY of class CL_ABAP_GZIP to compress the XSTRING file.

You probably want to use CL_ABAP_ZIP instead of CL_ABAP_GZIP. CL_ABAP_GZIP only does compression, which is fine for storing a single packet of data in the database. However CL_ABAP_ZIP is better suited for mult-part zip (multiple inner files).

>4) Use the method SEND_WEB_MAIL of class CL_HRRCF_SERVICES_MAIL to mail across the zipped contents.

This seems to be an HR specific class. Better to use the cross application, NetWeaver provided functionality for sending mail - CL_BCS.

uday_gubbala2
Active Contributor
0 Kudos

Hi Thomas,

Thanks for pitching in. Its pretty scary though that all of my suggestions needed amendments!

Regards,

Uday

ChrisPaine
Active Contributor
0 Kudos

It is also possible to use ( possibly abuse ) the standard ALV export functionality to convert your table into a nicer formatted XLS. This has the benefits of the ALV formatting and using the context to derive headers etc.

[Using WD ABAP ALV export - the hacked way|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/19646] [original link is broken] [original link is broken] [original link is broken];

The code in the linked blog should be able to show you how to do step (1) of Uday's list to produce a nicely formatted XString (so even goes past step 1

I can't say I could recommend this approach - as that's why I put the blog post up there - I'm not sure. But it does work and could be useful in meeting your requirement.

Cheers,

Chris

former_member628395
Active Participant
0 Kudos

Hi,

For ZIP file, you can check the link below.

Link:

[Creating a ZIP File|http://wiki.sdn.sap.com/wiki/display/ABAP/CL_ABAP_ZIPusage-ZippingABAPreportoutput?focusedCommentId=187336343]

Hope this helps.

Regards,

Sagar

Former Member
0 Kudos

This message was moderated.

former_member386434
Discoverer
0 Kudos

This message was moderated.

Sm1tje
Active Contributor
0 Kudos

I'm not quite sure what you mean by 'create an xls file', but you do have UI elements for office. For zipping a file, there is a class with which you can do this. I don't have a system at hand right now, but you should be able to find the class when entering ZIP in SE24 and click F4-help.

By the way, you can create an xls file from an internal table. Search for function module ASMLEXCEL* or something like that. So when displaying this data in a table in WD, and create a button in which data will be downloaded. Or use file upload / download functionality if possible for you.