‎2007 Dec 11 9:10 AM
Hello
This sort statement is taking too much of time.
SORT MAKT_KEYTAB BY MATNR SPRAS.
Is there any option using which we can optimise this ?
Thanks
Sudha
‎2007 Dec 11 9:15 AM
‎2007 Dec 11 9:16 AM
‎2007 Dec 11 9:18 AM
DATA: BEGIN OF MAKT_KEYTAB OCCURS 0,
MANDT LIKE SYST-MANDT,
MATNR LIKE MAKT-MATNR,
SPRAS LIKE MAKT-SPRAS,
END OF MAKT_KEYTAB.
‎2007 Dec 11 9:27 AM
DATA: BEGIN OF MAKT_KEYTAB OCCURS 0,
<b>MANDT LIKE SYST-MANDT,</b> ==> you don't need this line
MATNR LIKE MAKT-MATNR,
SPRAS LIKE MAKT-SPRAS,
END OF MAKT_KEYTAB.
‎2007 Dec 11 9:23 AM
hI
MAKE IT AS binary SEARCH
SORT MAKT_KEYTAB BY MATNR SPRAS binary serach .
The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.
IF the int table is sorted by a key, then when BINARY SEARCH is added to a WITH KEY statement... the "read" to the int table is performed at a binary level for maximum performance.
if N is the number of entries in your itab, linear search is done in O(N) and binary search is done in O(logN).
use it if your itab is big, just don't forget to sort it if it's a standard table.
‎2007 Dec 11 9:31 AM
Don't think that any thing can be done to increase the performance of this SORT statement. Better try to split data in different tables.
‎2007 Dec 11 9:33 AM
Hi,
It should work, may be because of huge amount of data it is taking lot of time.
try to move the MANDT field into last postion and then try.
reward if needful.
Thanks,
Sreeram.
‎2007 Dec 11 9:38 AM
Hi,
You dont need to use MANDT and declaration there in internal table.
Use SORT statement including ASCENDING oor DESCENDING statement after that.
For e.g SORT INT_TAB ASCENDING BY MATNR SPRAS .
General Syntax :
SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE].
Thanks,
Sakthi C