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

How to get variable value into internal table?

Former Member
0 Likes
4,013

Hello friends,

I have a string variable which stores the value like...

v_build_str = MAT210AS1MAT210AS2MAT210AS3MAT210AS4MAT210AS5MAT210AS6^

I want to process this variable value and want to store data in inter table like...

MAT210AS1

MAT210AS2

MAT210AS3

MAT210AS4

MAT210AS5

MAT210AS6

How can I do this?

Regards,

RH

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,042

HI Ronny,

Use SPLIT command and split the variable at cap symbol u have in text.

example..

DATA: str1 TYPE string,

str2 TYPE string,

str3 TYPE string,

itab TYPE TABLE OF string,

text TYPE string.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: str1 str2 str3,

TABLE itab.

11 REPLIES 11
Read only

Former Member
0 Likes
2,042

HI,

Use

declare you itab with one field of certain length ( u decide how much length u need )

Split variable at 'use your symbol' into table itab.

Please check the syntax.

Regards,

Venkatesh

Read only

Former Member
0 Likes
2,042

Hi Ronny,

You can split the string at '^' and store them into a internal table.

Or you can use offset since all of the are of same length,so once you reach that length in offset take that value into a variable and append it to internal table and then append it,.

Much Regards,

Amuktha.

Read only

0 Likes
2,042

Any example?

Read only

0 Likes
2,042

Hi Ronny,

Here you go!

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

This is the basic syntax.

Take that whole string as some w_string and some other string like w_str1 w_str2 w_str3 like that.

Now split w_string at ^ into w_str1 w_str2 .

Hope it helps!

Much Regards,

Amuktha.

Read only

0 Likes
2,042

Hi,

data :

begin of fs,

w_str(20) type c,

end of fs.

data itab like table of fs.

data w_len type i.

w_len = strlen( w_char ).

while w_char+0(w_len) ne ' '.

split w_char at '^' into fs-w_str.

append fs to itab.

clear fs.

endwhile.

loop at itab into fs.

write 😕 fs-w_str.

endloop.

Read only

Former Member
0 Likes
2,042

U can write as :

data : begin of itab occurs 0,

field(15),

end of itab.

split v_build_str at '^' into table itab.

Read only

Former Member
0 Likes
2,043

HI Ronny,

Use SPLIT command and split the variable at cap symbol u have in text.

example..

DATA: str1 TYPE string,

str2 TYPE string,

str3 TYPE string,

itab TYPE TABLE OF string,

text TYPE string.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: str1 str2 str3,

TABLE itab.

Read only

Former Member
0 Likes
2,042

Hi,

data: begin of itab occurs 0,

field(30) type c,

end of itab.

v_build_str = MAT210AS1MAT210AS2MAT210AS3MAT210AS4MAT210AS5MAT210AS6^

split v_buil_str at '^' into table itab.

Loop at itab.

write:/ itab-field.

endloop.

See the output.

Regards,

Venkatesh

Read only

Former Member
0 Likes
2,042

Hi,

*First: declare an ITAB of single field length could same or more than that.

DATA: BEGIN OF ITAB OCCURS 10,

FIELD1 TYPE CHAR9,

END OF ITAB.

*Second: split the field at your symbol or special character.

SPLIT V_BUILD_STR AT '^' INTO TABLE ITAB.

*Third: loop your itab to check it wheather the data is coming in proper manner or not.

LOOP AT ITAB.

WRITE:/ ITAB-FIELD1.

ENDLOOP.

Hope this is helpfull

Regards,

Nishant

Read only

Former Member
0 Likes
2,042

chk this:

DATA: itab TYPE TABLE OF string,

text TYPE string.

text = 'MAT210AS1MAT210AS2MAT210AS3MAT210AS4MAT210AS5MAT210AS6^'

.

SPLIT text AT '^' INTO:

TABLE itab.

itab will get all the values u need:

MAT210AS1

MAT210AS2

MAT210AS3

MAT210AS4

MAT210AS5

MAT210AS6

Read only

Former Member
0 Likes
2,042

Thanks