You are on page 1of 3

Reward if helpful

report ztest_0002
no standard page heading
message-id zmm.
* Tables.
tables: mara.
* Global ALV Data Declarations
type-pools: slis.
* Internal Tables
data: begin of itab occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of itab.
data: fieldcat type slis_t_fieldcat_alv.
data: variant type disvariant.
* Selection Screen
selection-screen begin of block b1 with frame title text-002 .
select-options: s_matnr for mara-matnr.
parameters: p_var(30) type c.
selection-screen end of block b1.
initialization.
variant-report = sy-repid.
variant-username = sy-uname.
at selection-screen on value-request for p_var.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = variant
i_save = 'U'
importing
es_variant = variant
exceptions
not_found = 1
program_error = 2
others = 3.
p_var = variant-variant.
start-of-selection.
perform get_data.
perform call_alv.
*********************************************************************
* Form GET_DATA
*********************************************************************
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table itab
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
************************************************************************
* CALL_ALV
************************************************************************
form call_alv.
perform build_field_catalog.
* Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
is_variant = variant
i_save = 'U'
tables
t_outtab = itab.
endform.
************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
data: label(30) type c.
clear: fieldcat. refresh: fieldcat.
perform update_catalog using 'Material Number'
'ITAB'
'MATNR'
'18'
space
space
'L'.
perform update_catalog using 'Material Description'
'ITAB'
'MAKTX'
'40'
space
space
'L'.
endform.
************************************************************************
* UPDATE_CATALOG
************************************************************************
form update_catalog using col_head
table
field
outputlen
do_sum
no_out
just.
data: tmp_fc type slis_t_fieldcat_alv with header line.
tmp_fc-reptext_ddic = col_head.
tmp_fc-fieldname = field.
tmp_fc-tabname = table.
tmp_fc-outputlen = outputlen.
tmp_fc-just = just.
tmp_fc-decimals_out = 0.
tmp_fc-do_sum = do_sum.
tmp_fc-no_out = no_out.
append tmp_fc to fieldcat.