03-28-2007 11:49 AM
Hi,
I have a internal table called itab, which has to be sorted with different keys. The priorities of the keys is decided at the runtime.
Consider the below statement where industry, term, amt are fields of the itab:
<b>SORT itab BY industry DESCENDING term DESCENDING amt DESCENDING.</b>
Here the itab is sorted with highest priority as industry, followed by term, followed by amt.
But now the requirement is that this priority might change. I will have three variables deciding the priority. assuming tat p1, p2 and p3 are the priority variables, how can i use these variables to sort this itab at runtime ???
Thanks and Regards,
Ajit
03-28-2007 11:53 AM
if priority = 1.
SORT itab BY industry DESCENDING term DESCENDING amt DESCENDING.
elseif priority = 2.
SORT itab BY term DESCENDING amt DESCENDING industry DESCENDING .
else.
SORT itab BY term DESCENDING industry DESCENDING amt DESCENDING .
endif.
like that
regards
shiba dutta
03-28-2007 11:56 AM
Hi...
Thanks for replying. There are 8 different possiblities rite ??
Regards,
Ajit
03-28-2007 11:56 AM
Hi...
Thanks for replying. There are 8 different possiblities rite ??
Regards,
Ajit
03-28-2007 12:04 PM
i dont know what your priority variable is containing and how you want to sort them but you have to do your combination as per your requirement.
regards
shiba dutta
03-28-2007 12:12 PM
The priority variable is containing the field name.
Example-
p1 = 'industry'
p2 = 'term'
p3 = 'amt'
so it can contain 8 combinations of values......