Skip to Content
0
Former Member
May 09, 2012 at 05:13 PM

ALV report is showing direct output without reading the select option statement.

16 Views

Dear Friends

My requirement is to display the data from table mara by entering a date range(created on) and user name(created by). my code is given below. This is showing the data directly but not hitting the statement of select option and parameter. can any one check and let me know where is the mistake I did?

REPORT zmara_ext2.

TABLES mara.

PARAMETERS: p_user TYPE mara-ernam.

SELECT-OPTIONS: s_ersda FOR mara-ersda.

DATA: BEGIN OF i_alv OCCURS 0,

matnr TYPE mara-matnr, "Material no.

ersda TYPE mara-ersda, "Created on

ernam TYPE mara-ernam, "Name of Person who Created the Object

mtart TYPE mara-mtart, "Material Type

matkl TYPE mara-matkl, "Material Group

laeda TYPE mara-laeda, "Date of Last Change

aenam TYPE mara-aenam, "Name of Person Who Changed Object

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_user.

INITIALIZATION.

PERFORM get_data.

AT SELECTION-SCREEN OUTPUT.

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[].

START-OF-SELECTION.

*----------------------------------------------------------------------

* FORM GET_DATA

*----------------------------------------------------------------------

FORM get_data.

SELECT matnr

ersda

ernam

mtart

matkl

laeda

aenam

INTO CORRESPONDING FIELDS OF TABLE i_alv

FROM mara

WHERE ersda IN s_ersda AND

ernam EQ p_user.

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 = 'Created On'.

ls_fcat-fieldname = 'ERSDA'.

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 = 'Created By'.

ls_fcat-fieldname = 'ERNAM'.

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 Type'.

ls_fcat-fieldname = 'MTART'.

ls_fcat-ref_table = 'I_ALV'.

ls_fcat-outputlen = '40'.

ls_fcat-col_pos = '5'.

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 = '40'.

ls_fcat-col_pos = '5'.

APPEND ls_fcat TO fieldcat.

CLEAR: ls_fcat.

ls_fcat-reptext = 'Date of Last Change'.

ls_fcat-fieldname = 'LAEDA'.

ls_fcat-ref_table = 'I_ALV'.

ls_fcat-outputlen = '40'.

ls_fcat-col_pos = '5'.

APPEND ls_fcat TO fieldcat.

CLEAR: ls_fcat.

ls_fcat-reptext = 'Changed By'.

ls_fcat-fieldname = 'AENAM'.

ls_fcat-ref_table = 'I_ALV'.

ls_fcat-outputlen = '40'.

ls_fcat-col_pos = '5'.

APPEND ls_fcat TO fieldcat.

CLEAR: ls_fcat.

ENDFORM. "get_fieldcatalog