*&---------------------------------------------------------------------*
*& Report ZALV4
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zalv4.
tables: mara.
types: begin of ty_mara,
matnr type matnr,
mtart type mtart,
mbrsh type mbrsh,
matkl type matkl,
end of ty_mara.
data: it_mara type standard table of ty_mara,
wa_mara type ty_mara,
it_fcat type lvc_t_fcat,
wa_fcat type lvc_s_fcat,
wa_layo type lvc_s_layo.
data: cust_cont type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid.
*FIELD-SYMBOLS: <wa_fcat> TYPE lvc_s_fcat.
select-options: s_matnr for mara-matnr.
initialization.
start-of-selection.
call screen 102.
*&---------------------------------------------------------------------*
*& Module STATUS_0102 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0102 output.
set pf-status 'STATUS1'.
set titlebar 'MATERIALS'.
if cust_cont is initial.
create object cust_cont
exporting
container_name = 'CONTAINER'.
create object grid
exporting
i_parent = cust_cont.
perform getmara.
if it_mara is not initial.
perform fieldcatalog.
perform layout.
perform display.
endif.
endif.
endmodule. " STATUS_0102 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0102 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0102 input.
case sy-ucomm.
when 'BACK' or 'EXIT'.
leave program.
endcase.
endmodule. " USER_COMMAND_0102 INPUT
*&---------------------------------------------------------------------*
*& Form FIELDCATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form fieldcatalog .
refresh it_fcat.
clear wa_fcat.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-col_pos = 1.
wa_fcat-coltext = 'Material No.'.
wa_fcat-outputlen = 15.
append wa_fcat to it_fcat.
wa_fcat-fieldname = 'MTART'.
wa_fcat-col_pos = 2.
wa_fcat-coltext = 'Material Type'.
wa_fcat-outputlen = 15.
append wa_fcat to it_fcat.
wa_fcat-fieldname = 'MBRSH'.
wa_fcat-col_pos = 3.
wa_fcat-coltext = 'Industry Sector'.
wa_fcat-outputlen = 15.
append wa_fcat to it_fcat.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-col_pos = 4.
wa_fcat-coltext = 'Material Text'.
wa_fcat-outputlen = 15.
append wa_fcat to it_fcat.
endform. " FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form layout .
wa_layo-cwidth_opt = 'X'.
wa_layo-zebra = 'X'.
wa_layo-grid_title = 'Material Data'.
endform. " LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display.
call method grid->set_table_for_first_display
exporting
is_layout = wa_layo
changing
it_outtab = it_mara
it_fieldcatalog = it_fcat.
endform. " DISPLAY
*&---------------------------------------------------------------------*
*& Form GETMARA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form getmara .
select matnr
mtart
mbrsh
matkl from mara
into corresponding fields of table it_mara
where matnr in s_matnr.
endform. " GETMARA