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

Sorting order in different manner.

kavya_2017
Explorer
0 Likes
449

Hi Experts,

I have a requirement where an internal table itab has some fileds.

and one of those fields say 'x' will be having values like Z002,Z003,Z010,Z012....

Now i have to sort the above internal table and i should get the records in the below manner

1) Firstly i should get records with field 'x' = Z012

2) Then i should get records with field 'x' = Z002

3) Then i should get records with field 'x' = Z010

4) Then i should get records with field 'x' = Z003

Again for this records i have to sort the internal table by other fields

5) i should get the records with field 'x' = other than above values.

Please let me know can we achieve this by using Sort statement or what logic we can apply to get the above result.

Thank you,

Regards,

Kavya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
423

Hi,

Take another field say NUM in your internal table(ITAB) and assign 1 to the records where field 'x' = Z012

similarly assign 2 to the records where field 'x' = Z002 .....

Do this while populatin ITAB.

Now sort ITAB by NUM x other_field1 ....

Regards,

Srini.

2 REPLIES 2
Read only

Former Member
0 Likes
424

Hi,

Take another field say NUM in your internal table(ITAB) and assign 1 to the records where field 'x' = Z012

similarly assign 2 to the records where field 'x' = Z002 .....

Do this while populatin ITAB.

Now sort ITAB by NUM x other_field1 ....

Regards,

Srini.

Read only

0 Likes
423

Hi,

Your logic was very helpful.

Thanks,

Kavya