Skip to Content
0
Former Member
Feb 21, 2011 at 11:40 PM

whats wrong with my alv code ?

36 Views

hello friends,

I am doing ALV display, and dont know what I am doing wrong.. please suggest:

DATA: o_alv_grid TYPE REF TO cl_gui_alv_grid.

DATA: o_gui_cont TYPE REF TO cl_gui_container.

DATA: lt_field_cat TYPE lvc_t_fcat.

IF o_gui_cont IS INITIAL.

CREATE OBJECT o_gui_cont

EXPORTING

clsid = space

container_name = 'ALV_GRID'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

lifetime_dynpro_illegal_parent = 6

OTHERS = 7.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

  • PERFORM set_field_catalog TABLES lt_field_cat.

CREATE OBJECT o_alv_grid

EXPORTING

i_parent = o_gui_cont

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*

  • DATA: w_layo TYPE lvc_s_layo.

*

  • * layout design

  • w_layo-no_toolbar = ''.

    • not to allow totaling feature

  • w_layo-no_totline = 'X'.

    • report title

  • w_layo-grid_title = text-004.

  • w_layo-grid_title = 'TEST'.

  • w_layo-zebra = 'X'. "Alternating line color (striped)

  • w_layo-cwidth_opt = 'X'. "Optimize column width

  • w_layo-sel_mode = 'A'. "Selection Mode

    • name of the color field

  • w_layo-info_fname = 'LINE_COLOR'."For row color

  • CALL METHOD o_alv_grid->set_table_for_first_display

    EXPORTING

    • i_buffer_active =

    • i_bypassing_buffer =

    • i_consistency_check =

    i_structure_name = 'ZFI_ALV_STR'

    • is_variant =

    i_save = 'A'

    • i_default = 'X'

    • is_layout = w_layo

    • is_print =

    • it_special_groups =

    • it_toolbar_excluding =

    • it_hyperlink =

    • it_alv_graphics =

    • it_except_qinfo =

    • ir_salv_adapter =

    CHANGING

    it_outtab = lt_error_msg

    • it_fieldcatalog = lt_field_cat

    • it_sort =

    • it_filter =

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    OTHERS = 4

    .

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.