Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multiple split in a program

Former Member
0 Likes
843

CONSTANTS : lv_string type char40 value 'we%123456789 gift%happy birthday',
lv_c1 TYPE char03 VALUE 'we%',
lv_c2 TYPE char03 VALUE 'gift%'.
data: str1 type string,
str2 type string,
s1 type string,
s2 type string.


SPLIT : lv_string at ' ' into str1 str2,
str1 at lv_c1 into s,
str2 at lv_c2 into s2.

write:/ str1.
write:/ str2.
write:/ s1.
write:/ s2.

Can any one correct my code? it showing error.

1 ACCEPTED SOLUTION
Read only

former_member1716
Active Contributor
766

Hello naveena_10,

There were few errors, you can use the below code which i hope satisfies your requirement.

CONSTANTS : lv_string TYPE char40 VALUE 'we%123456789 gift%happy birthday',
            lv_c1     TYPE char03 VALUE 'we%',
            lv_c2     TYPE char05 VALUE 'gift%'. --> There was error here in Data type declaration.

DATA: str1 TYPE string,
      str2 TYPE string,
      s1   TYPE string,
      s2   TYPE string,
      s3   TYPE string,
      s4   TYPE string.


SPLIT : lv_string AT ' ' INTO str1 str2,
        str1 AT lv_c1 INTO s1 s2, --> You failed to provide two variables as destination
        str2 AT lv_c2 INTO s3 s4. --> You failed to provide two variables as destination

WRITE:/ str1.
WRITE:/ str2.
WRITE:/ s1.
WRITE:/ s2.
WRITE:/ s3.
WRITE:/ s4.

Regards!

2 REPLIES 2
Read only

former_member1716
Active Contributor
767

Hello naveena_10,

There were few errors, you can use the below code which i hope satisfies your requirement.

CONSTANTS : lv_string TYPE char40 VALUE 'we%123456789 gift%happy birthday',
            lv_c1     TYPE char03 VALUE 'we%',
            lv_c2     TYPE char05 VALUE 'gift%'. --> There was error here in Data type declaration.

DATA: str1 TYPE string,
      str2 TYPE string,
      s1   TYPE string,
      s2   TYPE string,
      s3   TYPE string,
      s4   TYPE string.


SPLIT : lv_string AT ' ' INTO str1 str2,
        str1 AT lv_c1 INTO s1 s2, --> You failed to provide two variables as destination
        str2 AT lv_c2 INTO s3 s4. --> You failed to provide two variables as destination

WRITE:/ str1.
WRITE:/ str2.
WRITE:/ s1.
WRITE:/ s2.
WRITE:/ s3.
WRITE:/ s4.

Regards!

Read only

Sandra_Rossi
Active Contributor
0 Likes
766

Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).