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

Splitting string into noncharacter fields

Former Member
0 Likes
1,171

Hi All,

I have an internal table with character type data.

I have some 200 structures having some non-character fields like DEC and INT.

Now i want to split the line of internal table in to these structure fields one by one.

But the problem is SPLIT is a string function and only allows character type Field attributes.

Is there any way out, to SPLIT string in some non character fields?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
786
data : begin of itab occurs 0,
         str type string,
       end of itab.

loop at it_char.
 split it_char at <delimiter> into table itab.
endloop.

now loop at the ne itab and extract ur values

not sure if it can satify ur requirement

6 REPLIES 6
Read only

Former Member
0 Likes
786

Hi,

Insted of Splitting the ITAB data using SPLIT, why don't you use the <b>offsets</b>,

Move:itab-data+0(10) to DEC.

Move:itab-data+10(20) to DEC.

Regards

Sudheer

Read only

0 Likes
786

Hi Sudheer,

Offsets can be used..but the problem is length is not fixed.

I mean that i need to split at ';'.

Is there any FM available which performs the similar task that is performed by wrapper classes in JAVA?

regards,

G@urav.

Read only

Former Member
0 Likes
786

Hey,

Using SPLIT only will work if you do it on character types, so you should do it first to a char type and then to a non-char.

Hope this helps

Gabriel P.

Read only

Former Member
0 Likes
787
data : begin of itab occurs 0,
         str type string,
       end of itab.

loop at it_char.
 split it_char at <delimiter> into table itab.
endloop.

now loop at the ne itab and extract ur values

not sure if it can satify ur requirement

Read only

0 Likes
786

Hi Chandrashekhar,

Thanks, i think this will solve my problem.

Regards,

G@urav.

Read only

Former Member
0 Likes
786

Hi,

REPORT demo_mod_tech_fb_string_split.

DATA: text(10) TYPE c VALUE '0123456789',
      text1(6) TYPE c,
      text2(6) TYPE c.

PARAMETERS position TYPE i.

CALL FUNCTION 'STRING_SPLIT_AT_POSITION'
     EXPORTING
          string            = text
          pos               = position
     IMPORTING
          string1           = text1
          string2           = text2
     EXCEPTIONS
          string1_too_small = 1
          string2_too_small = 2
          pos_not_valid     = 3
          OTHERS            = 4.

Regards

Sudheer