Nov 10, 2010
Displaying ALV on the Selection Screen
REPORT zalv_sel_screen . TABLES: mara. DATA: BEGIN OF i_alv OCCURS 0,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
groes TYPE mara-groes,
maktx TYPE makt-maktx,
END OF i_alv. DATA: alv_container TYPE REF TO cl_gui_docking_container. DATA: alv_grid TYPE REF TO cl_gui_alv_grid. DATA: layout TYPE lvc_s_layo. DATA: fieldcat TYPE lvc_t_fcat. PARAMETERS: p_check,
p_file. INITIALIZATION.
PERFORM get_data. AT SELECTION-SCREEN OUTPUT.
PERFORM build_alv.
START- OF-SELECTION.
*************************************************************
* FORM GET_DATA
*************************************************************
FORM get_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE i_alv
FROM mara
INNER JOIN makt
ON mara~matnr = makt~matnr
UP TO 100 ROWS
WHERE makt~spras = sy-langu.
SORT i_alv ASCENDING BY matnr. ENDFORM. "get_data
***************************************************************
* Form Get_Fieldcatalog - Set Up Columns/Headers
****************************************************************
FORM get_fieldcatalog.
DATA: ls_fcat TYPE lvc_s_fcat.
REFRESH: fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '1'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Type'.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '10'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '2'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Group'.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = '3'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Size'.
ls_fcat-fieldname = 'GROES'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = '4'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = '5'.
APPEND ls_fcat TO fieldcat. ENDFORM. "get_fieldcatalog
*&---------------------------------------------------------------------*
*& Form BUILD_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_alv .
DATA: variant TYPE disvariant.
DATA: repid TYPE sy-repid.
repid = sy-repid.
variant- report = sy-repid.
variant-username = sy-uname.
layout-zebra = 'X'.
layout-edit_mode = 'X'.
CHECK alv_container IS INITIAL.
CREATE OBJECT alv_container
EXPORTING
repid = repid
dynnr = sy-dynnr
side = alv_container->dock_at_left
extension = 1500.
CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_container. * ALV Specific. Data selection.
* Populate Field Catalog
PERFORM get_fieldcatalog.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
CHANGING
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[]. ENDFORM. " BUILD_ALV
Output:
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment