Skip to Content
author's profile photo Former Member
Former Member

Behavior of ' SORT BY ' in ABAP

Hello All,

The variable field0_1, field0_2, field1_1, field1_2 are filled as per required.

An internal Table I_TAB with col1, col2.

SORT I_TAB BY field0_1 asc field0_2 desc field1_1 asc field1_2 desc .

Case 1: field0_1 is filled with col1. Rest all other variables are blank.

Behavior: After I_TAB is sorted by col1 , it gets inverted. [ Because of desc ]

How can I stop this behavior.

In actual scenario I have around 10 fields with which I need to sort based on priority,

Kindly give your inputs

Thanks & Regards,

Rohit

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2014 at 01:17 PM

    Try SORT ...STABLE keyword addition.

    If it doesn't work, please post a more complete snippet so that we can run it at our end and observe the data.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 28, 2014 at 03:48 PM

    Can you post the actual code of your SORT statement, here you seems to use dynamic fields for the statement :

    SORT I_TAB BY  (field0_1) ASCENDING (field0_2) DESCENDONG ?
    

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.