Application Development 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: 

A question about sorted table...

aris_hidalgo
Contributor
0 Kudos
63

Hello experts,

Recently I have been trying to optimize a certain report. On a certain part of a report the original programmer made this statement:

sort it_vendor by lifnr akont.

Now, I tried to experiment using sorted table so I can hopefully cut the response time of the report. Below is what I did:

TYPES: BEGIN OF s_vendor,

lifnr LIKE lfb1-lifnr,

akont LIKE lfb1-akont,

END OF s_vendor.

DATA: it_vendor TYPE SORTED TABLE OF s_vendor WITH NON-UNIQUE KEY lifnr

akont.

My question is, is my sorted table have the same effect as the statement the original programmer did?T^hanks guys!

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
33

Meaning, will you end up with the same data in the same order, then yes. It is the same.

F1 Help.

<i>You cannot sort a sorted table using the SORT statement. The system always maintains these tables automatically by their sort order. If an internal table is statically recognizable as a sorted table, the SORT statement causes a syntax error. If the table is a generic sorted table, the SORT statement causes a runtime error if the sort key is not the same as an extract of the beginning of the table key, you sort in descending order, or use the AS TEXT addition. In other words, the SORT statement is only allowed for generic internal tables, if it does not violate the internal sort order.</i>

Regards,

Rich Heilman

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
34

Meaning, will you end up with the same data in the same order, then yes. It is the same.

F1 Help.

<i>You cannot sort a sorted table using the SORT statement. The system always maintains these tables automatically by their sort order. If an internal table is statically recognizable as a sorted table, the SORT statement causes a syntax error. If the table is a generic sorted table, the SORT statement causes a runtime error if the sort key is not the same as an extract of the beginning of the table key, you sort in descending order, or use the AS TEXT addition. In other words, the SORT statement is only allowed for generic internal tables, if it does not violate the internal sort order.</i>

Regards,

Rich Heilman

0 Kudos
33

Hi Rich,

Thanks for the helpful reply. Anyway, can you please suggest more performance techniques that I can use in my report? how about field-symbols?is it like a header line?logical databases? thanks again man!

0 Kudos
33

The biggest bang you will get for improving performance is making your select statements efficient. Make sure that your program is not spending too much time retrieving the data. Make sure that the select statements are using the keys of the table the WHERE clause(or the keys of an index). I would start there first.

Regards,

Rich Heilman