cancel
Showing results for 
Search instead for 
Did you mean: 

I got a question about compression of files.

Former Member
0 Kudos

I implemented a file upload and download function in webdynpro abap.

but I think it's too heavy if there's no compression function.

So I've been searching the function but i couldn't find it.

is there anybody who knows the function?

thank you for reading.

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Jong,

I haven't yet worked on this kind of requirement. But there are quite a few classes for zipping & unzipping files. Am pasting them below for you.

CL_ABAP_GZIP                   Class for (De)Compression (GZIP)
CL_ABAP_GZIP_BINARY_STREAM     Class for Data Compression (GZIP, Streaming)
CL_ABAP_GZIP_TEXT_STREAM       Class for Text Compression (GZIP, Streaming)
CL_ABAP_UNGZIP_BINARY_STREAM   Class for Data Decompression (UnGzip, Streaming)
CL_ABAP_UNGZIP_TEXT_STREAM     Class for Text Decompression (UnGzip Text Streaming)
CL_ABAP_ZIP                    Zip Utility
CL_GEOCODER_ZIP5GOLD           Geocoder for zip5gold database
CL_IGS_ZIPPER                  Internet Graphics Service: Zipper
CL_RSRD_CONVERTER_ZIP          Converts Input Stream into a Zip Document
CL_UMC_ZIP_ITEM                ZIP Item
CL_UMC_ZIP_OSTREAM             ZIP Output Stream
IF_ABAP_GZIP_BINARY_HANDLER    IF for Output Buffer Handler
IF_ABAP_GZIP_TEXT_HANDLER      IF for Output Buffer Handler
IF_ABAP_UNGZIP_BINARY_HANDLER  IF for Output Buffer Handler
IF_ABAP_UNGZIP_TEXT_HANDLER    IF for Output Buffer Handler

Also if you can grab the SAP Press book, "Next generation ABAP Development" by Thomas there are a few pages describing how you can achieve the same. He was explaining about how students could fill in their assignments and upload them to the universities portal. It was in this context that he explained about compression techniques in ABAP. I was kind of lazy and skipped reading that part so am not able to explain it myself.... (I hope Thomas isn't reading this!)

Regards,

Uday

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>I was kind of lazy and skipped reading that part so am not able to explain it myself.... (I hope Thomas isn't reading this!)

Caught you! You better hope there won't be a quiz on this topic later.

Former Member
0 Kudos

Are you the Thomas?

lol

Anyway Thank you for all your helps.

regards,

Jong Hwan.

Answers (3)

Answers (3)

Former Member
0 Kudos

I solved the problem.

Thanks

Regards,

Jong.

data: lo_gzip type ref to cl_abap_gzip.

data: content type xstring.

data: content_len type i.

************************************************************************************

************************************************************************************

create object lo_gzip.

node_z009 = wd_context->get_child_node( name = 'Z009' ).

node_z009->get_static_attributes( importing static_attributes = l_z009 ).

wd_context->get_attribute( exporting name = 'DATA' importing value = l_z009-data ).

content_len = strlen( l_z009-data ).

lo_gzip->compress_text( exporting text_in = L_Z009-DATA TEXT_in_len = content_len compress_level = 6

importing gzip_out = content gzip_out_len = l_z009-len ).

L_Z009-DATA = CONTENT.

wd_comp_controller->upload( EXPORTING DATA = l_z009-data LEN = L_Z009-LEN ).

**********************************************************************************************************

  • ANOTHER METHOD

**********************************************************************************************************

DATA: LO_GZIP TYPE REF TO CL_ABAP_GZIP.

DATA: CONTENT TYPE XSTRING.

CREATE OBJECT LO_GZIP.

node_temp_z009 = wd_context->get_child_node( name = 'TEMP_Z009' ).

select * into table lt_temp_z009 from /dogok/009 where id_f = l_z002-id_f and number_f = l_z002-number_f.

LOOP AT LT_TEMP_Z009 INTO L_TEMP_Z009.

CONTENT = L_TEMP_Z009-DATA.

LO_GZIP->DECOMPRESS_TEXT( EXPORTING GZIP_IN = CONTENT GZIP_IN_LEN = L_TEMP_Z009-LEN

IMPORTING TEXT_OUT = L_TEMP_Z009-DATA TEXT_OUT_LEN = L_TEMP_Z009-LEN ).

MODIFY LT_TEMP_Z009 FROM L_TEMP_Z009.

ENDLOOP.

node_temp_z009->bind_table( lt_temp_z009 ).

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You can of course use the CL_ABAP_GZIP or CL_ABAP_ZIP classes to process compressed files from the frontend - but keep in mind that you might not need to actually ZIP the contents. The HTTP protocol automatically uses GZIP based compression during Request/Response transmission. Most data passed back and forth with modern browsers will have transparent compression. You might be able to get slightly better compression ratios by using the a desktop application to ZIP the contents, but the amount will probably be slight.

former_member188831
Contributor
0 Kudos

Hi Jung,

you can check this below code and try to make a zip.

* open (top-)zip-archive
CALL METHOD lo_zip->load
    EXPORTING
      zip             = lv_zip_file_head
    EXCEPTIONS
      zip_parse_error = 1
      OTHERS          = 2.
 
...
* create sub-zip-archives which contain the files you would assign to a folder
...
 
* add sub-zip-archive to top-zip-archive
CALL METHOD lo_zip->add
     EXPORTING
        name    = lv_zip_filename
        content = lv_zip_file.
 
* save zip-archive
CALL METHOD lo_zip->save
    RECEIVING
      zip = ev_zip_file.

or it can be done with

created a compressed zip file with two ways that using interface "cl_igs_zipper" and using interface "cl_abap_zip".

or check this thread too..

[]

all the best...

Reagrds,

Mahesh.Gattu

uday_gubbala2
Active Contributor
0 Kudos

Hi Jong,

This is more of an ABAP problem than a WDA one. Anyways.... Based on OSS note 644640 there is a class CL_ABAP_GZIP included in support package 29 for WAS 6.20. If you are in this package level, you can take a look on this class.

Regards,

Uday