2009 Apr 08 4:58 PM
hi there experts...
I´m doing an alv report and I want to know if it's possible to sort the alv like I'm going to explain:
WA_SORT-SPOS = 1.
WA_SORT-FIELDNAME = 'EKGRP'.
WA_SORT-TABNAME = 'T'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = 2.
WA_SORT-FIELDNAME = 'EKNAM'.
WA_SORT-TABNAME = 'T'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.I want to sort this two fields in order that, i just want to group the equal values of EKNAM that correspond to a single value of EKGRP nad not to group all equal values of EKNAM with diferent EKGRP values.
Output Example of what I want:
EKGRP | EKNAM | DESC
-----------|----------|-------------
1 | 001 | blabla1
|----------|-------------
| 002 | blabla2
| |-------------
| | blabla3
-----------|----------|-------------
2 | 002 | blabla4
| |-------------
| | blalba5
|--------- |--------------
| 012 | blabla6With normal sort, value 002 for EKNAM field is grouped independently from the value of EKGRP field...
Is it possible to do??
Tanks
Edited by: Hermano.Andrade on Apr 8, 2009 5:59 PM
2009 Apr 08 5:07 PM
HI,
Refer to this link..https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/sortinALV
Opp's sorry it is not possible...if the value is same for the corresponding two values in the different sort column then the values are merged and displayed at first instead of showing once again if any change in the any of the values in other sort column.
Instead you can update the internal table in the same way as required and display as the output. The restriction on this you need to disable the sort buttons on the alv and no other operations to be performed.
2009 Apr 08 5:08 PM
Hi Hermano,
can you try below
SORT itab by EKGRP EKNAM ,hope it works
Thanks!
2009 Apr 08 5:15 PM
yes it is possible with the way you are trying
just maintain the sequence...
Regards,
Lalit Mohan Gupta.
2009 Apr 09 5:41 AM
Hi,
Yes, you are right.
Use the code to sort output w.r.t. these two fields (based on the combination of both).
Let me know in case you have any doubts.
Regards,
Tarun
2009 Apr 09 6:37 AM
hi, check this one.
Loop at itab.
AT NEW EKGRP.
FLAG = 'X'.
ENDAT.
AT NEW EKNAM.
FLAG1 = 'X'.
ENDAT.
IF FLAG ='X'.
MOVE CORRESPONDING ITAB TO WA_TAB.
APPEND WA_TAB TO ITAB1.
ELSE.
CLEAR ITAB-EKGRP.
MOVE CORRESPONDING ITAB TO WA_TAB.
APPEND WA_TAB TO ITAB1.
ENDIF.
IF FLAG1 ='X'.
MOVE CORRESPONDING ITAB TO WA_TAB.
APPEND WA_TAB TO ITAB1.
ELSE.
CLEAR ITAB-EKNAM.
MOVE CORRESPONDING ITAB TO WA_TAB.
APPEND WA_TAB TO ITAB1.
ENDIF.
ENDLOOP.