ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Streaming → Streaming for Data Objects
Streaming for Strings
The specific classes for streaming for strings are:
- CL_ABAP_STRING_C_READER
- CL_ABAP_STRING_C_WRITER
- CL_ABAP_STRING_X_READER
- CL_ABAP_STRING_X_WRITER
These classes are subclasses of the abstract superclasses CL_ABAP_MEMORY_....
Other versions: 7.31 | 7.40 | 7.54
Example
A writer stream is used to fill a string and then pass it to a reader stream. The reader stream skips three characters and then reads the remaining characters.
DATA: string_writer TYPE REF TO cl_abap_string_c_writer,
string_reader TYPE REF TO if_abap_c_reader.
DATA snippet TYPE c LENGTH 1.
CREATE OBJECT string_writer TYPE cl_abap_string_c_writer.
DO 10 TIMES.
string_writer->write( |{ sy-index - 1 }| ).
ENDDO.
string_writer->close( ).
CREATE OBJECT string_reader TYPE cl_abap_string_c_reader
EXPORTING
str = string_writer->get_result_string( ).
string_reader->skip( 3 ).
WHILE string_reader->data_available( ) = 'X'.
snippet = string_reader->read( 1 ).
cl_demo_output=>write( snippet ).
ENDWHILE.
string_reader->close( ).
cl_demo_output=>display( ).