Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  SAP GUI User Dialogs →  General Dynpros →  Screen and Screen Elements →  Screen Elements - Examples 

Dynpros, Text Output

This example demonstrates the output of unformatted text.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA: text       TYPE REF TO cl_demo_text,
          text_table TYPE cl_demo_text=>t_text,
          text_line  TYPE cl_demo_text=>t_line.

    text = cl_demo_text=>new( ).

    text_line = 'First line of text'.
    text->add_line( text_line ).
    text->add_line( ' ' ).
    DO 10 TIMES.
      CLEAR text_line.
      text_line(3) = sy-index.
      text_line  = |Table line { text_line }|.
      APPEND text_line TO text_table.
    ENDDO.
    text->add_table( text_table ).
    text->add_line( ' ' ).
    text_line = 'Last line of text'.
    text->add_line( text_line ).

    text->display( ).

    text->delete( ).
    text->add_line( 'New text' ).
    text->display( ).

Description

The program uses the methods of the class CL_DEMO_TEXT, which was designed for this purpose. The class encapsulates the use of a text edit control in a dialog box.

Wrappers like this can replace the use of the statement WRITE for simple text output.