Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV (Secondary) SORTING????

Former Member
0 Likes
729

Hi Experts,

Am getting sorting as per my requirement [i.e.

1.Material # (ascending)...2.Last Price Change Date (most recent first)..3. Plant (ascending)] in my_ITAB, with the following code,

<i><b>sort i_out ascending

by matnr ascending

laepr descending

werks ascending .</b></i>

But, wanna to get it the same in ALV, so I hv written the code as follows, but NOT working??? particularly, the Last change date of the price, is not sorting(its displaying defaultly/just ascending)

So, how to get it done? Is it some wht related with WA_SORT-GROUP field populating?

<i><b>* wa_sort-spos = 1.

  • wa_sort-fieldname = 'MATNR'.

  • wa_sort-tabname = 'I_OUT'.

  • wa_sort-up = 'X'.

  • APPEND wa_sort TO alv_sort.

*

  • wa_sort-spos = 2.

  • wa_sort-fieldname = 'LAEPR'.

  • wa_sort-tabname = 'I_OUT'.

  • wa_sort-up = 'X'.

    • wa_sort-down = 'X'.

  • APPEND wa_sort TO alv_sort.

  • wa_sort-spos = 3.

  • wa_sort-fieldname = 'WERKS'.

  • wa_sort-tabname = 'I_OUT'.

  • wa_sort-up = 'X'.

  • APPEND wa_sort TO alv_sort.</b></i>

thanq.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
707

Well, for one, the sort logic is commented out. Once you have uncommented it, I would think that this would work, and that you are passing the ALV_SORT to the actually FM call.

* UP
 wa_sort-spos = 1.
 wa_sort-fieldname = 'MATNR'.
 wa_sort-tabname = 'I_OUT'.
 wa_sort-up = 'X'.
 APPEND wa_sort TO alv_sort.

* DOWN
 wa_sort-spos = 2.
 wa_sort-fieldname = 'LAEPR'.
 wa_sort-tabname = 'I_OUT'.
* wa_sort-up = 'X'.
 wa_sort-down = 'X'.
 APPEND wa_sort TO alv_sort.

* UP
 wa_sort-spos = 3.
 wa_sort-fieldname = 'WERKS'.
 wa_sort-tabname = 'I_OUT'.
 wa_sort-up = 'X'.
 APPEND wa_sort TO alv_sort.

Regards,

RIch Heilman

Hi Experts,

Am getting sorting as per my requirement [i.e.

1.Material # (ascending)...2.Last Price Change Date (most recent first)..3. Plant (ascending)] in my_ITAB, with the following code,

<i><b>sort i_out ascending

by matnr ascending

laepr descending

werks ascending .</b></i>

But, wanna to get it the same in ALV, so I hv written the code as follows, but NOT working??? particularly, the Last change date of the price, is not sorting(its displaying defaultly/just ascending)

So, how to get it done? Is it some wht related with WA_SORT-GROUP field populating?

<i><b>* wa_sort-spos = 1.

  • wa_sort-fieldname = 'MATNR'.

  • wa_sort-tabname = 'I_OUT'.

  • wa_sort-up = 'X'.

  • APPEND wa_sort TO alv_sort.

*

  • wa_sort-spos = 2.

  • wa_sort-fieldname = 'LAEPR'.

  • wa_sort-tabname = 'I_OUT'.

  • wa_sort-up = 'X'.

    • wa_sort-down = 'X'.

  • APPEND wa_sort TO alv_sort.

  • wa_sort-spos = 3.

  • wa_sort-fieldname = 'WERKS'.

  • wa_sort-tabname = 'I_OUT'.

  • wa_sort-up = 'X'.

  • APPEND wa_sort TO alv_sort.</b></i>

thanq.

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
708

Well, for one, the sort logic is commented out. Once you have uncommented it, I would think that this would work, and that you are passing the ALV_SORT to the actually FM call.

* UP
 wa_sort-spos = 1.
 wa_sort-fieldname = 'MATNR'.
 wa_sort-tabname = 'I_OUT'.
 wa_sort-up = 'X'.
 APPEND wa_sort TO alv_sort.

* DOWN
 wa_sort-spos = 2.
 wa_sort-fieldname = 'LAEPR'.
 wa_sort-tabname = 'I_OUT'.
* wa_sort-up = 'X'.
 wa_sort-down = 'X'.
 APPEND wa_sort TO alv_sort.

* UP
 wa_sort-spos = 3.
 wa_sort-fieldname = 'WERKS'.
 wa_sort-tabname = 'I_OUT'.
 wa_sort-up = 'X'.
 APPEND wa_sort TO alv_sort.

Regards,

RIch Heilman

Read only

0 Likes
707

.

Message was edited by:

Srikhar

Read only

0 Likes
707

Hi,

Can you change this way


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = alv_repid
it_events = gt_events[]
is_layout = gs_layout
it_fieldcat = alv_fieldcat[]
it_sort = alv_sort[]  "<<<<<<<
TABLES
t_outtab = i_out[]   "<<<<<<

EXCEPTIONS
OTHERS = 1.

aRs

Read only

0 Likes
707

thanq,

yes, its working. and get the same , if i do sorting in itab level also!

but, thing is that, in that case, U can NOT see actual ALV sorting look, I mean, here we get every horizontal line, for every record!

so, do u think, that, bcoz of COLUMN # in fld catlg causing this?

thanq.

Message was edited by:

Srikhar

Read only

Former Member
0 Likes
707

The double '*' suggests that the 'sort-down' parameter is just a comment, could this be the cause?

wa_sort-spos = 2.

  • wa_sort-fieldname = 'LAEPR'.

  • wa_sort-tabname = 'I_OUT'.

  • wa_sort-up = 'X'.

    • wa_sort-down = 'X'.

  • APPEND wa_sort TO alv_sort.

Read only

former_member194669
Active Contributor
0 Likes
707

Hi,

SORT-GROUP is having only two values accepted ie


	*	Page feed    (incl. underline) " Need a page break for group
	UL	Underline   " Need an underline

wa_sort-spos = 2.

wa_sort-fieldname = 'LAEPR'.

wa_sort-tabname = 'I_OUT'.

wa_sort-down = 'X'.

APPEND wa_sort TO alv_sort

aRs