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

split a line without separator

Former Member
0 Likes
1,227

hi everybody

is there a fm or a command which separates each field in a line, where theres no separator, but the fields are of a specified length

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
854

hi

use offset commands. i gave sample below

wa = 'WELCOME'

wa1 = wa+0(3).

value is WEL

wa2 = wa+3(2)

value is CO

4 REPLIES 4
Read only

matt
Active Contributor
0 Likes
854

Is all your data character based? Then you don't need to.

For example, if you have a field1 length 10, and field2 length 12, simply do this:

DATA: BEGIN OF my_line,
        field1 TYPE C LENGTH 10,
        field2 TYPE C LENGTH 12,
     END OF my_struc.

" l_line contains ABCDEFGHIJZZZZZZZZZZZZ

my_line = l_line.

" my_line-field1 now contains ABCDEFGHIJ
" my_line-field2 now contains ZZZZZZZZZZZZ

matt

Read only

Former Member
0 Likes
854

thanks

Read only

Former Member
0 Likes
854

Hi,

Firstly how many parts do you need to split ?

If is is 2/3/4 you need not use a function module. You can do it in simple coding.

Ex : Say you want split the following set of characters into 3 words of known length. then you can use the following coding.

Data : w_total(15) type c value 'SAPSDNFORUM',

w_sap(3) type c,

w_sdn(3) type c,

w_for(3) type c.

w_sap = w_total+0(3).

w_sdn = w_total+3(3).

w_for = w_total+6(5).

Regards,

Pramod

Read only

Former Member
0 Likes
855

hi

use offset commands. i gave sample below

wa = 'WELCOME'

wa1 = wa+0(3).

value is WEL

wa2 = wa+3(2)

value is CO