REPORT zdemo_alvgrid .
type-pools: slis.
*Data Declaration
data: BEGIN OF itab occurs 0,
F1 TYPE I,
F2 TYPE I,
F3 TYPE I,
END OF itab.
data: it_fieldcatalog type slis_t_fieldcat_alv ,
wa_fieldcatalog type slis_fieldcat_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
itab-f1 = '1'.
itab-f2 = '10'.
itab-f3 = '1234'.
append itab.
itab-f1 = '2'.
itab-f2 = '400'.
itab-f3 = '4321'.
append itab.
itab-f1 = '3'.
itab-f2 = '5120'.
itab-f3 = '0766'.
append itab.
itab-f1 = '4'.
itab-f2 = '620'.
itab-f3 = '3245'.
append itab.
itab-f1 = '5'.
itab-f2 = '9430'.
itab-f3 = '564'.
append itab.
itab-f1 = '6'.
itab-f2 = '1098'.
itab-f3 = '14'.
append itab.
itab-f1 = '7'.
itab-f2 = '140'.
itab-f3 = '4325'.
append itab.
wa_fieldcatalog-fieldname = 'F1'.
wa_fieldcatalog-reptext_ddic = 'field1'.
append wa_fieldcatalog to it_fieldcatalog .
clear wa_fieldcatalog .
wa_fieldcatalog-fieldname = 'F2'.
wa_fieldcatalog-reptext_ddic = 'field2'.
wa_fieldcatalog-do_sum = 'X'.
append wa_fieldcatalog to it_fieldcatalog .
clear wa_fieldcatalog .
wa_fieldcatalog-fieldname = 'F3'.
wa_fieldcatalog-reptext_ddic = 'field3'.
wa_fieldcatalog-do_sum = 'X'.
append wa_fieldcatalog to it_fieldcatalog .
clear wa_fieldcatalog .
* gd_layout-
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'.
gd_repid = sy-repid.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = it_fieldcatalog[]
tables
t_outtab = itab .
simple interactive report
REPORT zintractive .
TYPES : BEGIN OF str_mard,
matnr TYPE mard-matnr,
lgort TYPE mard-lgort,
werks TYPE mard-werks,
END OF str_mard.
DATA : wa_mard TYPE str_mard,
it_mard TYPE TABLE OF str_mard.
TYPES : BEGIN OF str_makt,
matnr TYPE makt-matnr,
maktg TYPE makt-maktg,
END OF str_makt.
DATA : wa_makt TYPE str_makt,
it_makt TYPE TABLE OF str_makt.
TYPES : BEGIN OF str_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
END OF str_mara.
DATA : wa_mara TYPE str_mara,
it_mara TYPE TABLE OF str_mara.
TYPES : BEGIN OF str_final,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
lgort TYPE mard-lgort,
werks TYPE mard-werks,
END OF str_final.
DATA: wa_final TYPE str_final,
it_final TYPE TABLE OF str_final.
PARAMETERS : plant TYPE mard-werks,
stor LIKE mard-lgort.
SELECT matnr
lgort
werks
FROM mard
INTO TABLE it_mard
WHERE lgort = stor AND werks = plant.
.SELECT matnr
maktg
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_mard
WHERE matnr = it_mard-matnr
AND spras = 'E'.
SELECT matnr
ersda
ernam
laeda
mtart
matkl
meins
FROM mara
INTO TABLE it_mara
FOR ALL ENTRIES IN it_makt
WHERE matnr = it_makt-matnr.
LOOP AT it_makt INTO wa_makt.
WRITE : /1 wa_makt-matnr COLOR 1,
40 wa_makt-maktg COLOR 2.
HIDE wa_makt-matnr.
ENDLOOP.
CLEAR wa_mard-matnr.
AT LINE-SELECTION.
REFRESH it_final.
CLEAR wa_final.
ULINE.
IF sy-lsind = 1.
WRITE : /1 'MATERIAL NO' COLOR 2,
20 'CREATION DATE' COLOR 3,
32 'PERSON CREATED',
50 'DATE OF LIST' ,
65 'MATERIALTYPE',
80 'MATGROUP' ,
90 'UNITOFMEASURE',
110 'STORLOCATION' COLOR 4,
130 'PLANT' COLOR 5.
ULINE.
ENDIF.
LOOP AT it_mara INTO wa_mara WHERE matnr = wa_makt-matnr.
wa_final-matnr = wa_mara-matnr.
wa_final-ersda = wa_mara-ersda.
wa_final-ernam = wa_mara-ernam.
wa_final-laeda = wa_mara-laeda.
wa_final-mtart = wa_mara-mtart.
wa_final-matkl = wa_mara-matkl.
wa_final-meins = wa_mara-meins.
READ TABLE it_mard INTO wa_mard WITH KEY matnr = wa_makt-matnr.
wa_final-lgort = wa_mard-lgort.
wa_final-werks = wa_mard-werks.
APPEND wa_final TO it_final.
ENDLOOP.
LOOP AT it_final INTO wa_final.
WRITE :
/1 wa_final-matnr
COLOR 2,
20 wa_final-ersda ,
37 wa_final-ernam,
50 wa_final-laeda ,
70 wa_final-mtart ,
85 wa_final-matkl ,
95 wa_final-meins,
115 wa_final-lgort ,
130 wa_final-werks .
ENDLOOP.
TOP-OF-PAGE.
WRITE : /1 'MATERIAL NO' COLOR 1,
40 'DISCRIPTION' COLOR 2.
ULINE .