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

sort internal table

Former Member
0 Likes
524

i have a requirement.

I am looking to sort an internal table with wbs element. I want to sort the internal table such a way that all the entries that have wbs element appears at top in ascending order and then those that dont have wbs element.

if i try sort ascending then blank entries come first.

help please..

thanks in advance

Hitesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
487

Hi

U can try to do something like this:

ITAB-WBS = 'ZZZZZZZZZ'.

MODIFY ITAB TRANSPORTING WBS WHERE WBS = SPACE.

SORT ITAB BY WBS.

CLEAR ITAB-WBS.

MODIFY ITAB TRANSPORTING WBS WHERE WBS = 'ZZZZZZZZZ'.

So u insert a value where the WBS is blank, sort the table and then clear WBS where u have inserted the false value.

Max

3 REPLIES 3
Read only

Former Member
0 Likes
487

Hello,

Use SORT ITAB <b>DESCENDING</b> by POSID.

If useful reward.

vasanth

Read only

Former Member
0 Likes
488

Hi

U can try to do something like this:

ITAB-WBS = 'ZZZZZZZZZ'.

MODIFY ITAB TRANSPORTING WBS WHERE WBS = SPACE.

SORT ITAB BY WBS.

CLEAR ITAB-WBS.

MODIFY ITAB TRANSPORTING WBS WHERE WBS = 'ZZZZZZZZZ'.

So u insert a value where the WBS is blank, sort the table and then clear WBS where u have inserted the false value.

Max

Read only

Former Member
0 Likes
487

It is not possible to achieve that by the SORT statement on WBS Element.

The only solution is that you include a field in the internal table say KEY and populate the same with '1' if WBS Element is not space and '9' if it is space.

After that sort the internal table using key and wbs element.

SORT itab by key wbselement.

Result of the same would be as you want.

Regards

Anurag