REPORT zpw_alv_multipleline .TYPE-POOLS slis .
*----------------------------------------------------------------------*
* Data Declarations
*----------------------------------------------------------------------*
CONSTANTS : c_len TYPE i VALUE 20 .
TYPES : BEGIN OF ty_t100 ,
sprsl TYPE t100-sprsl ,
arbgb TYPE t100-arbgb ,
msgnr TYPE t100-msgnr ,
text TYPE t100-text ,
fline TYPE t100-text ,
END OF ty_t100 .
TYPES : BEGIN OF ty_wrd ,
text TYPE char20 ,
END OF ty_wrd .
DATA : it_t100 TYPE TABLE OF ty_t100 ,
it_sentence TYPE TABLE OF ty_wrd ,
wa_t100 TYPE ty_t100 ,
wa_word TYPE ty_wrd ,
v_repid TYPE syst-repid ,
v_tabix TYPE syst-tabix .
DATA : it_fld TYPE slis_t_fieldcat_alv ,
it_evt TYPE slis_t_event ,
wa_fld TYPE slis_fieldcat_alv ,
wa_evt TYPE slis_alv_event ,
wa_lay TYPE slis_layout_alv .
*----------------------------------------------------------------------*
* Initialization
*----------------------------------------------------------------------*
INITIALIZATION .
v_repid = sy-repid .
*----------------------------------------------------------------------*
* Start of Selection
*----------------------------------------------------------------------*
START-OF-SELECTION .
* Get some test data to display in ALV List
SELECT * INTO TABLE it_t100
FROM t100
WHERE sprsl = 'EN'
AND arbgb = '00' .
LOOP AT it_t100 INTO wa_t100 .
v_tabix = sy-tabix .
CLEAR : it_sentence .
* Word Wrap the text in multiple lines
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = wa_t100-text
outputlen = c_len
TABLES
out_lines = it_sentence.
IF NOT it_sentence IS INITIAL .
READ TABLE it_sentence INTO wa_word INDEX 1 .
wa_t100-fline = wa_word-text .
MODIFY it_t100 FROM wa_t100 INDEX v_tabix .
ENDIF. ENDLOOP.
* 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 .
* Get event.. we will handle BEFORE and AFTER line output
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
et_events = it_evt.
READ TABLE it_evt INTO wa_evt WITH KEY name = slis_ev_after_line_output .
wa_evt-form = slis_ev_after_line_output .
MODIFY it_evt FROM wa_evt INDEX sy-tabix .
READ TABLE it_evt INTO wa_evt WITH KEY name = slis_ev_top_of_page .
wa_evt-form = slis_ev_top_of_page .
MODIFY it_evt FROM wa_evt INDEX sy-tabix .
wa_lay-no_colhead = 'X' .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = it_fld
is_layout = wa_lay
it_events = it_evt
TABLES
t_outtab = it_t100.
*---------------------------------------------------------------------*
* FORM top_of_page *
*---------------------------------------------------------------------*
FORM top_of_page .
ULINE AT 1(58) .
FORMAT COLOR COL_HEADING .
WRITE: / sy-vline ,
02 'Header1' ,
10 sy-vline ,
11 'Header1' ,
31 sy-vline ,
32 'Header1' ,
37 sy-vline ,
38 'Header1' ,
58 sy-vline .
WRITE: / sy-vline ,
02 'Header2' ,
10 sy-vline ,
11 'Header2' ,
31 sy-vline ,
32 'Header2' ,
37 sy-vline ,
38 'Header2' ,
58 sy-vline .
ENDFORM. "top_of_page
*---------------------------------------------------------------------*
* FORM AFTER_LINE_OUTPUT *
*---------------------------------------------------------------------*
FORM after_line_output USING rs_lineinfo TYPE slis_lineinfo .
CLEAR : it_sentence ,
wa_t100 .
READ TABLE it_t100 INTO wa_t100 INDEX rs_lineinfo-tabindex .
CHECK sy-subrc = 0 .
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = wa_t100-text
outputlen = c_len TABLES
out_lines = it_sentence.
DESCRIBE TABLE it_sentence LINES v_tabix .
CHECK v_tabix > 1 .
LOOP AT it_sentence INTO wa_word FROM 2 .
WRITE: / sy-vline ,
10 sy-vline ,
31 sy-vline ,
37 sy-vline ,
38 wa_word-text ,
58 sy-vline .
ENDLOOP.
ENDFORM . "after_line_output
ALSO READ:
- ALV Header With Logo.
- Including Line After Subtotal In ALV Display.
- ALV Subtotals In Different Blocks.
- ALV With Page Numbers & Subtotals.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
No comments:
Post a Comment