Application Development and Automation 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: 
Read only

Read Data FILE .gz from SERVER

4,173

Dear SAP Experts,

Do you know whether exist a functionality within SAP to "unzip" a .gz file extension?

In the Server, we have compress files with this extension and we have to develop a new custom program "unzip" the files and read data.

Best Regards and thanks in advance for your ideas.

Dear SAP Experts,

Do you know whether exist a functionality within SAP to "unzip" a .gz file extension?

In the Server, we have compress files with this extension and we have to develop a new custom program "unzip" the files and read data.

Best Regards and thanks in advance for your ideas.

7 REPLIES 7
Read only

FredericGirod
Active Contributor
3,521

Do you have test CL_ABAP_UNGZIP_TEXT_STREAM?

Read only

joltdx
Active Contributor
3,521

Hi!

Frederic suggested CL_ABAP_UNGZIP_TEXT_STREAM. That should work, but seems a bit tricky.

There is also CL_ABAP_GZIP:

Class CL_ABAP_GZIP Functionality

This class enables you to perform data compression with the DEFLATE algorithm as well as create and decode GZIP files.

The DEFLATE algorithm is used in different file formats, including GZIP and ZIP for data compression.

The following methods enable you to compress or decompress texts (as C strings or C fields) or binary data (as X strings or X fields) using the DEFLATE algorithm.

  • COMPRESS_TEXT
  • COMPRESS_BINARY
  • DECOMPRESS_TEXT
  • DECOMPRESS_BINARY

The following methods create or decode GZIP files in accordance with the format specification in RFC 1952, and allow you to access the relevant fields there.

  • COMPRESS_BINARY_WITH_HEADER
  • DECOMPRESS_BINARY_WITH_HEADER

The class can be used to create and decode ZIP files. One of the main differences between ZIP files and GZIP files is that ZIP files can contain multiple compressed files.

Further information

For further information, refer to the individual methods.

Read only

0 Likes
3,521

Hi, plz let me know if you have implemented the process, I have to do same for my project.

Appreciate your help and suggestion.

Read only

3,521

Hi,

I've solved with the simple code:

OPEN DATASET lv_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT FILTER 'uncompress'.

After this , u can do the READ DATASET:

DO.
READ DATASET lv_fname INTO l_content.

..

ENDDO.

Best Regards.

Read only

0 Likes
3,521

Thank you so much will check and update the status.

Read only

0 Likes
3,521

I tried using below code but variable V_DATA is showing blank no data.

DATA: rv_file(80) TYPE C,

v_data(150) TYPE c.

rv_file = '/shared/ecd/evnt/processed/old/evntarz20210402031000odr3.dat.gz'.

OPEN DATASET rv_file FOR INPUT IN TEXT MODE ENCODING DEFAULT FILTER 'uncompress'.

IF sy-subrc = 0.

DO.

READ DATASET rv_file INTO v_data.

ENDDO.

write: 'success'.

ENDIF.

Note: if v_data is declared XSTRING the program is going to dump

Read only

0 Likes
3,521

My file is in .DAT.GZ I tried using below syntax using BINARY mode

OPEN DATASET rv_file FOR INPUT IN BINARY MODE FILTER 'uncompress'.

in READ statement V_DATA is showing with '#########' and program is terminating.