‎2021 Feb 05 9:36 AM
I need to sort the it_mseg internal table in ascending order for the bwart and mkpf_budat fields.
I am trying to use this statement:
ORDER it_mseg FOR budat_mkpf bwart.
but it doesn't work because it only sorts for one field I also tried like this:
order it_mseg by bwart.
order stable it_mseg of budat_mkpf.
how do i do it? thanks
‎2021 Feb 05 9:50 AM
Normally the code should look like this:
SORT it_mseg BY field_a ASCENDING field_b DESCENDING.Are you sure that you can modify the contents of your table [it_mseg]? If it is an import parameter, it might be protected against changes.
‎2021 Feb 05 9:38 AM
Hello mark.fryu
If you want to sort an internal table then what you're looking for is SORT keyword.
https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapsort_itab.htm
Kind regards,‎2021 Feb 05 9:45 AM
I tried "sort" but it didn't work, can you give me an instruction with the sort to try?
‎2021 Feb 05 10:34 AM
‎2021 Feb 05 9:50 AM
Normally the code should look like this:
SORT it_mseg BY field_a ASCENDING field_b DESCENDING.Are you sure that you can modify the contents of your table [it_mseg]? If it is an import parameter, it might be protected against changes.
‎2021 Feb 05 10:01 AM
yes I can modify the internal table, it's my report, I also tried this instruction but it sorts only for the first field, in this example of yours it sorts only for the field field_a
‎2021 Feb 05 10:32 AM
Patricks example should work. Please update your question with your exact code and we will be able to help. Also please show us your data before and after the sort, where we can see the data not sorted properly.
‎2021 Feb 05 10:36 AM
‎2021 Feb 05 9:53 AM
Please show us your exact code.
Do you mean to use to SORT statement after there already is data in it_mseg? Or are you trying to use the ORDER BY to get the data sorted already from a SELECT query?
‎2021 Feb 05 1:53 PM
I'm guessing this question is the output of automated translation!