用SAP ABAP如何转换输入字串为数值并输出! 5
如下ORCAL语句的作用是输入带逗号的字符串,如何用SAPABAP转换为数字,并排序的形式输出?SELECTstrFROM(SELECT('regexp_substr(1...
如下ORCAL语句的作用是输入带逗号的字符串,如何用SAP ABAP转换为数字,并排序的形式输出?
SELECT str
FROM (SELECT ('regexp_substr(1,2,5,7,9)', '\d', 1, LEVEL) str FROM dual CONNECT BY LEVEL < = length('1,2,5,7,9')) WHERE str IS NOT NULL ORDER BY str DESC 输出结果需要为如下:97521 展开
SELECT str
FROM (SELECT ('regexp_substr(1,2,5,7,9)', '\d', 1, LEVEL) str FROM dual CONNECT BY LEVEL < = length('1,2,5,7,9')) WHERE str IS NOT NULL ORDER BY str DESC 输出结果需要为如下:97521 展开
2个回答
展开全部
1.先定义画面元素来接这个输入的字串,假设定义为c1
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
PARAMETERS : c1(100) type c. SELECTION-SCREEN END OF BLOCK BLK2. 2.再定义一个table: itab
types: begin of itab_type,
num(3) type n, end of itab_type.data: itab type STANDARD TABLE OF itab_type with HEADER LINE. 3.用split来切割c1
SPLIT c1 AT ',' INTO table itab.
然后在对itab里的值进行排序
sort itab DESCENDING BY num ASCENDING .
4.在用loop循环输出itab的值
LOOP AT itab.
WRITE: (3) itab-num,','. ENDLOOP.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
PARAMETERS : c1(100) type c. SELECTION-SCREEN END OF BLOCK BLK2. 2.再定义一个table: itab
types: begin of itab_type,
num(3) type n, end of itab_type.data: itab type STANDARD TABLE OF itab_type with HEADER LINE. 3.用split来切割c1
SPLIT c1 AT ',' INTO table itab.
然后在对itab里的值进行排序
sort itab DESCENDING BY num ASCENDING .
4.在用loop循环输出itab的值
LOOP AT itab.
WRITE: (3) itab-num,','. ENDLOOP.
展开全部
DATA : LV_STR TYPE STRING.
DATA : STR1 TYPE STRING, STR2 TYPE STRING, STR3 TYPE STRING, TEXT TYPE STRING.DATA : LT_TAB TYPE TABLE OF STRING.LV_STR = '9,3,8,4,1,7'.SPLIT LV_STR AT ',' INTO TABLE LT_TAB IN CHARACTER MODE.SORT LT_TAB ASCENDING.LOOP AT LT_TAB INTO STR1. CONCATENATE STR1 TEXT INTO TEXT.ENDLOOP.WRITE : / TEXT. 如果正确,给满意答案哈!
DATA : STR1 TYPE STRING, STR2 TYPE STRING, STR3 TYPE STRING, TEXT TYPE STRING.DATA : LT_TAB TYPE TABLE OF STRING.LV_STR = '9,3,8,4,1,7'.SPLIT LV_STR AT ',' INTO TABLE LT_TAB IN CHARACTER MODE.SORT LT_TAB ASCENDING.LOOP AT LT_TAB INTO STR1. CONCATENATE STR1 TEXT INTO TEXT.ENDLOOP.WRITE : / TEXT. 如果正确,给满意答案哈!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询