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

Statement SPLIT.

Former Member
0 Likes
1,095

Hi,

i have a simle VAR1 (CHAR255) which contains text

like 'test1morelines' or 'contain1moretext'' as example.

I will only use the text before 1.

i split at like this: split VAR1 at '1' into VAR1 dummy.

It works OK, but i have to use the seconc VAR dummy.

Is there any statement that deletes all char starting at vaue 1?

thanks,

regards, Dieter

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,023

hiii

first use FIND statement for finding '1' in variable then use sy-fdpos to get that position and then you can replace all value by 'SPACE' using offset (following abap statement)

REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new 
                [IN {BYTE|CHARACTER} MODE].

regards

twinkal

7 REPLIES 7
Read only

Former Member
0 Likes
1,023

hmmm Dieter i dont really get the problem, why dont you just delete dummy?

Read only

Former Member
0 Likes
1,023

Hi,

Instead of

split VAR1 at '1' into VAR1 dummy.

, you can use

split VAR1 at '1' into VAR1 .

Luck,

Bhumika

Read only

Former Member
0 Likes
1,024

hiii

first use FIND statement for finding '1' in variable then use sy-fdpos to get that position and then you can replace all value by 'SPACE' using offset (following abap statement)

REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new 
                [IN {BYTE|CHARACTER} MODE].

regards

twinkal

Read only

Former Member
0 Likes
1,023

hi,

Instead of Using SPLIT you can find the position of the '1' in the String.

Search '1' in <String>.

Sy-FDPOS contains the position os the '1'.

Extract the String using Offset.

string2 = string1+0(sy-fd-pos).

Regards

Sumit Agarwal

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,023

the dummy is necessary to take the "garbage"; it cant be just thrown away.

Another way is to use the FIND command to the position of "1", checking if evrything is ok, then calcualting the len of desired string from the position (obvious minus 1) and then use s substring command like var1+ü(len).

To be honest, its not shorter or more beautiful..

Read only

Former Member
0 Likes
1,023

Hi,

thanks to all. I think there is no better statement. I will use split with dummy.

Bhumika: split VAR1 at '1' into VAR1 .

gives an syntaxerror (ECC6).

i close the thread. Thanks again.

Regards, Dieter

Read only

Former Member
0 Likes
1,023

Use this syntax

SPLIT var1 AT '1' INTO: TABLE itab.

This table would be of single column type string and will have

test

morelines' or

contain

moretext''

Hope this helps!