* Here I am attempting to split the alv rows into multiple rows
* depending on the size of the content in the data .
*------------------------------------------------------------------------*
REPORT zalvmultiline .
*------------------------------------------------------------------------*
* TYPE POOLS.
*------------------------------------------------------------------------*
TYPE-POOLS slis .
*------------------------------------------------------------------------*
* TABLES
*------------------------------------------------------------------------*
tables: t100.
*------------------------------------------------------------------------*
* TYPES
*------------------------------------------------------------------------*
*---TYPES FOR THE TABLES
TYPES : BEGIN OF ty_t100 ,
sprsl TYPE t100-sprsl ,
arbgb TYPE t100-arbgb ,
msgnr TYPE t100-msgnr ,
text TYPE t100-text ,
lines TYPE t100-text ,
END OF ty_t100 .
*---TYPES FOR THE NEW WORD
TYPES : BEGIN OF ty_word ,
text TYPE char15 ,
END OF ty_word .
*---INTERNAL TABLES
DATA : it_t100 TYPE TABLE OF ty_t100 ,
it_word TYPE TABLE OF ty_word ,
*---WORK AREAS
wa_t100 TYPE ty_t100 ,
wa_word TYPE ty_word ,
*--VARIABLES
v_repid TYPE syst-repid ,
v_tabix TYPE syst-tabix ,
*---internal tables and workareas for ALVs
it_fieldcat TYPE slis_t_fieldcat_alv ,
it_events TYPE slis_t_event ,
wa_fieldcat TYPE slis_fieldcat_alv ,
wa_events TYPE slis_alv_event .
*------------------------------------------------------------------------*
* selection screen design
*------------------------------------------------------------------------*
select-options:s_arbgb for t100-arbgb.
*------------------------------------------------------------------------*
* initialization.
*------------------------------------------------------------------------*
INITIALIZATION .
v_repid = sy-repid .
*------------------------------------------------------------------------*
* start of selection
*------------------------------------------------------------------------*
START-OF-SELECTION .
PERFORM get_data .
PERFORM process_data.
PERFORM build_fieldcat .
PERFORM display_alv .
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
FORM get_data .
SELECT *
INTO TABLE it_t100
FROM t100
up to 30 rows
WHERE sprsl = 'EN'
AND arbgb in s_arbgb .
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form process_data
*&---------------------------------------------------------------------*
FORM process_data .
LOOP AT it_t100 INTO wa_t100 .
v_tabix = sy-tabix .
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = wa_t100-text
outputlen = 20
TABLES
out_lines = it_word.
IF NOT it_word[] IS INITIAL .
READ TABLE it_word INTO wa_word INDEX 1 .
wa_t100-lines = wa_word-text .
MODIFY it_t100 FROM wa_t100 transporting lines .
ENDIF.
ENDLOOP.
ENDFORM. " process_data
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*&---------------------------------------------------------------------*
FORM build_fieldcat .
CLEAR wa_fieldcat .
wa_fieldcat-fieldname = 'SPRSL' .
wa_fieldcat-tabname = 'T100'.
wa_fieldcat-reptext_ddic = 'Launguage' .
APPEND wa_fieldcat TO it_fieldcat .
CLEAR wa_fieldcat .
wa_fieldcat-fieldname = 'ARBGB' .
wa_fieldcat-tabname = 'T100'.
wa_fieldcat-reptext_ddic = 'Application Area' .
APPEND wa_fieldcat TO it_fieldcat .
CLEAR wa_fieldcat .
wa_fieldcat-fieldname = 'MSGNR' .
wa_fieldcat-tabname = 'T100'.
wa_fieldcat-reptext_ddic = 'Message Number' .
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat .
wa_fieldcat-fieldname = 'LINES' .
wa_fieldcat-outputlen = 20 .
wa_fieldcat-seltext_m = 'Text' .
APPEND wa_fieldcat TO it_fieldcat.
ENDFORM. " build_fieldcat
*&---------------------------------------------------------------------*
*& Form display_alv
*----------------------------------------------------------------------*
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
et_events = it_events.
READ TABLE it_events INTO wa_events WITH KEY name = slis_ev_after_line_output .
wa_events-form = slis_ev_after_line_output .
MODIFY it_events FROM wa_events INDEX sy-tabix .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = it_fieldcat
it_events = it_events
TABLES
t_outtab = it_t100.
ENDFORM. " display_alv
*---------------------------------------------------------------------*
* FORM AFTER_LINE_OUTPUT *
*---------------------------------------------------------------------*
FORM after_line_output USING rs_lineinfo TYPE slis_lineinfo .
CLEAR : it_word ,
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 = 20
TABLES
out_lines = it_word.
DESCRIBE TABLE it_word LINES v_tabix .
CHECK v_tabix > 1 .
LOOP AT it_word INTO wa_word FROM 2 .
WRITE: / sy-vline ,
12 sy-vline,
29 sy-vline,
44 sy-vline,
45 wa_word-text ,
65 sy-vline .
ENDLOOP.
ENDFORM . "AFTER_LINE_OUTPUT
ALSO READ:
- ALV Pop Up To Select The Options & Display Them.
- Example On Blocking ALV List/Grid Display.
- Change The Layout Of The ALV List/Grid Display.
- Add Color In ALV List/Grid Display.
- Use Of Double Click On ALV Grid/List Display.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
No comments:
Post a Comment