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

sorting the internal table I'm getting ......

While sorting the internal table I'm getting one of the columns not sorted .... why is that? for example

A B C

9 2 11

4 9 10

8 3 7

using ---> sort itab by A B C. gives me this

A B C

4 2 7

8 9 10

9 3 11

please help?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:30 AM

    are you sure ? because it gives me

    4 | 9 | 10

    8 | 3 | 7

    9 | 2 | 11

    like this and it is the correct one.

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 11, 2007 at 08:25 AM

    Hi,

    When you sort, sort operation will follow the order you give the columns if you give SORT by A B C that order will be taken if you give B A C then that order will be followed.

    SO thats why you see that result.

    Regards,

    Sesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:23 AM

    hi Essa,

    It would be better if you could sort it with key fields .. and more over the order in which you might have used the sort statement is

    sort ITAB by B A C.

    Note : Please close your previous theread by marking helpful answers

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:35 AM

    Hi,

    check this code,

    REPORT ZEX31 .

    data : begin of itab occurs 0,

    f1 type i,

    f2 type i,

    f3 type i,

    end of itab.

    itab-f1 = 9 .

    itab-f2 = 2.

    itab-f3 = 11 .

    append itab.

    clear itab.

    itab-f1 = 4 .

    itab-f2 = 9.

    itab-f3 = 10 .

    append itab.

    clear itab.

    itab-f1 = 8 .

    itab-f2 = 3.

    itab-f3 = 7 .

    append itab.

    clear itab.

    loop at itab.

    write : / itab-f1 , itab-f2 , itab-f3.

    endloop.

    sort itab by f1 f2 f3.

    skip 2.

    loop at itab.

    write : / itab-f1 , itab-f2 , itab-f3.

    endloop.

    sorting will be based on the order u give,

    if u give order f1 f2 f3 then first f1 will be checked and sorted in the order of it.

    o/p will be

    4 9 10

    8 3 7

    9 2 11

    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.