11-13-2006 11:21 AM
Hi,
i have a requirement i displayed output BY using ALV List Display .Iam displaying quarter ,year,sales group,site(kunnr),amount,etc in in li list disply. now my requirement is when i click sort(Ascending or descending) and select the fileds as sales group,site,quarter then it has to display output in that format.
any body can send the sample code plz.
its very urgent.
11-13-2006 11:28 AM
Hi,
Use the Sort internal table IT_SORT of the ALV function module..
<b>Add the rows for the key fields in the IT_SORT internal table.</b>
<b>Spos Sort sequence
Fieldname Internal output table field name
Tabname Name of the internal output table
Up 'X' = sort in ascending order
Down 'X' = sort in descending order
Subtot 'X' = subtotal at group value change
group '* ' = new page at group value change
'UL' = underline at group value change</b>
Here is the sample code ...
Here is the code.
sort-fieldname = 'First field'.
sort-spos = 1.
sort-up = 'X'.
append Sort.
sort-fieldname = 'Second field'.
sort-spos = 2.
sort-up = 'X'.
sort-group = 'UL' . " Underline
append Sort.
sort-fieldname = 'Third Field'.
sort-spos = 3.
sort-up = 'X'.
append Sort.
sort-fieldname = 'Fourth Field'.
sort-spos = 4.
sort-up = 'X'.
append Sort.
Regards
Sudheer
11-13-2006 11:28 AM
Hi,
Use the Sort internal table IT_SORT of the ALV function module..
<b>Add the rows for the key fields in the IT_SORT internal table.</b>
<b>Spos Sort sequence
Fieldname Internal output table field name
Tabname Name of the internal output table
Up 'X' = sort in ascending order
Down 'X' = sort in descending order
Subtot 'X' = subtotal at group value change
group '* ' = new page at group value change
'UL' = underline at group value change</b>
Here is the sample code ...
Here is the code.
sort-fieldname = 'First field'.
sort-spos = 1.
sort-up = 'X'.
append Sort.
sort-fieldname = 'Second field'.
sort-spos = 2.
sort-up = 'X'.
sort-group = 'UL' . " Underline
append Sort.
sort-fieldname = 'Third Field'.
sort-spos = 3.
sort-up = 'X'.
append Sort.
sort-fieldname = 'Fourth Field'.
sort-spos = 4.
sort-up = 'X'.
append Sort.
Regards
Sudheer
11-13-2006 11:41 AM
Hi..
************use this code to sort the alv list.. you can do either ascending or descending..
type-pools: slis.
data: i_sort type slis_t_sortinfo_alv .
**********************call the sub routine before the start-of-selection event.
PERFORM sort USING i_sort.
call the alv grid function module.. pass the sort internal table..
for example:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_USER_COMMAND = 'USER_CMD'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_BACKGROUND_ID = 'ALV_BACKGROUND'
I_GRID_TITLE = 'OPEN QUOTATION'
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = IT_FCAT1[]
IT_SORT = I_SORT[] "<----
internal table for sorting
IT_EVENTS = I_EVENT[]
TABLES
T_OUTTAB = IT_FINAL1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
********check the type-pool slis for all the fields in slis_t_sortinfo_alv.
&----
*& Form sort
&----
text
----
-->P_I_SORT text
----
FORM sort using p_sort type slis_t_sortinfo_alv.
data k_sort type slis_sortinfo_alv .
k_sort-fieldname = 'VBELN'.
k_sort-spos = 1.
k_sort-up = 'X'. <----- for ascending order..
k_sort-subtot = 'X'.
k_sort-group = '*'.
APPEND k_sort TO p_sort.
ENDFORM. " sort
regards
kothai venkatasamy
11-13-2006 11:44 AM
hi
good
go through this links, which ll give you brief idea about the change layout.
http://www.erpgenie.com/sapgenie/docs/Using%20ALV.pdf
http://www.cdg-inc.com/news/WhitePaper_ALV_Reporting_Power.htm
http://help.sap.com/saphelp_nw04/helpdata/en/8d/e994374c9cd355e10000009b38f8cf/frameset.htm
thanks
mrutyun^