Skip to Content
0
Oct 10, 2019 at 10:48 AM

Spli a string into internal table with a field of STRING TYPE

627 Views

Hi,

i'm newbie of SAP. My program is the following:

REPORT ZREGEX.

TYPES : BEGIN OF stringa ,
substring(1000) TYPE c ,
END OF stringa .

DATA : string1 TYPE STRING VALUE '<ANSWERPROMPT>DIMENSION:TIME|2019.01,2019.02,2019.03,2019.04,2019.05,'</ANSWERPROMPT>
DATA : string2 TYPE STRING VALUE '2019.06,2019.07,2019.08,2019.09,2019.10,2019.11,2019.12 </ANSWERPROMPT>'.
DATA : string3 TYPE STRING VALUE '<ANSWERPROMPT>DIMENSION:TIME|2019.09'.</ANSWERPROMPT>
DATA : my_string TYPE TABLE OF stringa , wa_string LIKE LINE OF my_string .

CONCATENATE string1 string2 string3 string4 INTO string1 . "Concateno le stringhe string1, string2, string3 e string4 in un'unica mega-stringa
SPLIT string1 AT '</ANSWERPROMPT>' INTO TABLE my_string .

I want split string1 in three different strings and i want put them in the internal table my_string .

The internal table has a field substring of length 1000 and TYPE c.

But, splitted strings could be very long so the length 1000 could be not enough . (strings over 1000 characters), so i tried to replace substring(1000) TYPE c with :

substring TYPE STRING .

But in this case I receive the following error:

Only tables with a character line type (C,N,D,T or STRING) are allowed with the INTO TABLE addition

and

wa_string must be a character type data object (data type C,N,D,T or STRING).

How can I do?

Thanks