用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.
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
展开全部
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. 如果正确,给满意答案哈!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询