没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
ABAP Class to gzip and gunzip
© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com
1
Applies To:
SAP R/3 4.7 and above
Summary
ABAP Implementation of GZIP
By: Otto Frost
Company: Capgemini
Date: 17 March 2006
GZIP / GUNZIP
The zcl_abap_gzip ABAP class implements gzip and gunzip as described in RFC 1952 - GZIP file format
specification version 4.3
http://www.faqs.org/rfcs/rfc1952.html.
Gzip/Gunzip is a lossless compressed data format that
• Is independent of CPU type, operating system, file system, and character set, and hence can be
used for interchange
• Can compress or decompress a data stream (as opposed to a randomly accessible file) to
produce another data stream, using only an a priori bounded amount of intermediate storage, and
hence can be used in data communications or similar structures such as Unix filters
• Compresses data with efficiency comparable to the best currently available general-purpose
compression methods, and in particular considerably better than the "compress" program
• Can be implemented readily in a manner not covered by patents, and hence can be practiced
freely
• Is compatible with the file format produced by the current widely used gzip utility, in that
conforming decompressors will be able to read data produced by the existing gzip compressor.
The zcl_abap_gzip ABAP class is intended for use by implementers of software to compress data into gzip
format and/or decompress data from gzip format.
If you need more information about gzip, try a google search. On a unix box the command "man gzip" or
"gzip --help" may work too. On windows gzip is available in the CygWin package from RedHat. On
http://www.gnu.org/ you should be able to find a manual for gzip.
Example code
ABAP Class to gzip and gunzip
© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com
1
* You may use gui_upload and gui_download to
* transfer the data in binary mode, but that is not included
* in this example. This example first executes ungzip
* and then gzip. Normally you would use gzip or ungzip, not both.
* This example is also available in the method example.
DATA xstringin TYPE xstring.
DATA xstringout TYPE xstring.
DATA file TYPE zcl_abap_gzip=>t_file.
DATA obj TYPE REF TO zcl_abap_gzip.
CREATE OBJECT obj.
* file without filename with content AAAAAA
xstringin = '1F8B0800FBAF0D44020373740401007EDE1CAA06000000'.
* a gzipped file with filename testa.txt, with content AAAAAA and a char with hex val x0A
xstringin = '1F8B0808B4331044020374657374612E74787400737404012E007646C08507000000'.
xstringout = obj->gunzip( gzip_in = xstringin ) ..
file = obj->get_file_attributes( ).
if obj->get_error( ) <> 0.
* error hadnling code.
endif.
xstringin = xstringout. " content AAAAAA and a char with hex val x0A
CREATE OBJECT obj.
obj->set_name( name = file-name ).
obj->set_compress_level( 9 ).
xstringout = obj->gzip( raw_in = xstringin ).
if obj->get_error( ) <> 0.
* error hadnling code.
endif.
(The cl_abap_gzip handle deflate/inflate/compression, but not member header and trailer
in the gzip format. See RFC 1952
ABAP class to gzip and gunzip. The
cl_abap_gzip handle deflate, but not head and tail in gzip
format. This sample was developed to be able to process big files in SAP XI. See the example method for
usage.
ABAP Class to gzip and gunzip
© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com
1
Code sample:
CLASS zcl_abap_gzip DEFINITION.
* RFC 1952 - GZIP file format specification version 4.3
* http://www.faqs.org/rfcs/rfc1952.html
* Author: Otto Frost
* Possible improvements
* Check input
* ID1, ID2, has correct values
* Set mtime to processingtime
* Handle CRC16
* Improve Error handling
* Tested with
* gnu gzip/gunzip 1.3.5 under cygwin
* winzip 8.1 SR1 can open the produced file
* Test run on SAP XI 3.0 SP14, on windows platform.
* Function modules gui_upload and gui_download may be used for
* up and download of data
* See example method for how to use the class
PUBLIC SECTION.
TYPE-POOLS abap.
TYPES: t_flg(1) TYPE x.
* flags
CONSTANTS: ftext TYPE i VALUE 0.
CONSTANTS: fhcrc TYPE i VALUE 1.
CONSTANTS: fextra TYPE i VALUE 2.
CONSTANTS: fname TYPE i VALUE 3.
CONSTANTS: fcomment TYPE i VALUE 4.
* flags 5, 6, 7 are reserved
* errors
CONSTANTS: err_invalid_range TYPE i VALUE 1.
CONSTANTS: err_buffer_overflow TYPE i VALUE 2.
CONSTANTS: err_codepage_converter_init TYPE i VALUE 4.
CONSTANTS: err_conversion_codepage TYPE i VALUE 8.
CONSTANTS: err_parameter_invalid_type TYPE i VALUE 16.
CONSTANTS: err_parameter_invalid_range TYPE i VALUE 32.
CONSTANTS: err_xlen TYPE i VALUE 64.
CONSTANTS: err_name TYPE i VALUE 128.
CONSTANTS: err_comment TYPE i VALUE 256.
CONSTANTS: err_gzip TYPE i VALUE 512.
CONSTANTS: err_crc32 TYPE i VALUE 1024.
CONSTANTS: err_out_of_bounds TYPE i VALUE 2048.
CONSTANTS: err_system_exception TYPE i VALUE 4096.
CONSTANTS: err_cm TYPE i VALUE 8192.
CONSTANTS: null(1) TYPE x VALUE '00'.
TYPES:
BEGIN OF t_file,
id1(1) TYPE x,
剩余11页未读,继续阅读
资源评论
- smart07692021-06-28好像没实际用处
ChampaignWolf
- 粉丝: 1702
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 使用 C 语言实现的计算非负整数的阶乘
- 2011-2021最新版本北京大学数字普惠金融指数(PKU-DFIIC).xlsx
- 县域数字乡村指数2018-2020(1).xlsx
- Docker容器配置进阶
- tensorflow-gpu-2.7.4-cp37-cp37m-manylinux2010-x86-64.whl
- 多段线、 圆、弧转多段线(仅我可见)
- tensorflow-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- 李慧琴C语言基础部分.zip
- yeyue-p8Yi4-ve4a83792.apk
- tensorflow-gpu-2.7.3-cp38-cp38-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功