简体   繁体   中英

How do I sort the data received from the user, from large to small in SAP ABAP?

I get a variable number of data from the user with the parameter. I want to sort (descending ascending) them among themselves. I tried using order by , but I don't know how to solve it.

My data is separated as follows:

SPLIT sayilar AT '-' INTO TABLE it_char.

I tried these. I guess I can't find what I want. Below is the block of code I tried to sort. I'm doing something wrong, but I don't know what happened.

SORT it_char DESCENDING.
LOOP AT it_char INTO wa_char.
  WRITE :/ wa_char.
ENDLOOP.

skip 2.

SORT it_char ASCENDING.
LOOP AT it_char INTO wa_char.
  WRITE :/ wa_char.
ENDLOOP.

I set the variable type to c but it doesn't work correctly in double digit numbers.

my parameters screen:

我的参数屏幕

my report screen:

我的报告屏幕

In order to sort an internal table, use the SORT keyword .

To sort a table of strings or type C alphabetically, use:

SORT it_char ASCENDING AS TEXT.

When the line type of the table is numerical and you want to sort from large to small:

SORT it_char DESCENDING.

More information can also be found in this help article .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM