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: 

How to Zip the data in an internal table

aaruljothi
Participant
0 Kudos

Hi all,

I have an internal table with some lakhs of records. I am sending that data as an attachment in the mail. Now my mail server has a restriction on the size of file that is sent. So i need to ZIP the data in the internal table before sending it. Is there any function module to do this.

Thanking you'll in advance.

Arul Jothi

7 REPLIES 7

Former Member
0 Kudos

Check this link

0 Kudos

Hi all,

Thankx for ur reply.

I have the data in the internal table. I am using the standard function module SO_DOCUMENT_SEND_API1 to send that internal table data as attachment to a mail receipient. Now before sending the mail i need to compress the data in the internal table.

I must not store that data in the application server.

Arul Jothi

0 Kudos

Hi,

Use extract dataset instead of itab.

The data will be saved in a compressed form in extract dataset..

Regards,

Abdul

0 Kudos

>I must not store that data in the application server.

The example I gave using CL_ABAP_ZIP does not store the data on the application server. When you call method save, the data is only returned as a binary string.

If you have data in an internal table, you probably want to turn it into a single string. You can loop through the internal table and concatenate each row together separated by CL_ABAB_CHAR_UTILITIES=>CR_LF. This single string can then be compressed by CL_ABAP_ZIP.

0 Kudos

>The data will be saved in a compressed form in extract dataset

That will compress the data, but will it put it in a format that can be included as an attachment in an email? The client machine that opens the attachment, must know how to decode the compressed data.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You are going to need to create a ZIP binary stream in memory before you attach it to the mail. You can use the classes CL_ABAP_GZIP, however these only offer compression - not the headers and package information that a client application will need to open the ZIP file.

In recent support packages of WebAS 620 and 640 there is a class called CL_ABAP_ZIP (what release are you on?). This class can create the datasteam that a client application will understand (including the CRC check).

data: zip type ref to cl_abap_zip.
create object zip.
...
 zip->add( name = <wa_dir>-filename
           content = content ).
...
 data: zip_results type xstring.
      zip_results = zip->save( ).

The CL_ABAP_ZIP class returns its content as a binary string. You can reformat this single binary string to a binary internal table (better for passing to any of the email functions as an attachment) using the following function module:


 call function 'SCMS_XSTRING_TO_BINARY'
        exporting
          buffer     = zip_results
        tables
          binary_tab = <wa_doc>-content_hex.

0 Kudos

The IGS can also be used to create a ZIP File. There is an SAP example program, GRAPHICS_IGS_ZIPPER_DEMO, that demonstrates this.