Text output in a window ABAP

In this article, we analyze the task of displaying long text to the user in the form of a pop-up window using FM COPO_POPUP_TO_DISPLAY_TEXTLIST. It makes it possible to display text of arbitrary length to the user, and also has several modes on which the set of buttons in the window depends.

Application of a window with a text block in practice.

The prerequisites for the occurrence of this article were as follows. In the ALV table, firstly, there is no way to display text in a column longer than 255 characters, and our field can be, for example, 300 or 500. Secondly, even if you display a field of 200-250 characters from the table, it will occupy most of the space on the screen, which will reduce user convenience. And even with a field length of 100 characters, there is no point in displaying it, for example, you can replace it with an indicator, and open a long text by clicking on this icon.

A standard message log as an alternative.

If the task is to display the texts of error messages, then you can use standard message log output, which we described earlier, but it has a limit on the length of one line of the message to 200 characters. And at the same time, a message type indicator will be displayed for each row in the column, so this option is not very beautiful for long messages. In the case of a list of messages with a length of up to 200 characters, this is a good option.

Preparation of data for transmission to FM.

Functional module COPO_POPUP_TO_DISPLAY_TEXTLIST also has restrictions on the length of one line, it is 132 characters, this is the maximum length of one line at the output. At the same time, it is not necessary to break the string into substrings of 132 characters each, but you can break it into any length convenient for the task at hand. In this regard, the problem arises of splitting an arbitrary string into substrings of the same length, which was also described in a separate article. That is, the task crashed into converting a long string into a string table and transferring it to the FM. Now let's take a closer look at the capabilities of the functional module.

On our channel in see a detailed discussion of this and other tasks. Subscribe and leave your comments:


  • task - mode of operation of the functional module. Possible modes:
    • 'DISPLAY' - this is a mode for easy viewing, in which there is the ability to quickly jump between pages of text on the screen. Go to the next page, go to the end of the text, to the first page and to the beginning of the text. With any option to close the window FUNCTION = BACK.
    • 'DECIDE' - this is a mode with the buttons "Copy" and "Change". But in fact, the buttons only affect the filling of the parameter FUNCTION. When the "Copy" button is clicked by the user FUNCTION = ACCE, and when you click "Edit" FUNCTION = MODI.
  • title - window title
  • function - code returned by the FM as a result of the dialogue with the user. Depends on the mode and user actions. Return options: BACK, ACCE, MODI.
  • text_table - table with rows for output
    • tdformat - this is a string format. It has two value formats "" и "U1". Где "U1" - highlight text with color.
    • tdline - output line
Assistance to the project on the domain and hosting. Thanks!

Template for displaying text to the user in the drop-down window (detailed articles on hyperlinks):

  lt_text_table TYPE STANDARD TABLE OF tline,
  lv_function TYPE sy-ucomm.
DATA(lv_strlen) = strlen( lv_text ). "lv_text-текст для вывода
"We choose the substrings of how long we split our text
DATA(lv_sep) = 65.
DATA(lv_count) = 0.
WHILE lv_strlen - lv_count > lv_sep.
  DATA(lv_substr) = CONV text132( substring( val = lv_text off = lv_count len = lv_sep ) ).
  APPEND VALUE #( tdline = lv_substr ) TO lt_text_table.
  lv_count = lv_count + lv_sep.

lv_substr = substring( val = lv_text off = lv_count ).
APPEND VALUE #( tdline = lv_substr tdformat = 'U1' ) TO lt_text_table.

    task       = 'DISPLAY' "Options: 'DECIDE' or 'DISPLAY'
    titel      = 'Output window title'
    function   = lv_function
    text_table = lt_text_table.