Code: Alles auswählen.
FORM create_alv TABLES gt_data.
TYPE-POOLS: slis.
DATA: lv_title TYPE lvc_title,
lt_fcat TYPE slis_t_fieldcat_alv,
ls_layout TYPE slis_layout_alv,
lv_from TYPE char10,
lv_to TYPE char10,
lv_tfrom TYPE char8,
lv_tto TYPE char8,
cnt_lin TYPE numc10,
lv_message TYPE string.
FIELD-SYMBOLS: <fs_fcat> TYPE slis_fieldcat_alv.
* Feldkatalog aufbauen
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'Z_CNP_ALV_STRUC'
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = lt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Ausrichtung "zentriert"
LOOP AT lt_fcat ASSIGNING <fs_fcat>.
IF <fs_fcat>-fieldname EQ 'STATUS' OR
<fs_fcat>-fieldname EQ 'STATUS_PLAUS' OR
<fs_fcat>-fieldname EQ 'STATUS_VERS_T' OR
<fs_fcat>-fieldname EQ 'STATUS_VERS_M'.
<fs_fcat>-just = 'C'.
ENDIF.
ENDLOOP.
UNASSIGN <fs_fcat>.
* ggf. Felder ausblenden
IF p_plaus IS INITIAL.
LOOP AT lt_fcat ASSIGNING <fs_fcat>.
IF <fs_fcat>-fieldname EQ 'STATUS_PLAUS' OR
<fs_fcat>-fieldname EQ 'SUMME_CHK' OR
<fs_fcat>-fieldname EQ 'ABW_CHK_PROZ'.
<fs_fcat>-no_out = 'X'.
ENDIF.
ENDLOOP.
UNASSIGN <fs_fcat>.
ENDIF.
* Layout für ALV
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
* ALV anzeigen
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'STATUS_1100'
i_callback_user_command = 'USER_ACTION'
i_grid_title = lv_title
it_fieldcat = lt_fcat
is_layout = ls_layout
TABLES
t_outtab = gt_data
EXCEPTIONS
program_error = 1.
IF sy-subrc <> 0.
MESSAGE 'Fehler bei Listanzeige' TYPE 'I'.
ENDIF.
ENDFORM.
Code: Alles auswählen.
DATA: gv_alv_grid_1100 TYPE REF TO cl_gui_alv_grid,
gv_alv_cont_1100 TYPE REF TO cl_gui_custom_container,
MODULE status_1100 OUTPUT.
DATA: lv_title TYPE lvc_title,
lt_fcat TYPE lvc_t_fcat,
ls_layout TYPE lvc_s_layo.
SET PF-STATUS 'STATUS_1100'. " Buttons
SET TITLEBAR 'MAIN1100'. " GUI-Titel
* ALV Vorbereiten
PERFORM get_alv_1100.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZPAG_PLAUS_DET_ALV_STRUC'
CHANGING
ct_fieldcat = lt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Layout anpassen
ls_layout-zebra = 'X' .
ls_layout-cwidth_opt = 'X'.
CALL METHOD gv_alv_grid_1100->set_table_for_first_display
EXPORTING
is_layout = ls_layout
CHANGING
it_outtab = gt_plaus_det
it_fieldcatalog = lt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE. " STATUS_1100 OUTPUT
MODULE user_command_1100 INPUT.
IF g_ok_code EQ 'CLOSE'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE. " USER_COMMAND_1100 INPUT
FORM get_alv_1100 .
IF gv_alv_cont_1100 IS NOT INITIAL.
CALL METHOD gv_alv_cont_1100->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
"MESSAGE 'TODO: zmcp_get_alv Corrupted msg cont' TYPE 'S' DISPLAY LIKE 'E'.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
IF gv_alv_grid_1100 IS NOT INITIAL.
CALL METHOD gv_alv_grid_1100->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
" wird oft geworfen
"MESSAGE 'TODO: zmcp_get_alv Corrupted msg grid' TYPE 'S' DISPLAY LIKE 'E'.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
CREATE OBJECT gv_alv_cont_1100
EXPORTING
container_name = 'CCCONTAINER'.
CREATE OBJECT gv_alv_grid_1100
EXPORTING
i_parent = gv_alv_cont_1100.
ENDFORM. " GET_ALV_1100
MODULE pbo_1100 OUTPUT.
SET PF-STATUS 'STATUS_1100'.
SET TITLEBAR 'MAIN1100'. " GUI-Titel
CREATE OBJECT gv_alv_container_act
EXPORTING
container_name = 'ALV-CONT-ACT'.
CREATE OBJECT gv_alv_viewer_act
EXPORTING
i_parent = gv_alv_container_act.
* Feldkatalog aufbauen
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZMCP_ALV_ZP_ORDER'
CHANGING
ct_fieldcat = lt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
" Tabelle anpassen (Spalten ausblenden, Breite anpassen, Zebra aktivieren, Titel
FIELD-SYMBOLS: <fs_column> TYPE lvc_s_fcat .
LOOP AT lt_fcat ASSIGNING <fs_column> .
CASE <fs_column>-fieldname .
WHEN 'SETTLUNIT' .
<fs_column>-outputlen = '15' .
WHEN 'GRID_ID'.
<fs_column>-outputlen = '15' .
WHEN 'ZRTYP' .
<fs_column>-outputlen = '15' .
WHEN 'SETTLUNITEXT' .
<fs_column>-outputlen = '20' .
WHEN 'SETTLUNITTXT' .
<fs_column>-outputlen = '20' .
WHEN 'REQUIRED_ACTION' .
<fs_column>-no_out = 'X' .
WHEN 'SBIKO' .
<fs_column>-outputlen = '5' .
WHEN 'SLIEF' .
<fs_column>-outputlen = '5' .
ENDCASE.
ENDLOOP.
" Layout anpassen
lv_layout-zebra = 'X' .
lv_layout-grid_title = text-005.
*&---------------------------------------------------------------------*
* FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
*&---------------------------------------------------------------------*
DATA: lt_toolbar_buttons_to_exclude TYPE ui_functions.
APPEND '&INFO' TO lt_toolbar_buttons_to_exclude . "Info button weg
APPEND '&MB_SUM' TO lt_toolbar_buttons_to_exclude . "
APPEND '&MB_SUMTOT' TO lt_toolbar_buttons_to_exclude . "
APPEND '&GRAPH' TO lt_toolbar_buttons_to_exclude . "
*&---------------------------------------------------------------------*
CALL METHOD gv_alv_viewer_act->set_table_for_first_display
EXPORTING
is_layout = lv_layout
it_toolbar_excluding = lt_toolbar_buttons_to_exclude
CHANGING
it_outtab = lt_zrtyp_act
it_fieldcatalog = lt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT gv_alv_container_deact
EXPORTING
container_name = 'ALV-CONT-DEACT'.
CREATE OBJECT gv_alv_viewer_deact
EXPORTING
i_parent = gv_alv_container_deact.
lv_layout-grid_title = text-006.
CALL METHOD gv_alv_viewer_deact->set_table_for_first_display
EXPORTING
is_layout = lv_layout
it_toolbar_excluding = lt_toolbar_buttons_to_exclude
CHANGING
it_outtab = lt_zrtyp_deact
it_fieldcatalog = lt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE. " PBO_1100 OUTPUT