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

Put a string in an Internal Table

nathalie_michel
Participant
0 Likes
671

Dear All,

Hope you have a solution.

In a program, I have a field type String.

In this field I put some values separated by TAB -

I would like to take this field and put it in the header line of an internal table.

The length of the values put on the string file is not fix.

Ex: ITAB

Field1(50)

FIELD2(50),

Field3(50)

FIELD4(50)

Field_string = 'TOTO#TATA#TITI#TUTU#'

I would like to obtain

ITAB-field1 = TOTO

ITAB-field2 = TATA

ITAB-field3 = TITI

ITAB-field4 = TUTU.

And of course I don't want to write something like

IF 1 then ITBA1-FIELD1 = u2026

IF 2 then ITBA1-FIELD2 = u2026

I'll be surprised that we can't do that in one coding line.

DO you have an idea ?

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
642

Hi

Use the following syntax

SPLIT Field_string AT tab INTO ITAB-field1 ITAB-field2 ITAB-field3 ITAB-field4.

4 REPLIES 4
Read only

ThomasZloch
Active Contributor
0 Likes
642

Study ABAP online help for statement SPLIT and try applying it to your case.

Thomas

Read only

Former Member
0 Likes
643

Hi

Use the following syntax

SPLIT Field_string AT tab INTO ITAB-field1 ITAB-field2 ITAB-field3 ITAB-field4.

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
642

hi,

see the below pseudo code

DATA : text TYPE string VALUE 'toto#tata#titi#tutu',
       it_tab TYPE TABLE OF string,
       wa_tab LIKE LINE OF it_tab.

SPLIT text AT '#' INTO TABLE it_tab.
" it_tab contain four rows
LOOP AT it_tab INTO wa_tab.
"loop it_tab and do your operations
ENDLOOP.

BREAK-POINT.

Thanks

Read only

Former Member
0 Likes
642

Hello


split Field_string at '#' into itab-field1 itab-field2 itab-field3 itab-field4.