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: 

Zip PDF files for BSP response

Former Member
0 Kudos

Hello,

We have a BSP app that downloads PDF files to the client side. The PDF data is generated by using the FM CONVERT_OTF_2_PDF. Since these PDF files are large, we would like to compress them with some zip utility. Any ideas how this can be done?

Regards

Cerish

1 ACCEPTED SOLUTION

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The ICM should automatically apply GZip compression to the object before it is transmitted via HTTP based upon the mime type. So really you are getting compression already.

There are ABAP classes that are availble for zip compression of data stream (CL_ABAP_GZIP). However this only performs the compression. This does not create a ZIP file (multiple objects in one stream with a package header and CRC).

However in 640 (SP14 I believe) SAP is going to deliver a class (CL_ABAP_ZIP) to create full blown ZIP files. With the right Kernel release it will even do CRC checks in the Kernel instead of ABAP.

7 REPLIES 7

eddy_declercq
Active Contributor
0 Kudos

Hi, class CL_ABAP_GZIP is the way to go.

Check also note 616958.

Thomas uses it in weblog

/people/thomas.jung3/blog/2004/12/15/bsp-developers-journal-part-xvi--using-the-btf-editor

Eddy

former_member182371
Active Contributor
0 Kudos

hi,

search for topic "

Extract file from http://...zip into ABAP

" in the forum. There you´ll fin an example.

Best regards.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The ICM should automatically apply GZip compression to the object before it is transmitted via HTTP based upon the mime type. So really you are getting compression already.

There are ABAP classes that are availble for zip compression of data stream (CL_ABAP_GZIP). However this only performs the compression. This does not create a ZIP file (multiple objects in one stream with a package header and CRC).

However in 640 (SP14 I believe) SAP is going to deliver a class (CL_ABAP_ZIP) to create full blown ZIP files. With the right Kernel release it will even do CRC checks in the Kernel instead of ABAP.

0 Kudos

Hi Thomas,

Do we need to do any config to enable compression by the ICM. Also, if this is enabled, does it mean that is no advantage to be gained by zipping a file before downloading it?

It is great to know about CL_ABAP_ZIP, but we are on 620 and 640 seems far far way. However, our SRM Systems are on 640 and they have a class cl_doc_zipper that they use to create zip files. But this class is attached to a BPP package, not a general basis one.

Regards

Cerish

Regards

0 Kudos

>Do we need to do any config to enable compression by the ICM

Overall no. For this content - maybe. Are you using a cached response or sending the ZIP file back in the current response. I would think that if you are using a cached response the ICM would apply its MIME logic and compress. If it is the current response then worst case it might use the compression setting on your current page (which you could always go ahead and set).

>does it mean that is no advantage to be gained by zipping a file before downloading it?

Yes this does mean you might not receive any further compression. However the ZIP file has advantages (multiple inner files, the browser doesnt' have to decompress the content upon receipt, the file stays compressed on the user's disk, etc).

CL_ABAP_ZIP might be coming to 620 as well. I only know of the 640 release SP. I looked and I don't see anything in the code that off hand would exclude it from working in 620 so it is likely that you will see it there as well.

0 Kudos

I should have mentioned this. SP14 isn't out yet. It is schedule for the 40th week (beginning of October). So don't be discuraged if you don't see it in your 620 system. If it will be delivered for 620 I would imagine it would make a support package at about the same time as 640.

Former Member
0 Kudos

Hi,

I ported the CL_DOC_ZIPPER class to R/3 620. This will create the Zip file correctly with all the admin data. However the class does not compress the file in any form.

I tried running the data stream through the GZIP class to compress before passing it through the zipper. Winzip opens the archive but cannot open the compressed file.

So I am at a stuck. Any ideas on how to get compression to work?

In case anybody wants the code to create the archive I have attached it below.

report zcjctest.

parameters:

spool type rspoid default '44696'.

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

class :

lcl_doc_zipper definition deferred,

lcl_doc_ostream definition deferred,

lcl_doc_crc32 definition deferred,

lcl_doc_zip_item definition deferred.

types :

bbpt_raw4 type table of raw4,

bbpt_att_cont type sdokcntbins,

bbps_zip_components type zzip_component,

bbpt_zip_components type table of zzip_component,

bbp_doc_y_zip_item type ref to lcl_doc_zip_item,

bbp_doc_yt_zip_item type table of bbp_doc_y_zip_item.

----


  • class lcl_doc_zip_item DEFINITION

----


class lcl_doc_zip_item definition

final

create public .

public section.

data m_name type string .

data m_time type i value 747605219 .

data m_crc type i value -1 .

data m_size type i value -1 .

data m_csize type i value -1 .

data m_method type i value 0 .

data m_flag type i .

data m_version type i .

data m_offset type i .

data m_typefolder type xfeld .

methods constructor

importing

i_name type string

i_reldir type string .

methods get_crc

exporting

e_crc type i .

methods get_method

exporting

e_method type i .

methods set_crc

importing

i_crc type i .

methods set_method

importing

i_method type i .

methods get_name .

methods set_time

importing

i_time type i .

methods get_time

exporting

e_time type i .

methods set_size

importing

i_size type i .

methods set_size_numc

importing

i_size type sdok_fsize .

methods get_size

exporting

e_size type i .

methods get_size_numc

exporting

e_size type sdok_fsize .

methods set_csize

importing

i_csize type i .

methods set_csize_numc

importing

i_csize type sdok_fsize .

methods get_csize

exporting

e_csize type i .

methods get_csize_numc

exporting

e_csize type sdok_fsize .

methods get_typefolder

exporting

e_typefolder type xfeld .

endclass. "lcl_doc_zip_item DEFINITIO

----


  • class llcl_doc_zip_item IMPLEMENTATION

----


class lcl_doc_zip_item implementation.

method constructor .

m_name = i_name.

if i_reldir = 'PHILIPPSTEVES'.

m_typefolder = 'X'.

endif.

endmethod. "lcl_doc_zip_item

method get_crc .

e_crc = m_crc.

endmethod. "get_crc

method get_method .

e_method = m_method.

endmethod. "get_method

method set_crc .

m_crc = i_crc.

endmethod. "set_crc

method set_method .

m_method = i_method.

endmethod. "set_method

method get_name .

endmethod. "get_name

method set_time .

m_time = i_time.

endmethod. "set_time

method get_time .

e_time = m_time.

endmethod. "get_time

method set_size .

m_size = i_size.

endmethod. "set_size

method set_size_numc .

m_size = i_size.

endmethod. "set_size_numc

method get_size .

e_size = m_size.

endmethod. "get_size

method get_size_numc .

e_size = m_size.

endmethod. "get_size_numc

method set_csize .

m_csize = i_csize.

endmethod. "set_csize

method set_csize_numc .

m_csize = i_csize.

endmethod. "set_csize_numc

method get_csize .

e_csize = m_csize.

endmethod. "get_csize

method get_csize_numc .

e_csize = m_csize.

endmethod. "get_csize_numc

method get_typefolder .

e_typefolder = m_typefolder.

endmethod. "get_typefolder

endclass. "lcl_doc_zip_item IMPLEMENTATIO

----


  • class lcl_doc_crc32 DEFINITIO

----


class lcl_doc_crc32 definition

final

create public .

public section.

constants c_hex1 type raw4 value '000000FF'. "#EC NOTEXT

constants c_hex2 type raw4 value 'FFFFFFFF'. "#EC NOTEXT

class-data mt_crc_tab type bbpt_raw4 .

class-methods get_instance

exporting

er_instance type ref to lcl_doc_crc32 .

methods get_crc32

importing

it_data type bbpt_att_cont

i_length type sdok_fsize

exporting

value(e_crc32) type i .

private section.

class-data mr_instance type ref to lcl_doc_crc32 .

class-methods get_crctab .

endclass. "lcl_doc_crc32 DEFINITIO

----


  • class lcl_doc_crc32 IMPLEMENTATION

----


class lcl_doc_crc32 implementation.

method get_instance .

if mr_instance is initial.

create object mr_instance.

get_crctab( ).

endif.

er_instance = mr_instance.

endmethod. "get_instance

method get_crc32 .

data:

l_index type sy-index,

l_offset type i,

l_length type i,

l_startlength type i,

l_crc32 type raw4 value c_hex2,

l_temp1 type raw4,

l_temp2 type raw4,

l_temp3 type x,

l_xstr type xstring,

ls_data type sdokcntbin.

loop at it_data into ls_data.

concatenate l_xstr ls_data-line into l_xstr in byte mode.

endloop.

l_startlength = i_length.

l_length = i_length.

while l_length > 0.

l_temp1 = l_crc32.

shift l_temp1 right in byte mode.

l_offset = l_startlength - l_length.

l_crc32 = l_crc32 bit-and c_hex1.

l_temp3 = l_crc323(1) bit-xor l_xstrl_offset(1).

l_index = l_temp3.

l_index = l_index + 1.

read table mt_crc_tab into l_temp2 index l_index.

l_crc32 = l_temp1 bit-xor l_temp2.

l_length = l_length - 1.

endwhile.

l_crc32 = l_crc32 bit-xor c_hex2.

e_crc32 = l_crc32.

endmethod. "get_crc32

method get_crctab .

data:

l_int type raw4.

if mt_crc_tab is not initial.

exit.

endif.

l_int = '00000000'. append l_int to mt_crc_tab.

l_int = '77073096'. append l_int to mt_crc_tab.

l_int = 'EE0E612C'. append l_int to mt_crc_tab.

l_int = '990951BA'. append l_int to mt_crc_tab.

l_int = '076DC419'. append l_int to mt_crc_tab.

l_int = '706AF48F'. append l_int to mt_crc_tab.

l_int = 'E963A535'. append l_int to mt_crc_tab.

l_int = '9E6495A3'. append l_int to mt_crc_tab.

l_int = '0EDB8832'. append l_int to mt_crc_tab.

l_int = '79DCB8A4'. append l_int to mt_crc_tab.

l_int = 'E0D5E91E'. append l_int to mt_crc_tab.

l_int = '97D2D988'. append l_int to mt_crc_tab.

l_int = '09B64C2B'. append l_int to mt_crc_tab.

l_int = '7EB17CBD'. append l_int to mt_crc_tab.

l_int = 'E7B82D07'. append l_int to mt_crc_tab.

l_int = '90BF1D91'. append l_int to mt_crc_tab.

l_int = '1DB71064'. append l_int to mt_crc_tab.

l_int = '6AB020F2'. append l_int to mt_crc_tab.

l_int = 'F3B97148'. append l_int to mt_crc_tab.

l_int = '84BE41DE'. append l_int to mt_crc_tab.

l_int = '1ADAD47D'. append l_int to mt_crc_tab.

l_int = '6DDDE4EB'. append l_int to mt_crc_tab.

l_int = 'F4D4B551'. append l_int to mt_crc_tab.

l_int = '83D385C7'. append l_int to mt_crc_tab.

l_int = '136C9856'. append l_int to mt_crc_tab.

l_int = '646BA8C0'. append l_int to mt_crc_tab.

l_int = 'FD62F97A'. append l_int to mt_crc_tab.

l_int = '8A65C9EC'. append l_int to mt_crc_tab.

l_int = '14015C4F'. append l_int to mt_crc_tab.

l_int = '63066CD9'. append l_int to mt_crc_tab.

l_int = 'FA0F3D63'. append l_int to mt_crc_tab.

l_int = '8D080DF5'. append l_int to mt_crc_tab.

l_int = '3B6E20C8'. append l_int to mt_crc_tab.

l_int = '4C69105E'. append l_int to mt_crc_tab.

l_int = 'D56041E4'. append l_int to mt_crc_tab.

l_int = 'A2677172'. append l_int to mt_crc_tab.

l_int = '3C03E4D1'. append l_int to mt_crc_tab.

l_int = '4B04D447'. append l_int to mt_crc_tab.

l_int = 'D20D85FD'. append l_int to mt_crc_tab.

l_int = 'A50AB56B'. append l_int to mt_crc_tab.

l_int = '35B5A8FA'. append l_int to mt_crc_tab.

l_int = '42B2986C'. append l_int to mt_crc_tab.

l_int = 'DBBBC9D6'. append l_int to mt_crc_tab.

l_int = 'ACBCF940'. append l_int to mt_crc_tab.

l_int = '32D86CE3'. append l_int to mt_crc_tab.

l_int = '45DF5C75'. append l_int to mt_crc_tab.

l_int = 'DCD60DCF'. append l_int to mt_crc_tab.

l_int = 'ABD13D59'. append l_int to mt_crc_tab.

l_int = '26D930AC'. append l_int to mt_crc_tab.

l_int = '51DE003A'. append l_int to mt_crc_tab.

l_int = 'C8D75180'. append l_int to mt_crc_tab.

l_int = 'BFD06116'. append l_int to mt_crc_tab.

l_int = '21B4F4B5'. append l_int to mt_crc_tab.

l_int = '56B3C423'. append l_int to mt_crc_tab.

l_int = 'CFBA9599'. append l_int to mt_crc_tab.

l_int = 'B8BDA50F'. append l_int to mt_crc_tab.

l_int = '2802B89E'. append l_int to mt_crc_tab.

l_int = '5F058808'. append l_int to mt_crc_tab.

l_int = 'C60CD9B2'. append l_int to mt_crc_tab.

l_int = 'B10BE924'. append l_int to mt_crc_tab.

l_int = '2F6F7C87'. append l_int to mt_crc_tab.

l_int = '58684C11'. append l_int to mt_crc_tab.

l_int = 'C1611DAB'. append l_int to mt_crc_tab.

l_int = 'B6662D3D'. append l_int to mt_crc_tab.

l_int = '76DC4190'. append l_int to mt_crc_tab.

l_int = '01DB7106'. append l_int to mt_crc_tab.

l_int = '98D220BC'. append l_int to mt_crc_tab.

l_int = 'EFD5102A'. append l_int to mt_crc_tab.

l_int = '71B18589'. append l_int to mt_crc_tab.

l_int = '06B6B51F'. append l_int to mt_crc_tab.

l_int = '9FBFE4A5'. append l_int to mt_crc_tab.

l_int = 'E8B8D433'. append l_int to mt_crc_tab.

l_int = '7807C9A2'. append l_int to mt_crc_tab.

l_int = '0F00F934'. append l_int to mt_crc_tab.

l_int = '9609A88E'. append l_int to mt_crc_tab.

l_int = 'E10E9818'. append l_int to mt_crc_tab.

l_int = '7F6A0DBB'. append l_int to mt_crc_tab.

l_int = '086D3D2D'. append l_int to mt_crc_tab.

l_int = '91646C97'. append l_int to mt_crc_tab.

l_int = 'E6635C01'. append l_int to mt_crc_tab.

l_int = '6B6B51F4'. append l_int to mt_crc_tab.

l_int = '1C6C6162'. append l_int to mt_crc_tab.

l_int = '856530D8'. append l_int to mt_crc_tab.

l_int = 'F262004E'. append l_int to mt_crc_tab.

l_int = '6C0695ED'. append l_int to mt_crc_tab.

l_int = '1B01A57B'. append l_int to mt_crc_tab.

l_int = '8208F4C1'. append l_int to mt_crc_tab.

l_int = 'F50FC457'. append l_int to mt_crc_tab.

l_int = '65B0D9C6'. append l_int to mt_crc_tab.

l_int = '12B7E950'. append l_int to mt_crc_tab.

l_int = '8BBEB8EA'. append l_int to mt_crc_tab.

l_int = 'FCB9887C'. append l_int to mt_crc_tab.

l_int = '62DD1DDF'. append l_int to mt_crc_tab.

l_int = '15DA2D49'. append l_int to mt_crc_tab.

l_int = '8CD37CF3'. append l_int to mt_crc_tab.

l_int = 'FBD44C65'. append l_int to mt_crc_tab.

l_int = '4DB26158'. append l_int to mt_crc_tab.

l_int = '3AB551CE'. append l_int to mt_crc_tab.

l_int = 'A3BC0074'. append l_int to mt_crc_tab.

l_int = 'D4BB30E2'. append l_int to mt_crc_tab.

l_int = '4ADFA541'. append l_int to mt_crc_tab.

l_int = '3DD895D7'. append l_int to mt_crc_tab.

l_int = 'A4D1C46D'. append l_int to mt_crc_tab.

l_int = 'D3D6F4FB'. append l_int to mt_crc_tab.

l_int = '4369E96A'. append l_int to mt_crc_tab.

l_int = '346ED9FC'. append l_int to mt_crc_tab.

l_int = 'AD678846'. append l_int to mt_crc_tab.

l_int = 'DA60B8D0'. append l_int to mt_crc_tab.

l_int = '44042D73'. append l_int to mt_crc_tab.

l_int = '33031DE5'. append l_int to mt_crc_tab.

l_int = 'AA0A4C5F'. append l_int to mt_crc_tab.

l_int = 'DD0D7CC9'. append l_int to mt_crc_tab.

l_int = '5005713C'. append l_int to mt_crc_tab.

l_int = '270241AA'. append l_int to mt_crc_tab.

l_int = 'BE0B1010'. append l_int to mt_crc_tab.

l_int = 'C90C2086'. append l_int to mt_crc_tab.

l_int = '5768B525'. append l_int to mt_crc_tab.

l_int = '206F85B3'. append l_int to mt_crc_tab.

l_int = 'B966D409'. append l_int to mt_crc_tab.

l_int = 'CE61E49F'. append l_int to mt_crc_tab.

l_int = '5EDEF90E'. append l_int to mt_crc_tab.

l_int = '29D9C998'. append l_int to mt_crc_tab.

l_int = 'B0D09822'. append l_int to mt_crc_tab.

l_int = 'C7D7A8B4'. append l_int to mt_crc_tab.

l_int = '59B33D17'. append l_int to mt_crc_tab.

l_int = '2EB40D81'. append l_int to mt_crc_tab.

l_int = 'B7BD5C3B'. append l_int to mt_crc_tab.

l_int = 'C0BA6CAD'. append l_int to mt_crc_tab.

l_int = 'EDB88320'. append l_int to mt_crc_tab.

l_int = '9ABFB3B6'. append l_int to mt_crc_tab.

l_int = '03B6E20C'. append l_int to mt_crc_tab.

l_int = '74B1D29A'. append l_int to mt_crc_tab.

l_int = 'EAD54739'. append l_int to mt_crc_tab.

l_int = '9DD277AF'. append l_int to mt_crc_tab.

l_int = '04DB2615'. append l_int to mt_crc_tab.

l_int = '73DC1683'. append l_int to mt_crc_tab.

l_int = 'E3630B12'. append l_int to mt_crc_tab.

l_int = '94643B84'. append l_int to mt_crc_tab.

l_int = '0D6D6A3E'. append l_int to mt_crc_tab.

l_int = '7A6A5AA8'. append l_int to mt_crc_tab.

l_int = 'E40ECF0B'. append l_int to mt_crc_tab.

l_int = '9309FF9D'. append l_int to mt_crc_tab.

l_int = '0A00AE27'. append l_int to mt_crc_tab.

l_int = '7D079EB1'. append l_int to mt_crc_tab.

l_int = 'F00F9344'. append l_int to mt_crc_tab.

l_int = '8708A3D2'. append l_int to mt_crc_tab.

l_int = '1E01F268'. append l_int to mt_crc_tab.

l_int = '6906C2FE'. append l_int to mt_crc_tab.

l_int = 'F762575D'. append l_int to mt_crc_tab.

l_int = '806567CB'. append l_int to mt_crc_tab.

l_int = '196C3671'. append l_int to mt_crc_tab.

l_int = '6E6B06E7'. append l_int to mt_crc_tab.

l_int = 'FED41B76'. append l_int to mt_crc_tab.

l_int = '89D32BE0'. append l_int to mt_crc_tab.

l_int = '10DA7A5A'. append l_int to mt_crc_tab.

l_int = '67DD4ACC'. append l_int to mt_crc_tab.

l_int = 'F9B9DF6F'. append l_int to mt_crc_tab.

l_int = '8EBEEFF9'. append l_int to mt_crc_tab.

l_int = '17B7BE43'. append l_int to mt_crc_tab.

l_int = '60B08ED5'. append l_int to mt_crc_tab.

l_int = 'D6D6A3E8'. append l_int to mt_crc_tab.

l_int = 'A1D1937E'. append l_int to mt_crc_tab.

l_int = '38D8C2C4'. append l_int to mt_crc_tab.

l_int = '4FDFF252'. append l_int to mt_crc_tab.

l_int = 'D1BB67F1'. append l_int to mt_crc_tab.

l_int = 'A6BC5767'. append l_int to mt_crc_tab.

l_int = '3FB506DD'. append l_int to mt_crc_tab.

l_int = '48B2364B'. append l_int to mt_crc_tab.

l_int = 'D80D2BDA'. append l_int to mt_crc_tab.

l_int = 'AF0A1B4C'. append l_int to mt_crc_tab.

l_int = '36034AF6'. append l_int to mt_crc_tab.

l_int = '41047A60'. append l_int to mt_crc_tab.

l_int = 'DF60EFC3'. append l_int to mt_crc_tab.

l_int = 'A867DF55'. append l_int to mt_crc_tab.

l_int = '316E8EEF'. append l_int to mt_crc_tab.

l_int = '4669BE79'. append l_int to mt_crc_tab.

l_int = 'CB61B38C'. append l_int to mt_crc_tab.

l_int = 'BC66831A'. append l_int to mt_crc_tab.

l_int = '256FD2A0'. append l_int to mt_crc_tab.

l_int = '5268E236'. append l_int to mt_crc_tab.

l_int = 'CC0C7795'. append l_int to mt_crc_tab.

l_int = 'BB0B4703'. append l_int to mt_crc_tab.

l_int = '220216B9'. append l_int to mt_crc_tab.

l_int = '5505262F'. append l_int to mt_crc_tab.

l_int = 'C5BA3BBE'. append l_int to mt_crc_tab.

l_int = 'B2BD0B28'. append l_int to mt_crc_tab.

l_int = '2BB45A92'. append l_int to mt_crc_tab.

l_int = '5CB36A04'. append l_int to mt_crc_tab.

l_int = 'C2D7FFA7'. append l_int to mt_crc_tab.

l_int = 'B5D0CF31'. append l_int to mt_crc_tab.

l_int = '2CD99E8B'. append l_int to mt_crc_tab.

l_int = '5BDEAE1D'. append l_int to mt_crc_tab.

l_int = '9B64C2B0'. append l_int to mt_crc_tab.

l_int = 'EC63F226'. append l_int to mt_crc_tab.

l_int = '756AA39C'. append l_int to mt_crc_tab.

l_int = '026D930A'. append l_int to mt_crc_tab.

l_int = '9C0906A9'. append l_int to mt_crc_tab.

l_int = 'EB0E363F'. append l_int to mt_crc_tab.

l_int = '72076785'. append l_int to mt_crc_tab.

l_int = '05005713'. append l_int to mt_crc_tab.

l_int = '95BF4A82'. append l_int to mt_crc_tab.

l_int = 'E2B87A14'. append l_int to mt_crc_tab.

l_int = '7BB12BAE'. append l_int to mt_crc_tab.

l_int = '0CB61B38'. append l_int to mt_crc_tab.

l_int = '92D28E9B'. append l_int to mt_crc_tab.

l_int = 'E5D5BE0D'. append l_int to mt_crc_tab.

l_int = '7CDCEFB7'. append l_int to mt_crc_tab.

l_int = '0BDBDF21'. append l_int to mt_crc_tab.

l_int = '86D3D2D4'. append l_int to mt_crc_tab.

l_int = 'F1D4E242'. append l_int to mt_crc_tab.

l_int = '68DDB3F8'. append l_int to mt_crc_tab.

l_int = '1FDA836E'. append l_int to mt_crc_tab.

l_int = '81BE16CD'. append l_int to mt_crc_tab.

l_int = 'F6B9265B'. append l_int to mt_crc_tab.

l_int = '6FB077E1'. append l_int to mt_crc_tab.

l_int = '18B74777'. append l_int to mt_crc_tab.

l_int = '88085AE6'. append l_int to mt_crc_tab.

l_int = 'FF0F6A70'. append l_int to mt_crc_tab.

l_int = '66063BCA'. append l_int to mt_crc_tab.

l_int = '11010B5C'. append l_int to mt_crc_tab.

l_int = '8F659EFF'. append l_int to mt_crc_tab.

l_int = 'F862AE69'. append l_int to mt_crc_tab.

l_int = '616BFFD3'. append l_int to mt_crc_tab.

l_int = '166CCF45'. append l_int to mt_crc_tab.

l_int = 'A00AE278'. append l_int to mt_crc_tab.

l_int = 'D70DD2EE'. append l_int to mt_crc_tab.

l_int = '4E048354'. append l_int to mt_crc_tab.

l_int = '3903B3C2'. append l_int to mt_crc_tab.

l_int = 'A7672661'. append l_int to mt_crc_tab.

l_int = 'D06016F7'. append l_int to mt_crc_tab.

l_int = '4969474D'. append l_int to mt_crc_tab.

l_int = '3E6E77DB'. append l_int to mt_crc_tab.

l_int = 'AED16A4A'. append l_int to mt_crc_tab.

l_int = 'D9D65ADC'. append l_int to mt_crc_tab.

l_int = '40DF0B66'. append l_int to mt_crc_tab.

l_int = '37D83BF0'. append l_int to mt_crc_tab.

l_int = 'A9BCAE53'. append l_int to mt_crc_tab.

l_int = 'DEBB9EC5'. append l_int to mt_crc_tab.

l_int = '47B2CF7F'. append l_int to mt_crc_tab.

l_int = '30B5FFE9'. append l_int to mt_crc_tab.

l_int = 'BDBDF21C'. append l_int to mt_crc_tab.

l_int = 'CABAC28A'. append l_int to mt_crc_tab.

l_int = '53B39330'. append l_int to mt_crc_tab.

l_int = '24B4A3A6'. append l_int to mt_crc_tab.

l_int = 'BAD03605'. append l_int to mt_crc_tab.

l_int = 'CDD70693'. append l_int to mt_crc_tab.

l_int = '54DE5729'. append l_int to mt_crc_tab.

l_int = '23D967BF'. append l_int to mt_crc_tab.

l_int = 'B3667A2E'. append l_int to mt_crc_tab.

l_int = 'C4614AB8'. append l_int to mt_crc_tab.

l_int = '5D681B02'. append l_int to mt_crc_tab.

l_int = '2A6F2B94'. append l_int to mt_crc_tab.

l_int = 'B40BBE37'. append l_int to mt_crc_tab.

l_int = 'C30C8EA1'. append l_int to mt_crc_tab.

l_int = '5A05DF1B'. append l_int to mt_crc_tab.

l_int = '2D02EF8D'. append l_int to mt_crc_tab.

endmethod. "get_crctab

endclass. "lcl_doc_crc32 IMPLEMENTATION

----


  • class lcl_doc_ostream DEFINITIO

----


class lcl_doc_ostream definition

create public .

public section.

constants c_line_len type i value 1022. "#EC NOTEXT

methods constructor .

methods write

importing

!it_data type bbpt_att_cont

!i_length type int4 .

methods write_byte

importing

!i_data type x .

methods lclose .

methods get_data

exporting

!et_data type bbpt_att_cont .

methods get_length

exporting

!e_length type int4 .

class-methods tab2xstr

importing

!it_data type table

!i_length type int4

exporting

!e_xstr type xstring .

class-methods xstr2tab

importing

!i_xstr type xstring

exporting

!et_data type table

!e_length type int4 .

private section.

data mt_stream type bbpt_att_cont .

data m_length type i value 0 .

endclass. "lcl_doc_ostream DEFINITIO

----


  • class lcl_doc_ostream IMPLEMENTATION

----


class lcl_doc_ostream implementation.

method constructor .

clear m_length.

refresh mt_stream.

endmethod. "constructor

method write .

data:

l_line_count type i,

l_last_line_len type i,

l_last_line_left type i,

l_xstr type xstring,

lt_data type bbpt_att_cont.

field-symbols:

<ls_data> type bapiconten.

check i_length <> 0.

describe table mt_stream lines l_line_count.

l_last_line_len = m_length mod c_line_len.

if l_line_count = 0 or l_last_line_len = 0.

call method lcl_doc_ostream=>tab2xstr

exporting

it_data = it_data

i_length = i_length

importing

e_xstr = l_xstr.

call method lcl_doc_ostream=>xstr2tab

exporting

i_xstr = l_xstr

importing

et_data = lt_data.

append lines of lt_data to mt_stream.

else.

read table mt_stream assigning <ls_data> index l_line_count.

call method lcl_doc_ostream=>tab2xstr

exporting

it_data = it_data

i_length = i_length

importing

e_xstr = l_xstr.

l_last_line_left = c_line_len - l_last_line_len.

if l_last_line_left >= i_length.

<ls_data>-line+l_last_line_len(i_length)

= l_xstr.

else.

<ls_data>-line+l_last_line_len(l_last_line_left)

= l_xstr(l_last_line_left).

l_xstr = l_xstr+l_last_line_left.

call method lcl_doc_ostream=>xstr2tab

exporting

i_xstr = l_xstr

importing

et_data = lt_data.

append lines of lt_data to mt_stream.

endif.

endif.

m_length = m_length + i_length.

endmethod. "write

method write_byte .

data:

l_line_count type sy-tfill,

l_last_line_len type i,

l_last_line_left type i,

l_xstr type xstring,

lt_data type bbpt_att_cont.

field-symbols:

<ls_data> type bapiconten.

describe table mt_stream lines l_line_count.

l_last_line_len = m_length mod c_line_len.

if l_line_count = 0 or l_last_line_len = 0.

append initial line to mt_stream.

read table mt_stream assigning <ls_data> index sy-tabix.

<ls_data>-line(1) = i_data.

else.

read table mt_stream assigning <ls_data> index l_line_count.

<ls_data>-line+l_last_line_len(1) = i_data.

endif.

m_length = m_length + 1.

endmethod. "write_byte

method lclose .

refresh mt_stream.

clear m_length.

endmethod. "lclose

method get_data .

et_data[] = mt_stream[].

endmethod. "get_data

method get_length .

e_length = m_length.

endmethod. "get_length

method tab2xstr .

data:

l_xstr type xstring.

field-symbols:

<ls_data> type any,

<ls_line> type any.

loop at it_data assigning <ls_data>.

assign component 1 of structure <ls_data> to <ls_line>.

concatenate l_xstr <ls_line> into l_xstr in byte mode.

endloop.

e_xstr = l_xstr(i_length).

endmethod. "tab2xstr

method xstr2tab .

data:

l_times type i,

l_pos type i value 0,

l_last_line_len type i,

l_tab_line_len type i,

lr_type_descr type ref to cl_abap_typedescr,

lr_tab_descr type ref to cl_abap_tabledescr.

field-symbols:

<ls_data> type any,

<ls_line> type any.

e_length = xstrlen( i_xstr ).

lr_type_descr = cl_abap_typedescr=>describe_by_data( et_data ).

lr_tab_descr ?= lr_type_descr.

lr_type_descr = lr_tab_descr->get_table_line_type( ).

l_tab_line_len = lr_type_descr->length.

l_times = e_length div l_tab_line_len.

l_last_line_len = e_length mod l_tab_line_len.

do l_times times.

append initial line to et_data.

read table et_data assigning <ls_data> index sy-tabix.

assign component 1 of structure <ls_data> to <ls_line>.

<ls_line> = i_xstr+l_pos(l_tab_line_len).

l_pos = l_pos + l_tab_line_len.

enddo.

if l_last_line_len <> 0.

append initial line to et_data.

read table et_data assigning <ls_data> index sy-tabix.

assign component 1 of structure <ls_data> to <ls_line>.

<ls_line> = i_xstr+l_pos(l_last_line_len).

endif.

endmethod. "xstr2tab

endclass. "lcl_doc_ostream IMPLEMENTATION

----


  • class lcl_doc_zip_ostream DEFINITIO

----


class lcl_doc_zip_ostream definition

inheriting from lcl_doc_ostream

final

create public .

public section.

methods begin_new_item

changing

cr_item type ref to lcl_doc_zip_item .

methods write_new_item

importing

it_data type bbpt_att_cont

i_length type sdok_fsize .

methods end_new_item .

methods end_zip_stream .

private section.

data m_lclosed type as4flag .

data m_method type i .

data m_finished type as4flag .

data m_written type i .

data mr_zip_item type ref to lcl_doc_zip_item .

data mt_zip_items type bbp_doc_yt_zip_item .

methods write_loc

importing

ir_item type ref to lcl_doc_zip_item .

methods write_cen

importing

ir_item type ref to lcl_doc_zip_item .

methods write_end

importing

i_off type i

i_len type i .

methods write_short

importing

i_short type i .

methods write_long

importing

i_long type i .

methods get_utf8_bytes

importing

i_string type string

exporting

et_data type bbpt_att_cont

e_length type i .

endclass. "lcl_doc_zip_ostream DEFINITIO

----


  • class lcl_doc_zip_ostream IMPLEMENTATIO

----


*

----


class lcl_doc_zip_ostream implementation.

method begin_new_item .

if m_lclosed is not initial.

exit.

endif.

if mr_zip_item is not initial.

call method me->end_new_item.

endif.

if cr_item->m_time = -1.

call method cr_item->set_time( 123 ).

endif.

if cr_item->m_method = -1.

call method cr_item->set_method( m_method ).

endif.

case cr_item->m_method.

when 8.

when 0. " Stored

if cr_item->m_size = -1.

call method cr_item->set_size( cr_item->m_csize ).

elseif cr_item->m_csize = -1.

call method cr_item->set_csize( cr_item->m_size ).

elseif cr_item->m_size <> cr_item->m_csize.

exit.

endif.

cr_item->m_version = 10.

cr_item->m_flag = 0.

endcase.

cr_item->m_offset = m_written.

write_loc( cr_item ).

append cr_item to mt_zip_items.

mr_zip_item = cr_item.

endmethod. "lcl_doc_zip_ostream

method write_new_item .

data: lv_length type i.

lv_length = i_length.

if m_lclosed is not initial.

exit.

endif.

if mr_zip_item is initial.

exit.

endif.

case mr_zip_item->m_method.

when 8.

when 0.

m_written = m_written + lv_length.

call method me->write

exporting

it_data = it_data

i_length = lv_length.

endcase.

endmethod. "write_new_item

method end_new_item .

endmethod. "end_new_item

method end_zip_stream .

if m_lclosed is not initial.

exit.

endif.

if m_finished is not initial.

exit.

endif.

if mr_zip_item is not initial.

call method me->end_new_item.

endif.

  • write central directory

data:

l_off type i,

l_len type i,

lr_item type ref to lcl_doc_zip_item.

l_off = m_written.

loop at mt_zip_items into lr_item.

call method me->write_cen

exporting

ir_item = lr_item.

endloop.

l_len = m_written - l_off.

call method me->write_end

exporting

i_off = l_off

i_len = l_len.

m_finished = 'X'.

endmethod. "end_zip_stream

method write_loc .

data:

lt_data type bbpt_att_cont,

l_length type i.

write_long( 67324752 ).

write_short( ir_item->m_version ).

write_short( ir_item->m_flag ).

write_short( ir_item->m_method ).

write_long( ir_item->m_time ).

write_long( ir_item->m_crc ).

write_long( ir_item->m_csize ).

write_long( ir_item->m_size ).

call method me->get_utf8_bytes

exporting

i_string = ir_item->m_name

importing

et_data = lt_data

e_length = l_length.

write_short( l_length ).

write_short( 0 ).

write( it_data = lt_data i_length = l_length ).

if ir_item->m_typefolder = 'X'.

write_long( 51966 ).

  • write_long( 202 ).

  • write_long( 0 ).

  • write_long( 0 ).

endif.

m_written = m_written + l_length.

endmethod. "write_loc

method write_cen .

data:

lt_data type bbpt_att_cont,

l_length type i.

write_long( 33639248 ).

write_short( ir_item->m_version ).

write_short( ir_item->m_version ).

write_short( ir_item->m_flag ).

write_short( ir_item->m_method ).

write_long( ir_item->m_time ).

write_long( ir_item->m_crc ).

write_long( ir_item->m_csize ).

write_long( ir_item->m_size ).

call method me->get_utf8_bytes

exporting

i_string = ir_item->m_name

importing

et_data = lt_data

e_length = l_length.

write_short( l_length ).

write_short( 0 ).

write_short( 0 ).

write_short( 0 ).

write_short( 0 ).

write_long( 0 ).

write_long( ir_item->m_offset ).

call method me->write

exporting

it_data = lt_data

i_length = l_length.

m_written = m_written + l_length.

endmethod. "write_cen

method write_end .

data:

l_count type sy-tfill.

write_long( 101010256 ).

write_short( 0 ).

write_short( 0 ).

describe table mt_zip_items lines l_count.

write_short( l_count ).

write_short( l_count ).

write_long( i_len ).

write_long( i_off ).

write_short( 0 ).

endmethod. "write_end

method write_short .

data:

l_short(2) type x.

l_short = i_short.

call method me->write_byte

exporting

i_data = l_short+1(1).

call method me->write_byte

exporting

i_data = l_short(1).

m_written = m_written + 2.

endmethod. "write_short

method write_long .

data:

l_long(4) type x.

l_long = i_long.

call method me->write_byte

exporting

i_data = l_long+3(1).

call method me->write_byte

exporting

i_data = l_long+2(1).

call method me->write_byte

exporting

i_data = l_long+1(1).

call method me->write_byte

exporting

i_data = l_long(1).

m_written = m_written + 4.

endmethod. "write_long

method get_utf8_bytes .

call function 'SSFH_STRING_TO_TABUTF8'

exporting

cstr_input_data = i_string

  • CODEPAGE = '4110'

importing

ostr_input_data_l = e_length

tables

ostr_input_data = et_data

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • INTERNAL_ERROR = 2

  • OTHERS = 3

.

endmethod. "get_utf8_bytes

endclass. "lcl_doc_zip_ostream IMPLEMENTATIO

----


  • CLASS lcl_doc_zipper DEFINITIO

----


*

----


class lcl_doc_zipper definition

final

create public .

public section.

methods constructor

importing

iv_base_dir type string optional .

methods zip

importing

it_ostreams type bbpt_zip_components

exporting

e_length type int4

et_content type bbpt_att_cont .

private section.

data m_base_dir type string .

endclass. "lcl_doc_zipper DEFINITIO

----


  • CLASS lcl_doc_zipper IMPLEMENTATION

----


*

----


class lcl_doc_zipper implementation.

method constructor .

if not iv_base_dir is initial.

m_base_dir = iv_base_dir.

endif.

endmethod. "constructor

method zip .

data:

lv_filename type string,

lo_zip_item type ref to lcl_doc_zip_item,

lo_crc32 type ref to lcl_doc_crc32,

lo_zip_ostream type ref to lcl_doc_zip_ostream,

lv_percentage type i,

lv_lines type i,

lv_nr type i,

lv_nr_ch type char255,

lv_lines_ch type char255.

field-symbols:

<ls_ostream> type bbps_zip_components.

create object lo_zip_ostream.

call method lcl_doc_crc32=>get_instance

importing

er_instance = lo_crc32.

lv_lines = lines( it_ostreams ).

loop at it_ostreams assigning <ls_ostream>.

lv_nr = lv_nr + 1.

lv_percentage = lv_nr * 100 / lv_lines.

write lv_nr to lv_nr_ch.

write lv_lines to lv_lines_ch.

if not m_base_dir is initial.

lv_filename = m_base_dir.

endif.

if not <ls_ostream>-realitive_dir is initial

and not <ls_ostream>-realitive_dir cs 'PHILIPPSTEVES'.

if not lv_filename is initial.

concatenate lv_filename

'/'

<ls_ostream>-realitive_dir

into lv_filename.

else.

lv_filename = <ls_ostream>-realitive_dir.

endif.

endif.

if not lv_filename is initial.

concatenate

lv_filename

'/'

<ls_ostream>-filename

into lv_filename.

else.

lv_filename = <ls_ostream>-filename.

endif.

create object lo_zip_item

exporting

i_name = lv_filename

i_reldir = <ls_ostream>-realitive_dir.

lo_zip_item->set_size_numc( <ls_ostream>-docsize ).

lo_zip_item->set_csize_numc( <ls_ostream>-docsize ).

lo_zip_item->set_time( -1 ).

call method lo_crc32->get_crc32

exporting

it_data = <ls_ostream>-content

i_length = <ls_ostream>-docsize

importing

e_crc32 = lo_zip_item->m_crc.

call method lo_zip_ostream->begin_new_item

changing

cr_item = lo_zip_item.

lo_zip_ostream->write_new_item(

it_data = <ls_ostream>-content

i_length = <ls_ostream>-docsize ).

free lo_zip_item.

clear lv_filename.

endloop.

lo_zip_ostream->end_zip_stream( ).

call method lo_zip_ostream->get_length

importing

e_length = e_length.

call method lo_zip_ostream->get_data

importing

et_data = et_content.

endmethod. "zip

endclass. "lcl_doc_zipper IMPLEMENTATION

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

start-of-selection.

data :

l_output type string,

l_outputx type xstring,

l_outputb type xstring,

l_pdf_len type i,

it_pdf type table of tline with header line.

call function 'CONVERT_OTFSPOOLJOB_2_PDF'

exporting

src_spoolid = spool

tables

pdf = it_pdf

exceptions

err_no_otf_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_dstdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

others = 12.

if sy-subrc <> 0.

endif.

call method cl_gui_frontend_services=>gui_download

exporting

filename = 'C:\File.pdf'

filetype = 'BIN'

changing

data_tab = it_pdf[].

  • Call Function module to convert the PDF data to string

call function 'CONVERT_TABLE_TO_STRING'

exporting

i_tabline_length = 134

importing

e_string = l_output

tables

it_table = it_pdf.

*Call function module to convert the Character String to Binary String

call function 'SCMS_STRING_TO_XSTRING'

exporting

text = l_output

importing

  • buffer = l_outputb.

buffer = l_outputx.

  • call method cl_abap_gzip=>compress_binary

  • exporting

  • raw_in = l_outputb

  • compress_level = 9

  • importing

  • gzip_out = l_outputx.

data:

lv_current_length type i,

ls_content type sdokcntbin,

lt_zip_file type sdokcntbins,

ls_zip_content type sdokcntbin,

ls_zip_entry type bbps_zip_components,

lt_zip_entries type bbpt_zip_components.

field-symbols <fs_line> type x.

ls_zip_entry-mime_type = 'text/xml'.

ls_zip_entry-filename = 'test.pdf'.

ls_zip_entry-docsize = xstrlen( l_outputx ).

refresh ls_zip_entry-content.

lv_current_length = xstrlen( l_outputx ).

while lv_current_length > 1022.

assign ls_content to <fs_line> casting type x.

move l_outputx(1022) to <fs_line>.

append ls_content to ls_zip_entry-content.

shift l_outputx by 1022 places in byte mode.

lv_current_length = xstrlen( l_outputx ).

endwhile.

if lv_current_length > 0.

assign ls_content to <fs_line> casting type x.

move l_outputx to <fs_line>.

append ls_content to ls_zip_entry-content.

endif.

append ls_zip_entry to lt_zip_entries.

  • Make zip stream

data lo_zipper type ref to lcl_doc_zipper.

create object lo_zipper.

call method lo_zipper->zip

exporting

it_ostreams = lt_zip_entries

importing

et_content = lt_zip_file.

  • Download file

call method cl_gui_frontend_services=>gui_download

exporting

filename = 'C:\File.zip'

filetype = 'BIN'

changing

data_tab = lt_zip_file.