Code: Alles auswählen.
REPORT z_mmstamm_bl LINE-SIZE 132.
*** I N C L U D E S ****************************************************
INCLUDE <icon>.
*** D A T E N D E K L A R A T I O N ************************************
DATA:
g_it_data TYPE TABLE OF zsss_mmstamm_bl,
g_wa_data TYPE zsss_mmstamm_bl,
g_it_makt TYPE TABLE OF makt,
g_wa_makt TYPE makt.
DATA:
g_zaehler TYPE i.
DATA:
ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_repid LIKE sy-repid,
* Define a structure of type LVC_S_LAYO.
gs_layout TYPE lvc_s_layo,
g_custom_container TYPE REF TO cl_gui_custom_container.
** Define the fieldcatalog
* gt_field TYPE lvc_t_fcat,
** Define the workarea
* gw_field TYPE lvc_s_fcat.
DATA:
g_light TYPE c.
* The name of the additional field has to be acquainted to ALV
* in 'gs_layout-excp_fname' which is of type lvc_cifnm.
* 'g_lights_name' is defined for that purpose
DATA:
g_lights_name TYPE lvc_cifnm VALUE 'LIGHT'.
*** S E L E K T I O N E N **********************************************
* Selectionscreen
SELECTION-SCREEN BEGIN OF BLOCK selection WITH FRAME TITLE text-001.
SELECT-OPTIONS:
so_matnr FOR g_wa_data-matnr.
PARAMETER:
pa_alv TYPE c RADIOBUTTON GROUP radi,
pa_wri TYPE c RADIOBUTTON GROUP radi.
SELECTION-SCREEN END OF BLOCK selection.
*This is written on the top of the page
TOP-OF-PAGE.
* It should only be written in the report version
IF pa_wri = 'X'.
WRITE:/1 'List of the materials',
* Point of run time of the report, date
40 'Date: ', sy-datum,
* Point of run time of the report, time
60 'Time: ', sy-uzeit,
100 'User: ', sy-uname.
WRITE: /.
WRITE: /1 'Material Number',
20 'Material Description (Short Text)',
70 'Number of the short text',
100 'Section',
120 'Status'.
WRITE: /.
ENDIF.
START-OF-SELECTION.
CLEAR: g_it_data,
g_it_makt.
SELECT matnr spart FROM mara INTO CORRESPONDING FIELDS OF TABLE g_it_data
WHERE matnr IN so_matnr.
SELECT * FROM makt INTO TABLE g_it_makt
WHERE matnr IN so_matnr.
LOOP AT g_it_data INTO g_wa_data.
[b]LOOP AT g_it_makt INTO g_wa_makt.
IF g_wa_data-matnr = g_wa_makt-matnr.
IF g_wa_makt-spras = sy-langu.
g_wa_data-maktx = g_wa_makt-maktx.
ENDIF.
g_wa_data-counter = g_wa_data-counter + 1.
ENDIF.
IF g_wa_data-spart = 'Z1'.
g_wa_data-light = '1'.
ELSEIF g_wa_data-spart = 'LF'.
g_wa_data-light = '2'.
ELSE.
g_wa_data-light = '3'.
ENDIF.
MODIFY g_it_data FROM g_wa_data.
ENDLOOP.[/b]
[b] IF pa_alv = 'X'.
* Set initial dynpro
CALL SCREEN 100.[/b]
ELSEIF pa_wri = 'X'.
* Output of the data records
WRITE: /1 g_wa_data-matnr,
20 g_wa_data-maktx,
70 g_wa_data-counter,
100 g_wa_data-spart.
IF g_wa_data-spart = 'Z1'.
WRITE 120 icon_red_light AS ICON.
ELSEIF g_wa_data-spart = 'LF'.
WRITE 120 icon_yellow_light AS ICON.
ELSE.
WRITE 120 icon_green_light AS ICON.
ENDIF.
* Count up the data records
g_zaehler = g_zaehler + 1.
ENDIF.
ENDLOOP.
END-OF-SELECTION.
* It should only be written in the report version
IF pa_wri = 'X'.
WRITE: /.
WRITE:/1 'Number of the short text: ', g_wa_data-counter,
70 'Data records: ', g_zaehler,
110 'Page: ', sy-pagno.
WRITE: /.
ENDIF.
*This is written on the end of the page
END-OF-PAGE.
*----------------------------------------------------------------------*
* MODULE PBO OUTPUT
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
g_repid = sy-repid.
IF g_custom_container IS INITIAL.
* Set a value for field LIGHT for each line of your output table.
* You do not necessarily need to define a field catalog if
* the rest of your output table is represented by a DDIC structure.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
* Add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.
* Create an instance of alv control
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
*..............................................
*set some layout-values (Structure LVC_S_LAYO)
*..............................................
* Set a titlebar for the grid control
gs_layout-grid_title = 'Materials'(100).
* Set field EXCP_FNAME of the structure of type LVC_S_LAYO
* with the name of your additional field.
gs_layout-excp_fname = g_lights_name.
gs_layout-excp_rolln = 'ALV_LIGHT'.
* gs_layout-excp_led = 'X'.
gs_layout-zebra = 'X'.
*.............................
* show table on ALV Control
*.............................
* Provide your Layout-Structure when calling
* 'set_table_for_first_display' (Parameter IS_LAYOUT).
CALL METHOD grid1->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
i_structure_name = 'ZSSS_MMSTAMM_BL'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = g_it_data
* it_fieldcatalog = gt_field
* 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.
*Control Framework flushes at the end of PBO automatically!
ENDMODULE. " PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* To react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* Do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
Code: Alles auswählen.
REPORT z_mmstamm_bl LINE-SIZE 132.
*** I N C L U D E S ****************************************************
INCLUDE <icon>.
*** D A T E N D E K L A R A T I O N ************************************
DATA:
g_it_data TYPE TABLE OF zsss_mmstamm_bl,
g_wa_data TYPE zsss_mmstamm_bl,
g_it_makt TYPE TABLE OF makt,
g_wa_makt TYPE makt.
DATA:
g_zaehler TYPE i.
DATA:
ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_repid LIKE sy-repid,
* Define a structure of type LVC_S_LAYO.
gs_layout TYPE lvc_s_layo,
g_custom_container TYPE REF TO cl_gui_custom_container.
** Define the fieldcatalog
* gt_field TYPE lvc_t_fcat,
** Define the workarea
* gw_field TYPE lvc_s_fcat.
DATA:
g_light TYPE c.
* The name of the additional field has to be acquainted to ALV
* in 'gs_layout-excp_fname' which is of type lvc_cifnm.
* 'g_lights_name' is defined for that purpose
DATA:
g_lights_name TYPE lvc_cifnm VALUE 'LIGHT'.
*** S E L E K T I O N E N **********************************************
* Selectionscreen
SELECTION-SCREEN BEGIN OF BLOCK selection WITH FRAME TITLE text-001.
SELECT-OPTIONS:
so_matnr FOR g_wa_data-matnr.
PARAMETER:
pa_alv TYPE c RADIOBUTTON GROUP radi,
pa_wri TYPE c RADIOBUTTON GROUP radi.
SELECTION-SCREEN END OF BLOCK selection.
*This is written on the top of the page
TOP-OF-PAGE.
* It should only be written in the report version
IF pa_wri = 'X'.
WRITE:/1 'List of the materials',
* Point of run time of the report, date
40 'Date: ', sy-datum,
* Point of run time of the report, time
60 'Time: ', sy-uzeit,
100 'User: ', sy-uname.
WRITE: /.
WRITE: /1 'Material Number',
20 'Material Description (Short Text)',
70 'Number of the short text',
100 'Section',
120 'Status'.
WRITE: /.
ENDIF.
START-OF-SELECTION.
CLEAR: g_it_data,
g_it_makt.
SELECT matnr spart FROM mara INTO CORRESPONDING FIELDS OF TABLE g_it_data
WHERE matnr IN so_matnr.
SELECT * FROM makt INTO TABLE g_it_makt
WHERE matnr IN so_matnr.
LOOP AT g_it_data INTO g_wa_data.
LOOP AT g_it_makt INTO g_wa_makt.
IF g_wa_data-matnr = g_wa_makt-matnr.
IF g_wa_makt-spras = sy-langu.
g_wa_data-maktx = g_wa_makt-maktx.
ENDIF.
g_wa_data-counter = g_wa_data-counter + 1.
ENDIF.
IF g_wa_data-spart = 'Z1'.
g_wa_data-light = '1'.
ELSEIF g_wa_data-spart = 'LF'.
g_wa_data-light = '2'.
ELSE.
g_wa_data-light = '3'.
ENDIF.
MODIFY g_it_data FROM g_wa_data.
ENDLOOP.
ENDLOOP.
IF pa_wri = 'X'.
LOOP AT g_it_data INTO g_wa_data.
* Output of the data records
WRITE: /1 g_wa_data-matnr,
20 g_wa_data-maktx,
70 g_wa_data-counter,
100 g_wa_data-spart.
IF g_wa_data-spart = 'Z1'.
WRITE 120 icon_red_light AS ICON.
ELSEIF g_wa_data-spart = 'LF'.
WRITE 120 icon_yellow_light AS ICON.
ELSE.
WRITE 120 icon_green_light AS ICON.
ENDIF.
* Count up the data records
g_zaehler = g_zaehler + 1.
ENDLOOP.
ELSEIF pa_alv = 'X'.
* Set initial dynpro
CALL SCREEN 100.
ENDIF.
END-OF-SELECTION.
* It should only be written in the report version
IF pa_wri = 'X'.
WRITE: /.
WRITE:/1 'Number of the short text: ', g_wa_data-counter,
70 'Data records: ', g_zaehler,
110 'Page: ', sy-pagno.
WRITE: /.
ENDIF.
*This is written on the end of the page
END-OF-PAGE.
*----------------------------------------------------------------------*
* MODULE PBO OUTPUT
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
g_repid = sy-repid.
IF g_custom_container IS INITIAL.
* Set a value for field LIGHT for each line of your output table.
* You do not necessarily need to define a field catalog if
* the rest of your output table is represented by a DDIC structure.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
* Add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.
* Create an instance of alv control
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
*..............................................
*set some layout-values (Structure LVC_S_LAYO)
*..............................................
* Set a titlebar for the grid control
gs_layout-grid_title = 'Materials'(100).
* Set field EXCP_FNAME of the structure of type LVC_S_LAYO
* with the name of your additional field.
gs_layout-excp_fname = g_lights_name.
gs_layout-excp_rolln = 'ALV_LIGHT'.
* gs_layout-excp_led = 'X'.
gs_layout-zebra = 'X'.
*.............................
* show table on ALV Control
*.............................
* Provide your Layout-Structure when calling
* 'set_table_for_first_display' (Parameter IS_LAYOUT).
CALL METHOD grid1->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
i_structure_name = 'ZSSS_MMSTAMM_BL'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = gs_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = g_it_data
* it_fieldcatalog = gt_field
* 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.
*Control Framework flushes at the end of PBO automatically!
ENDMODULE. " PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* To react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* Do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
Code: Alles auswählen.
TYPES:
BEGIN OF t_maktx,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
END OF t_maktx.
DATA:
i_maktx TYPE HASHED TABLE OF t_maktx WITH UNIQUE KEY matnr,
wa_maktx LIKE LINE OF i_maktx,
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Form READ_MAKTX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM read_maktx USING p_matnr TYPE matnr
CHANGING ch_maktx TYPE maktx.
CLEAR: ch_maktx, wa_maktx.
IF p_matnr IS NOT INITIAL.
READ TABLE i_maktx WITH TABLE KEY matnr = p_matnr
INTO wa_maktx TRANSPORTING maktx.
IF sy-subrc NE 0 .
SELECT SINGLE maktx
INTO (wa_maktx-maktx)
FROM makt
WHERE matnr EQ p_matnr AND
spras EQ sy-langu .
wa_maktx-matnr = p_matnr.
INSERT wa_maktx INTO TABLE i_maktx.
ENDIF.
ch_maktx = wa_maktx-maktx .
ENDIF.
ENDFORM. " READ_MAKTX