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

string

Former Member
0 Likes
803

hi ,

i want to split text like below

Canada41890-01 into Canada 41890-01 how to do that ?

tanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
779

jim,

If text has constant value like first 6 chars next intergers then we can use directly

DATA : v_char(100) TYPE C VALUE

'Canada41890-01 into Canada 41890-01',

v_char1(10) ,

v_char2(20) .

v_char1 = v_char+0(6).

v_char2 = v_char+6(8).

CONCATENATE v_char1 v_char2 INTO v_char SEPERATED BY

space.

7 REPLIES 7
Read only

Former Member
0 Likes
779

Hi,

SPLIT

Splits a string.

Syntax

SPLIT <c> AT <del> INTO <c1>... <cn> INTO TABLE <itab>

[IN BYTE MODE|IN CHARACTER MODE].

This statement searches the character field <c> for delimiter strings <del> and the parts before and after the delimiters are placed in the target fields <c1> ...> … <cn>, or into a new line of the internal table <itab>. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions

Regards,

Priya.

Read only

Former Member
0 Likes
779

Hi,

Variable8(6) Variable6(8)

Hope this will help

Regards

Shibin

Read only

Former Member
0 Likes
779

1. SPLIT Canada41890-01 AT a INTO h1 ... hn.

here you can split the string Canada41890-01 in to 2 parts h1 and h2 at delimeter a.

2. SPLIT f AT g INTO TABLE itab.

you can even add it as directly into internal table.

syntax:

SPLIT c AT <del> INTO c1 ... cn.

or

SPLIT c AT <del> INTO table <internal table>.

where, del = delimeter

data: begin of wa,

text type string,

end of wa.

data: itab like table of wa.

data: st type string value 'I am new to ABAP'.

data: st1 type string,

st2 type string,

st3 type string,

st4 type string,

st5 type string.

split st at space into st1 st2 st3 st4 st5.

split st at space into table itab.

Regards,

Chandru

Edited by: Chandra Prakash on Mar 5, 2008 12:30 PM

Read only

Former Member
0 Likes
779

use the function module 'G_SPLIT_LINE'

Example code

CLEAR str_len .

str_len = strlen( w_string ) .

IF str_len GT split_len .

CALL FUNCTION 'G_SPLIT_LINE'

EXPORTING

input_line = w_string

TABLES

export_lines = split_tab.

  • Updating the internal table of structure TLINE

LOOP AT split_tab .

MOVE split_tab-txt_line TO txt_tab-tdline .

APPEND txt_tab .

ENDLOOP .

ELSE.

.........

ENDIF.

do reward if useful

Read only

Former Member
0 Likes
780

jim,

If text has constant value like first 6 chars next intergers then we can use directly

DATA : v_char(100) TYPE C VALUE

'Canada41890-01 into Canada 41890-01',

v_char1(10) ,

v_char2(20) .

v_char1 = v_char+0(6).

v_char2 = v_char+6(8).

CONCATENATE v_char1 v_char2 INTO v_char SEPERATED BY

space.

Read only

Former Member
0 Likes
779

v_str = 'Canada41890-01'.

v_str1 = v_str+0(6).

v_str2 = v_str+6(8).

Read only

Former Member
0 Likes
779

Hi JIM,

Try the following code.

DATA:

v_char(32) TYPE c,

v_char1(16) TYPE c,

v_char2(16) TYPE c.

v_char = 'Canada41890-01'.

v_char1 = v_char+0(6).

v_char2 = v_char+6(8).

CLEAR v_char.

CONCATENATE v_char1 v_char2 INTO v_char

SEPARATED BY space.

Reward if helpful.