cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting string in text view

Former Member
0 Kudos

Good day,

In web dynpro, I'm trying to split string field into specific format as following:

Field value in DB table: 'user_id1 Date1 Time1 comment_text1 user_id2 Date2 Time2 comment_text2' as one field.

Field type is STRING.

After fetching this field from DB table, I need to split the string as following:

user_id1 Date1 Time1

comment_text1

********************************

user_id2 Date2 Time2

comment_text2

*******************************

Regards;

Habeeb

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Is  your issue resolved?...if not please revert back

Thanks

KH

Former Member
0 Kudos

Hi,

Recently i got the same requirement and CR_LF does'nt works for me.Alternatively i used

CL_ABAP_CHAR_UTILITIES=>NEWLINE.

You can achieve this in various ways.

1) If your comments are fixed i,e as per shown above, use below code.

Data LV_STRING type STRING.

CONCATENATE USER_ID1 DATE1 TIME1 INTO LV_STRING SEPERATED BY SPACE.

CONCATENATE LV_STRING <COMMENT_TEXT1> INTO LV_STRING SEPERATED BY

CL_ABAP_CHAR_UTILITIES=>NEWLINE.

CONCATENATE LV_STRING '********************************' INTO LV_STRING SEPERATED BY 

CL_ABAP_CHAR_UTILITIES=>NEWLINE.

CONCATENATE LV_STRING USER_ID2 DATE2 TIME2 INTO LV_STRING SEPERATED BY SPACE.

CONCATENATE LV_STRING <COMMENT_TEXT2> INTO LV_STRING SEPERATED BY

CL_ABAP_CHAR_UTILITIES=>NEWLINE.

CONCATENATE LV_STRING '********************************' INTO LV_STRING SEPERATED BY 

CL_ABAP_CHAR_UTILITIES=>NEWLINE.

2) Else, you can achieve the same in LOOP statement as well.

Hope this helps you to resolve your issue.

Thanks

KH

Former Member
0 Kudos

Just use the concatenate Statement and CR_LF to get the new lines.