‎2010 Jan 20 4:45 PM
Hi All,
Greetings for the Day!!!
am using alv oops for displaying output..
BEFORE sorting my internal table looks like below in the output.....
for example
A
B
C
D
E
F
AFTER sorting the internal table in the output .display.,, the internal table shows like below
F
E
D
C
B
A
but when i call the method set_table_for_first_display ,after sorting the in the output display ....,the internal table remains as like before
A
B
C
D
E
F....
it should be lke
F
E
D
C
B
A .....
kindly suggest me the alternatives.pls
Regards
Jack
‎2010 Jan 20 7:31 PM
‎2010 Jan 20 7:22 PM
You are using ASCENDING sorting type and should be DESCENDING . What I understand is that you want to do sorting in the output (manually in frontend). Therefore you need to use descending sorting option (icon).
If you want to do this using code then use below
"fill the ls_sort strcutre
data: ls_sort type lvc_s_sort.
ls_sort-fieldname = 'FIELDNAME_TO_SORT'.
ls_sort-down = 'X'. "you need descending sorting, not ascending so this one should be used
"then simply pass it to
call method grid->set_table_for_first_display
....
sort = ls_sort
"the output will show rows sorted descending
Regards
Marcin
‎2010 Jan 20 7:31 PM
‎2010 Jan 20 7:34 PM
For example....
DATA: lo_alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: lo_form_alv_container TYPE REF TO cl_gui_custom_container.
* Create Controls
IF lo_form_alv_container IS INITIAL. "<-- Check if already created
CREATE OBJECT lo_form_alv_container
EXPORTING
container_name = 'FORMULA_CONTAINER'.
* Create control based ALV grid
CREATE OBJECT lo_alv_grid
EXPORTING
i_parent = lo_form_alv_container.
....
* set for first display
lo_alv_grid->set_table_for_first_display(
EXPORTING
is_layout = ls_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = lt_formulas[]
it_fieldcatalog = lt_fieldcat[] ).
ELSE.
lo_alv_grid->refresh_table_display( ). "<-- If so, just refresh
ENDIF.Regards,
Rich Heilman
‎2010 Jan 27 5:52 AM
Hi,
set_table_for_first_display has to be called only once. to retain sorting order and filter call refresh_table_display.
However if there is any structure changes on your ALV or for field catalog changes, you have to make a call again to Set_table_for_first_display, in th at case, you will loose the sort order set by the user previously.
Regards,
Bhuvana