2016 Jul 28 12:57 AM
Hello, I am trying to split a long string in parts equals for after to insert this information on fields different, for example:
Split to var_textlong and put each result on:
v_text1 that after will be inserted on text1 of my table Z.
v_text2 that after will be inserted on text2 of my table Z.
Etc..
This is like the SAP ERP saves information with a lot of characters in its tables.
I try to making this of the next form but I have problems with the validation, if a valor be passed to split the string, my code broke
v_str = 'A long text.....'
v_value1 = STRLEN( v_str ) / 3.
v_value2 = v_value1 + v_value1.
v_desc1 = v_str(v_value1).
v_desc2 = v_str+v_value1(v_value1).
v_desc3 = v_str+v_value2(v_value1).
2016 Jul 28 6:22 AM
Did you tried below?,
DATA: LONGSTR TYPE STRING,
PARTLEN TYPE I.
DATA : IST_ZTAB TYPE TABLE OF CHAR100.
LONGSTR = 'THIS IS PART1 THIS IS PART2 THIS IS PART3'.
PARTLEN = STRLEN( LONGSTR ) / 3.
CALL FUNCTION 'SOTR_SERV_STRING_TO_TABLE'
EXPORTING
TEXT = LONGSTR
LINE_LENGTH = PARTLEN
TABLES
TEXT_TAB = IST_ZTAB
.
Hope this helps.
2016 Jul 28 6:58 AM
DATA(str) = sy-abcde && sy-abcde && sy-abcde && sy-abcde.
DATA itab TYPE TABLE OF string.
DATA(pos) = strlen( str ).
DATA(length) = pos / 3.
WHILE pos > length.
APPEND str(length) TO itab.
SHIFT str LEFT BY length PLACES.
pos = pos - length.
ENDWHILE.
APPEND str TO itab.
cl_demo_output=>display( itab ).