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 Internal Tables by Non-Key Fields

Former Member
0 Likes
2,109

Hi All,

Would the performance of sort be degraded if I used non-key fields rather than key fields for the sort command?

Thanks and Regards,

Vidya.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,382

Hi

All char fields are key fields for an internal table, so the performance can be degraded only as y make one operation more the sorting, and this is not dependent on which fields used by the sorting.

The sorting needs to certain time and memory space, so u should do it only if u need it

Max

4 REPLIES 4
Read only

Former Member
0 Likes
1,383

Hi

All char fields are key fields for an internal table, so the performance can be degraded only as y make one operation more the sorting, and this is not dependent on which fields used by the sorting.

The sorting needs to certain time and memory space, so u should do it only if u need it

Max

Read only

Sidh_M
Participant
0 Likes
1,382

hi vidya,

i guess if we use non-key fields rather then key fields it would affect performance.

go through following link

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm

also

SORT inside a LOOP should not used

Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work

For large internal tables where only some rows are to be processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IFu2026EXITu2026ENDIF as appropriate to exit from the loop

Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 ASCENDING)

Hashed table is used for processing large amount of data (provided that you access single records only, and all with a fully specified key)

DELETE or SORT is not used on a hashed table since it increases memory consumption

Sorted table is used for range accesses involving table key or index accesses

Reward points if it is help full in any way

Regards,

SUDHIR MANJAREKAR

Read only

Former Member
0 Likes
1,382

a SORT is only useful on a standard table

and a standard table has no real key. You can define something as key, but this has no effect.

Use SORT if you want display something in a certain order.

Or use SORT if you want to use READ BINARY SEARCH. The read binary search works always, but only correctly if the table is sorted in the same way.

Your table should only be sorted once program execution, I doubt that it will make sense to sort it several times.

Siegfried

Read only

Former Member