*&---------------------------------------------------------------------*
*& Report ZSALV_POPUP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSALV_POPUP NO STANDARD PAGE HEADING.
*
INCLUDE <COLOR>.
INCLUDE <ICON>.
INCLUDE <SYMBOL>.
TYPES: BEGIN OF G_TYPE_S_TEST,
AMOUNT TYPE I,
REPID TYPE SYREPID,
DISPLAY TYPE I,
SELECTION TYPE SAP_BOOL,
END OF G_TYPE_S_TEST.
CONSTANTS: GC_TRUE TYPE SAP_BOOL VALUE 'X',
BEGIN OF GC_S_DISPLAY,
LIST TYPE I VALUE 1,
FULLSCREEN TYPE I VALUE 2,
END OF GC_S_DISPLAY.
DATA: GS_TEST TYPE G_TYPE_S_TEST.
DATA: GT_OUTTAB TYPE STANDARD TABLE OF eablg.
DATA: GR_TABLE TYPE REF TO CL_SALV_TABLE.
*----------------------------------------------------------------------*
* SELECTION-SCREEN - for demonstration purposes only *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK GEN WITH FRAME.
PARAMETERS:
P_AMOUNT TYPE I DEFAULT 30.
SELECTION-SCREEN END OF BLOCK GEN.
SELECTION-SCREEN BEGIN OF BLOCK DSP WITH FRAME.
PARAMETERS:
P_FULL RADIOBUTTON GROUP DSP,
P_LIST RADIOBUTTON GROUP DSP.
SELECTION-SCREEN END OF BLOCK DSP.
SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME.
PARAMETERS:
P_BOX AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK SEL.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
GS_TEST-AMOUNT = P_AMOUNT.
GS_TEST-REPID = SY-REPID.
CASE GC_TRUE.
WHEN P_LIST.
GS_TEST-DISPLAY = GC_S_DISPLAY-LIST.
WHEN P_FULL.
GS_TEST-DISPLAY = GC_S_DISPLAY-FULLSCREEN.
ENDCASE.
GS_TEST-SELECTION = P_BOX.
PERFORM SELECT_DATA.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
CASE GS_TEST-DISPLAY.
WHEN GC_S_DISPLAY-FULLSCREEN.
PERFORM DISPLAY_FULLSCREEN.
WHEN GC_S_DISPLAY-LIST.
PERFORM DISPLAY_LIST.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form select_data
*&---------------------------------------------------------------------*
* §2 to display the data, you first have to select it in some table
*----------------------------------------------------------------------*
FORM SELECT_DATA.
SELECT * FROM eablg INTO CORRESPONDING FIELDS OF TABLE GT_OUTTAB
UP TO GS_TEST-AMOUNT ROWS. "#EC *
ENDFORM. " select_data
*&---------------------------------------------------------------------*
*& Form display_fullscreen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_FULLSCREEN .
*... §2 create an ALV table
* §2.2 just create an instance and do not set LIST_DISPLAY for
* displaying the data as a Fullscreen Grid
TRY.
CL_SALV_TABLE=>FACTORY(
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = GT_OUTTAB ).
CATCH CX_SALV_MSG. "#EC NO_HANDLER
ENDTRY.
*... §3 Functions
*... §3.1 activate ALV generic Functions
DATA: LR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST.
LR_FUNCTIONS = GR_TABLE->GET_FUNCTIONS( ).
LR_FUNCTIONS->SET_ALL( GC_TRUE ).
*... set the columns technical
DATA: LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS.
LR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
* TRY.
* CALL METHOD gr_table->set_screen_status
* EXPORTING
* report = 'SALV_DEMO_TABLE_EVENTS'
* pfstatus = 'D0100'
** SET_FUNCTIONS = C_FUNCTIONS_NONE
.
* ENDTRY.
PERFORM SET_COLUMNS_TECHNICAL USING LR_COLUMNS.
*... §4.1 set the size and position of the Popup via coordinates
GR_TABLE->SET_SCREEN_POPUP(
START_COLUMN = 1
END_COLUMN = 100
START_LINE = 1
END_LINE = 20 ).
*... §4.2 set the selection mode of the Popup: multiple or single row selection
IF GS_TEST-SELECTION EQ GC_TRUE.
DATA: LR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
LR_SELECTIONS = GR_TABLE->GET_SELECTIONS( ).
LR_SELECTIONS->SET_SELECTION_MODE( IF_SALV_C_SELECTION_MODE=>ROW_COLUMN ).
ENDIF.
*... §5 display the table
GR_TABLE->DISPLAY( ).
*
* lr_selections = gr_table->get_selections( ).
* data: lt_sel type salv_t_row.
* lt_sel = lr_selections->get_selected_rows( ).
ENDFORM. " display_fullscreen
*&---------------------------------------------------------------------*
*& Form display_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_LIST .
*... §2 create an ALV table
* §2.1 set LIST_DISPLAY to 'X' for displaying an ALV List
TRY.
CL_SALV_TABLE=>FACTORY(
EXPORTING
LIST_DISPLAY = GC_TRUE
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = GT_OUTTAB ).
CATCH CX_SALV_MSG. "#EC NO_HANDLER
ENDTRY.
*... §3 Functions
*... §3.1 activate ALV generic Functions
DATA: LR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS.
LR_FUNCTIONS = GR_TABLE->GET_FUNCTIONS( ).
LR_FUNCTIONS->SET_ALL( GC_TRUE ).
*... set the columns technical
DATA: LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS.
LR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
PERFORM SET_COLUMNS_TECHNICAL USING LR_COLUMNS.
*... §4.1 set the size and position of the Popup via coordinates
GR_TABLE->SET_SCREEN_POPUP(
START_COLUMN = 1
END_COLUMN = 100
START_LINE = 1
END_LINE = 20 ).
*... §4.2 set the selection mode of the Popup: multiple or single row selection
IF GS_TEST-SELECTION EQ GC_TRUE.
DATA: LR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
LR_SELECTIONS = GR_TABLE->GET_SELECTIONS( ).
LR_SELECTIONS->SET_SELECTION_MODE( IF_SALV_C_SELECTION_MODE=>ROW_COLUMN ).
ENDIF.
*... §5 display the table
GR_TABLE->DISPLAY( ).
ENDFORM. " display_list
*&---------------------------------------------------------------------*
*& Form set_columns_technical
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SET_COLUMNS_TECHNICAL USING IR_COLUMNS TYPE REF TO CL_SALV_COLUMNS.
DATA: LR_COLUMN TYPE REF TO CL_SALV_COLUMN.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'MANDT' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'FLOAT_FI' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'STRING_F' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'XSTRING' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'INT_FIEL' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'HEX_FIEL' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'DROPDOWN' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'TAB_INDEX' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
ENDFORM. " set_columns_technical(
*& Report ZSALV_POPUP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSALV_POPUP NO STANDARD PAGE HEADING.
*
INCLUDE <COLOR>.
INCLUDE <ICON>.
INCLUDE <SYMBOL>.
TYPES: BEGIN OF G_TYPE_S_TEST,
AMOUNT TYPE I,
REPID TYPE SYREPID,
DISPLAY TYPE I,
SELECTION TYPE SAP_BOOL,
END OF G_TYPE_S_TEST.
CONSTANTS: GC_TRUE TYPE SAP_BOOL VALUE 'X',
BEGIN OF GC_S_DISPLAY,
LIST TYPE I VALUE 1,
FULLSCREEN TYPE I VALUE 2,
END OF GC_S_DISPLAY.
DATA: GS_TEST TYPE G_TYPE_S_TEST.
DATA: GT_OUTTAB TYPE STANDARD TABLE OF eablg.
DATA: GR_TABLE TYPE REF TO CL_SALV_TABLE.
*----------------------------------------------------------------------*
* SELECTION-SCREEN - for demonstration purposes only *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK GEN WITH FRAME.
PARAMETERS:
P_AMOUNT TYPE I DEFAULT 30.
SELECTION-SCREEN END OF BLOCK GEN.
SELECTION-SCREEN BEGIN OF BLOCK DSP WITH FRAME.
PARAMETERS:
P_FULL RADIOBUTTON GROUP DSP,
P_LIST RADIOBUTTON GROUP DSP.
SELECTION-SCREEN END OF BLOCK DSP.
SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME.
PARAMETERS:
P_BOX AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK SEL.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
GS_TEST-AMOUNT = P_AMOUNT.
GS_TEST-REPID = SY-REPID.
CASE GC_TRUE.
WHEN P_LIST.
GS_TEST-DISPLAY = GC_S_DISPLAY-LIST.
WHEN P_FULL.
GS_TEST-DISPLAY = GC_S_DISPLAY-FULLSCREEN.
ENDCASE.
GS_TEST-SELECTION = P_BOX.
PERFORM SELECT_DATA.
*----------------------------------------------------------------------*
* END-OF-SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
CASE GS_TEST-DISPLAY.
WHEN GC_S_DISPLAY-FULLSCREEN.
PERFORM DISPLAY_FULLSCREEN.
WHEN GC_S_DISPLAY-LIST.
PERFORM DISPLAY_LIST.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form select_data
*&---------------------------------------------------------------------*
* §2 to display the data, you first have to select it in some table
*----------------------------------------------------------------------*
FORM SELECT_DATA.
SELECT * FROM eablg INTO CORRESPONDING FIELDS OF TABLE GT_OUTTAB
UP TO GS_TEST-AMOUNT ROWS. "#EC *
ENDFORM. " select_data
*&---------------------------------------------------------------------*
*& Form display_fullscreen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_FULLSCREEN .
*... §2 create an ALV table
* §2.2 just create an instance and do not set LIST_DISPLAY for
* displaying the data as a Fullscreen Grid
TRY.
CL_SALV_TABLE=>FACTORY(
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = GT_OUTTAB ).
CATCH CX_SALV_MSG. "#EC NO_HANDLER
ENDTRY.
*... §3 Functions
*... §3.1 activate ALV generic Functions
DATA: LR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST.
LR_FUNCTIONS = GR_TABLE->GET_FUNCTIONS( ).
LR_FUNCTIONS->SET_ALL( GC_TRUE ).
*... set the columns technical
DATA: LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS.
LR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
* TRY.
* CALL METHOD gr_table->set_screen_status
* EXPORTING
* report = 'SALV_DEMO_TABLE_EVENTS'
* pfstatus = 'D0100'
** SET_FUNCTIONS = C_FUNCTIONS_NONE
.
* ENDTRY.
PERFORM SET_COLUMNS_TECHNICAL USING LR_COLUMNS.
*... §4.1 set the size and position of the Popup via coordinates
GR_TABLE->SET_SCREEN_POPUP(
START_COLUMN = 1
END_COLUMN = 100
START_LINE = 1
END_LINE = 20 ).
*... §4.2 set the selection mode of the Popup: multiple or single row selection
IF GS_TEST-SELECTION EQ GC_TRUE.
DATA: LR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
LR_SELECTIONS = GR_TABLE->GET_SELECTIONS( ).
LR_SELECTIONS->SET_SELECTION_MODE( IF_SALV_C_SELECTION_MODE=>ROW_COLUMN ).
ENDIF.
*... §5 display the table
GR_TABLE->DISPLAY( ).
*
* lr_selections = gr_table->get_selections( ).
* data: lt_sel type salv_t_row.
* lt_sel = lr_selections->get_selected_rows( ).
ENDFORM. " display_fullscreen
*&---------------------------------------------------------------------*
*& Form display_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_LIST .
*... §2 create an ALV table
* §2.1 set LIST_DISPLAY to 'X' for displaying an ALV List
TRY.
CL_SALV_TABLE=>FACTORY(
EXPORTING
LIST_DISPLAY = GC_TRUE
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = GT_OUTTAB ).
CATCH CX_SALV_MSG. "#EC NO_HANDLER
ENDTRY.
*... §3 Functions
*... §3.1 activate ALV generic Functions
DATA: LR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS.
LR_FUNCTIONS = GR_TABLE->GET_FUNCTIONS( ).
LR_FUNCTIONS->SET_ALL( GC_TRUE ).
*... set the columns technical
DATA: LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS.
LR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
PERFORM SET_COLUMNS_TECHNICAL USING LR_COLUMNS.
*... §4.1 set the size and position of the Popup via coordinates
GR_TABLE->SET_SCREEN_POPUP(
START_COLUMN = 1
END_COLUMN = 100
START_LINE = 1
END_LINE = 20 ).
*... §4.2 set the selection mode of the Popup: multiple or single row selection
IF GS_TEST-SELECTION EQ GC_TRUE.
DATA: LR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
LR_SELECTIONS = GR_TABLE->GET_SELECTIONS( ).
LR_SELECTIONS->SET_SELECTION_MODE( IF_SALV_C_SELECTION_MODE=>ROW_COLUMN ).
ENDIF.
*... §5 display the table
GR_TABLE->DISPLAY( ).
ENDFORM. " display_list
*&---------------------------------------------------------------------*
*& Form set_columns_technical
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SET_COLUMNS_TECHNICAL USING IR_COLUMNS TYPE REF TO CL_SALV_COLUMNS.
DATA: LR_COLUMN TYPE REF TO CL_SALV_COLUMN.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'MANDT' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'FLOAT_FI' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'STRING_F' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'XSTRING' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'INT_FIEL' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'HEX_FIEL' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'DROPDOWN' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
TRY.
LR_COLUMN = IR_COLUMNS->GET_COLUMN( 'TAB_INDEX' ).
LR_COLUMN->SET_TECHNICAL( IF_SALV_C_BOOL_SAP=>TRUE ).
CATCH CX_SALV_NOT_FOUND. "#EC NO_HANDLER
ENDTRY.
ENDFORM. " set_columns_technical(