Professional Documents
Culture Documents
Sometimes, there is a requirement to set an ALV Column to “wrap word” so that the text gets moved to
the second line if there is too much text for the Column Width. ALV doesn’t provide the functionality to
wrap the texts. That’s why column that has long texts are not get displayed in single instance.
Purpose
The purpose of this document is to provide an option of “wrap word” to ALV functionality.
Identify the length to which the column needs to be wrapped and define a field of same length.
Different columns can be wrapped to different length, and hence logic needs to be modified
accordingly.
For ALV output, data records internal table is defined to populate output. In order to implement
wrap functionality, we need to declare another internal table with the desired wrapped length.
This internal table will contain wrapped texts for the column. Internal table will need to have first
column as identifier to match each record of parent internal table.
Standard Function Module RKD_WORD_WRAP is used to wrap the desired text.
REUSE_ALV_EVENTS_GET is called to get the list of all active events for particular ALV
report output.
Populate appropriate FORM name for the event AFTER_LINE_OUTPUT.
Call function module REUSE_ALV_LIST_DISPLAY to populate report output. ALV List is
used for demonstration.
Implement AFTER_LINE_OUTPUT event among other events for the ALV.
Sample code
REPORT ztest_wordwrap.
TYPE-POOLS slis.
CONSTANTS : c_len TYPE i VALUE 20.
INITIALIZATION .
v_repid = sy-repid .
START-OF-SELECTION .
*Get data
SELECT * INTO TABLE it_t100
FROM t100
WHERE sprsl = 'EN'
AND arbgb = '00' .
*Prepare fieldcatelog
CLEAR wa_fld .
wa_fld-fieldname = 'SPRSL' .
wa_fld-ref_tabname = 'T100' .
wa_fld-ref_fieldname = 'SPRSL' .
APPEND wa_fld TO it_fld . CLEAR wa_fld.
wa_fld-fieldname = 'ARBGB' .
wa_fld-ref_tabname = 'T100' .
wa_fld-ref_fieldname = 'ARBGB' .
APPEND wa_fld TO it_fld . CLEAR wa_fld.
wa_fld-fieldname = 'MSGNR' .
wa_fld-ref_tabname = 'T100' .
wa_fld-ref_fieldname = 'MSGNR' .
APPEND wa_fld TO it_fld . CLEAR wa_fld .
wa_fld-fieldname = 'FLINE' .
wa_fld-inttype = 'CHAR' .
wa_fld-outputlen = 20 .
wa_fld-intlen = 20.
wa_fld-seltext_l = 'Text' .
wa_fld-ddictxt = 'L' .
APPEND wa_fld TO it_fld .
*--------------------------------------------------------------------------------
*FORM AFTER_LINE_OUTPUT *
*--------------------------------------------------------------------------------
CHECK sy-subrc = 0 .