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: 

Use of CL_ABAP_GZIP_TEXT_STREAM / any examples?

0 Kudos

Hi all,

Am trying to get a very basic gzip streaming example working, taking some example text and hopefully displaying to the screen (for now). Ultimately, looking to write out tabular data to a compressed file.

The ABAP code is based off the example within documentation. When I try to run the code, it throws an exception CX_SY_MISSING_OUTBUF within CL_ABPAP_GZIP_TEXT_STREAM, which I suspect I need to define a little more code relating to the out buffer but am not sure what exactly. Searching online hasn't exposed any leads. Also tried to search for where this module has been used elsewhere (SE80 Where-Used List), but no hits.

Any suggestions, pointers, links or example code would be greatly appreciated.

Thanks,
Jay 🙂

REPORT ZAZLIB.

CLASS user_outbuf DEFINITION.
  PUBLIC SECTION.
    INTERFACES if_abap_gzip_text_handler.
ENDCLASS.

CLASS user_outbuf IMPLEMENTATION.
  METHOD if_abap_gzip_text_handler~use_out_buf.
   WRITE 'Here'.
   WRITE OUT_BUF.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.

DATA: uref       TYPE REF TO user_outbuf.
DATA: csref TYPE REF TO CL_ABAP_GZIP_TEXT_STREAM.

CREATE OBJECT uref.

CREATE OBJECT csref
   EXPORTING  CONVERSION      = 'DEFAULT'
              OUTPUT_HANDLER  = uref.

CALL METHOD  csref->compress_text_stream
    EXPORTING
      TEXT_IN = 'Some text'
      TEXT_IN_LEN = -1.

CALL METHOD  csref->compress_text_stream_end
    EXPORTING  TEXT_IN        = 'Last text'
               TEXT_IN_LEN    = -1.
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

So, the documentation misses SET_OUT_BUF before being able to use COMPRESS_TEXT_STREAM:

DATA: buffer TYPE x LENGTH 1000, " the length you want
      buffer_len TYPE i VALUE -1. " -1 means the total length of buffer

csref->set_out_buf(
      IMPORTING
        out_buf     = buffer
        out_buf_len = buffer_len ).
1 REPLY 1

Sandra_Rossi
Active Contributor
0 Kudos

So, the documentation misses SET_OUT_BUF before being able to use COMPRESS_TEXT_STREAM:

DATA: buffer TYPE x LENGTH 1000, " the length you want
      buffer_len TYPE i VALUE -1. " -1 means the total length of buffer

csref->set_out_buf(
      IMPORTING
        out_buf     = buffer
        out_buf_len = buffer_len ).