This is a Simple ALV grid display using "cl_gui_alv_grid" class...
REPORT ergp2020 LINE-SIZE 90 NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------*
* Programmversion; angelegt: 31.1.1995, Gerd Waloszek *
*----------------------------------------------------------------------*
* Letzte Änderung: 25.2.98, Gerd Waloszek
** Kopiert und umgestellt auf ALV: August 00, Andreas Groß
*
*----------------------------------------------------------------------*
************************************************************************
************************* Global data **********************************
************************************************************************
DATA: txt_report LIKE dokhl-object. "Reportname für Erläuterungsaufruf
DATA: BEGIN OF mylist OCCURS 20, " Internal table for preparing
zuordnung(8) TYPE c, " the list
belegnr(10) TYPE c,
ba(2) TYPE c,
bldatum TYPE d,
bs(2) TYPE c,
s(4) TYPE c VALUE ' ',
wrg(4) TYPE c,
betrag TYPE p DECIMALS 2,
END OF mylist.
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'LIBS_GRID_CONTROL_CONTAINER',
grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_fieldcatalog TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.
DATA: seed1 TYPE i value '123', " Rand number seed 1
seed2 TYPE i value '2345', " Rand number seed 2
seed3 TYPE i value '23'. " Rand number seed 3
************************************************************************
*************************** Main Program *******************************
************************************************************************
PERFORM fill_itab.
PERFORM fieldcatalog_init USING gt_fieldcatalog[].
PERFORM layout_init USING gs_layout.
PERFORM main.
************************************************************************
*************************** Form Routines ******************************
************************************************************************
*---------------------------------------------------------------------*
* FORM MAIN *
*---------------------------------------------------------------------*
* Main output routine *
*---------------------------------------------------------------------*
FORM main.
CALL SCREEN 100.
ENDFORM.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN1'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid
EXPORTING i_parent = g_custom_container.
CALL METHOD grid->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
it_outtab = mylist[]
it_fieldcatalog = gt_fieldcatalog
* IT_SORT =
* IT_FILTER =
* 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.
ENDIF.
ENDMODULE.
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN '&F03' OR '&F15' OR '&F12'.
PERFORM exit_program.
WHEN 'ERLE'.
txt_report = 'ERGP2020'.
CALL FUNCTION 'ERGO_TEXT_SHOW'
EXPORTING
textname = txt_report
id = 'RE'
langu = sy-langu.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE.
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FILL_ITAB *
*---------------------------------------------------------------------*
* Fills the internal table for the list output *
*---------------------------------------------------------------------*
FORM fill_itab.
DATA: ran TYPE f,
rani TYPE i,
ranp TYPE p DECIMALS 2,
belnr TYPE i VALUE 1600000040,
date TYPE d.
date = '19920417'.
DO 18 TIMES.
MOVE '19920316' TO mylist-zuordnung.
ADD 1 TO belnr.
MOVE belnr TO mylist-belegnr.
MOVE 'DA' TO mylist-ba.
PERFORM random(ergphelp) USING seed1 seed2 seed3 ran.
rani = 10 * ran.
IF rani > 7.
ADD 1 TO date.
ENDIF.
MOVE date TO mylist-bldatum.
MOVE '01' TO mylist-bs.
PERFORM random(ergphelp) USING seed1 seed2 seed3 ran.
rani = 10 * ran.
IF rani > 7.
MOVE text-w10 TO mylist-wrg. "USD
ELSE.
MOVE text-w20 TO mylist-wrg. "DM
ENDIF.
PERFORM random(ergphelp) USING seed1 seed2 seed3 ran.
ranp = 1000000 * ran.
IF mylist-wrg = text-w10.
ranp = ranp / 2.
ENDIF.
MOVE ranp TO mylist-betrag.
APPEND mylist.
ENDDO.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FIELDCAT_INIT
*
*---------------------------------------------------------------------*
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat.
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'ZUORDNUNG'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U10.
ls_fieldcatalog-coltext = TEXT-U10.
ls_fieldcatalog-seltext = TEXT-U10.
ls_fieldcatalog-tooltip = TEXT-U10.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BELEGNR'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U20.
ls_fieldcatalog-coltext = TEXT-U20.
ls_fieldcatalog-seltext = TEXT-U20.
ls_fieldcatalog-tooltip = TEXT-U20.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BA'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U30.
ls_fieldcatalog-coltext = TEXT-U30.
ls_fieldcatalog-seltext = TEXT-U30.
ls_fieldcatalog-tooltip = TEXT-U30.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BLDATUM'.
ls_fieldcatalog-datatype = 'DATS'.
ls_fieldcatalog-reptext = TEXT-U40.
ls_fieldcatalog-coltext = TEXT-U40.
ls_fieldcatalog-seltext = TEXT-U40.
ls_fieldcatalog-tooltip = TEXT-U40.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BS'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U50.
ls_fieldcatalog-coltext = TEXT-U50.
ls_fieldcatalog-seltext = TEXT-U50.
ls_fieldcatalog-tooltip = TEXT-U50.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'S'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U60.
ls_fieldcatalog-coltext = TEXT-U60.
ls_fieldcatalog-seltext = TEXT-U60.
ls_fieldcatalog-tooltip = TEXT-U60.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'WRG'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U70.
ls_fieldcatalog-coltext = TEXT-U70.
ls_fieldcatalog-seltext = TEXT-U70.
ls_fieldcatalog-tooltip = TEXT-U70.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BETRAG'.
ls_fieldcatalog-datatype = 'CURR'.
ls_fieldcatalog-outputlen = '15'.
ls_fieldcatalog-reptext = TEXT-U80.
ls_fieldcatalog-coltext = TEXT-U80.
ls_fieldcatalog-seltext = TEXT-U80.
ls_fieldcatalog-tooltip = TEXT-U80.
ls_fieldcatalog-cfieldname = 'WRG'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ENDFORM.
*---------------------------------------------------------------------*
* FORM layout_init *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> LS_LAYOUT *
*---------------------------------------------------------------------*
FORM layout_init USING ls_layout TYPE lvc_s_layo.
ls_layout-no_toolbar = 'X'.
ls_layout-zebra = 'X'.
ENDFORM.
*----------------------------------------------------------------------*
* Programmversion; angelegt: 31.1.1995, Gerd Waloszek *
*----------------------------------------------------------------------*
* Letzte Änderung: 25.2.98, Gerd Waloszek
** Kopiert und umgestellt auf ALV: August 00, Andreas Groß
*
*----------------------------------------------------------------------*
************************************************************************
************************* Global data **********************************
************************************************************************
DATA: txt_report LIKE dokhl-object. "Reportname für Erläuterungsaufruf
DATA: BEGIN OF mylist OCCURS 20, " Internal table for preparing
zuordnung(8) TYPE c, " the list
belegnr(10) TYPE c,
ba(2) TYPE c,
bldatum TYPE d,
bs(2) TYPE c,
s(4) TYPE c VALUE ' ',
wrg(4) TYPE c,
betrag TYPE p DECIMALS 2,
END OF mylist.
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'LIBS_GRID_CONTROL_CONTAINER',
grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_fieldcatalog TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.
DATA: seed1 TYPE i value '123', " Rand number seed 1
seed2 TYPE i value '2345', " Rand number seed 2
seed3 TYPE i value '23'. " Rand number seed 3
************************************************************************
*************************** Main Program *******************************
************************************************************************
PERFORM fill_itab.
PERFORM fieldcatalog_init USING gt_fieldcatalog[].
PERFORM layout_init USING gs_layout.
PERFORM main.
************************************************************************
*************************** Form Routines ******************************
************************************************************************
*---------------------------------------------------------------------*
* FORM MAIN *
*---------------------------------------------------------------------*
* Main output routine *
*---------------------------------------------------------------------*
FORM main.
CALL SCREEN 100.
ENDFORM.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN1'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid
EXPORTING i_parent = g_custom_container.
CALL METHOD grid->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
it_outtab = mylist[]
it_fieldcatalog = gt_fieldcatalog
* IT_SORT =
* IT_FILTER =
* 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.
ENDIF.
ENDMODULE.
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN '&F03' OR '&F15' OR '&F12'.
PERFORM exit_program.
WHEN 'ERLE'.
txt_report = 'ERGP2020'.
CALL FUNCTION 'ERGO_TEXT_SHOW'
EXPORTING
textname = txt_report
id = 'RE'
langu = sy-langu.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE.
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FILL_ITAB *
*---------------------------------------------------------------------*
* Fills the internal table for the list output *
*---------------------------------------------------------------------*
FORM fill_itab.
DATA: ran TYPE f,
rani TYPE i,
ranp TYPE p DECIMALS 2,
belnr TYPE i VALUE 1600000040,
date TYPE d.
date = '19920417'.
DO 18 TIMES.
MOVE '19920316' TO mylist-zuordnung.
ADD 1 TO belnr.
MOVE belnr TO mylist-belegnr.
MOVE 'DA' TO mylist-ba.
PERFORM random(ergphelp) USING seed1 seed2 seed3 ran.
rani = 10 * ran.
IF rani > 7.
ADD 1 TO date.
ENDIF.
MOVE date TO mylist-bldatum.
MOVE '01' TO mylist-bs.
PERFORM random(ergphelp) USING seed1 seed2 seed3 ran.
rani = 10 * ran.
IF rani > 7.
MOVE text-w10 TO mylist-wrg. "USD
ELSE.
MOVE text-w20 TO mylist-wrg. "DM
ENDIF.
PERFORM random(ergphelp) USING seed1 seed2 seed3 ran.
ranp = 1000000 * ran.
IF mylist-wrg = text-w10.
ranp = ranp / 2.
ENDIF.
MOVE ranp TO mylist-betrag.
APPEND mylist.
ENDDO.
ENDFORM.
*---------------------------------------------------------------------*
* FORM FIELDCAT_INIT
*
*---------------------------------------------------------------------*
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat.
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'ZUORDNUNG'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U10.
ls_fieldcatalog-coltext = TEXT-U10.
ls_fieldcatalog-seltext = TEXT-U10.
ls_fieldcatalog-tooltip = TEXT-U10.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BELEGNR'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U20.
ls_fieldcatalog-coltext = TEXT-U20.
ls_fieldcatalog-seltext = TEXT-U20.
ls_fieldcatalog-tooltip = TEXT-U20.
ls_fieldcatalog-key = 'X'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BA'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U30.
ls_fieldcatalog-coltext = TEXT-U30.
ls_fieldcatalog-seltext = TEXT-U30.
ls_fieldcatalog-tooltip = TEXT-U30.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BLDATUM'.
ls_fieldcatalog-datatype = 'DATS'.
ls_fieldcatalog-reptext = TEXT-U40.
ls_fieldcatalog-coltext = TEXT-U40.
ls_fieldcatalog-seltext = TEXT-U40.
ls_fieldcatalog-tooltip = TEXT-U40.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BS'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U50.
ls_fieldcatalog-coltext = TEXT-U50.
ls_fieldcatalog-seltext = TEXT-U50.
ls_fieldcatalog-tooltip = TEXT-U50.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'S'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U60.
ls_fieldcatalog-coltext = TEXT-U60.
ls_fieldcatalog-seltext = TEXT-U60.
ls_fieldcatalog-tooltip = TEXT-U60.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'WRG'.
ls_fieldcatalog-datatype = 'C'.
ls_fieldcatalog-reptext = TEXT-U70.
ls_fieldcatalog-coltext = TEXT-U70.
ls_fieldcatalog-seltext = TEXT-U70.
ls_fieldcatalog-tooltip = TEXT-U70.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = 'BETRAG'.
ls_fieldcatalog-datatype = 'CURR'.
ls_fieldcatalog-outputlen = '15'.
ls_fieldcatalog-reptext = TEXT-U80.
ls_fieldcatalog-coltext = TEXT-U80.
ls_fieldcatalog-seltext = TEXT-U80.
ls_fieldcatalog-tooltip = TEXT-U80.
ls_fieldcatalog-cfieldname = 'WRG'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
CLEAR ls_fieldcatalog.
ENDFORM.
*---------------------------------------------------------------------*
* FORM layout_init *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> LS_LAYOUT *
*---------------------------------------------------------------------*
FORM layout_init USING ls_layout TYPE lvc_s_layo.
ls_layout-no_toolbar = 'X'.
ls_layout-zebra = 'X'.
ENDFORM.