‎2011 Feb 21 11:40 PM
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.
‎2011 Feb 22 12:41 AM
do i need to have screen and pbo and pai in oder to display alv ?
please suggest, I am getting confused...
Thanks.
‎2011 Feb 22 2:12 AM
Hi ,
No, you actually don't need a PBO or PAI to display ALV, unless you have a requirement of additional push buttons on screen.
In the code given, you have commented the IS_LAYOUT parameter and changing table IT_FIELDCATALOG , but you need these to arrange the ALV, so pass proper values in IS_LAYOUT (according to your requirement) and manually fill the fieldcatalog or do it with the FM.
Hope this answers your query.
-MBD2186
‎2011 Feb 22 2:29 AM
Hi Shah,
No it is not compulsory to write code in PBO and PAI events.
Though, you should call the "SET_TABLE_FOR_FIRST_DISPLAY" module in the PBO event to make sure that the table gets refreshed everytime.
Also,
In you code you have not called a screen which is used to display the ALV.
See program BCALV_GRID_DEMO to have a better idea.
Line 13 : CALL SCREEN 100.Double click on 100 in the code to see how the screen is defined incase you do not already know it.
Regards,
Jovito.
‎2011 Feb 22 5:27 AM
Hi Shah H.,
Few Changes need to be incurred:
1. Did you created a Container on Screen where you want to Display your ALV.
2. Code doesnt contain CALL SCREEN.
3. lt_error_msg is not populated.
Correct Soln:
1. Call a screen and add Custom Container.
2. Create Object of Class: CL_GUI_CUSTOM_CONTAINER.
3. Create ALV Grid instance.
4. Build a Field Catalog.(Optional)
5. Build Layout(Optional)
6. Display Using Method: SET_TABLE_FOR_FIRST_DISPLAY.
Hope its Clear.
For Code: Check Program BCALV_GRID_DEMO
Regards,
Ankit.