如题,
原题要求先拆分一个随意的英文string,然后loop循环。
代码如下:
DATA: str1 TYPE string,
itab TYPE TABLE OF string,
text TYPE string VALUE 'Presentation styles of search results have been constantly changing in these years, which affect users'' click-through behaviors. In order to discover what the'.
SPLIT text AT space INTO TABLE itab.
LOOP AT itab INTO str1.
WRITE :/ str1.
ENDLOOP.
现在需要把内表中的多行结果又重新的合并起来,求大神讲解。
使用关键字CONCATENATE:
CONCATENATE LINES OF itab INTO text SEPARATED BY space.
DATA: str1 TYPE string,
itab TYPE TABLE OF string,
text TYPE string VALUE 'Presentation styles of search results have been constantly changing in these years, which affect users'' click-through behaviors. In order to discover what the'.
SPLIT text AT space INTO TABLE itab.
LOOP AT itab INTO str1.
WRITE :/ str1.
ENDLOOP.
"CONNECT STRING、
DATA:LV_STR_RESULT TYPE STRING,
LV_STR_TEMP TYPE STRING,
LV_FLAG TYPE C.
LOOP AT ITAB INTO STR1.
LV_STR_TEMP = STR1.
CLEAR:LV_FLAG.
AT FIRST.
LV_STR_RESULT = LV_STR_TEMP.
LV_FLAG = 'X'.
ENDAT.
IF LV_FLAG NE 'X'.
CONCATENATE LV_STR_RESULT STR1 INTO LV_STR_RESULT SEPARATED BY SPACE.
ENDIF.
ENDLOOP.
WRITE:/ '原字符串 ' ,TEXT.
WRITE:/ '拼接字符串', LV_STR_RESULT.
注意下首行