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 TO INTERNAL TABLE

Former Member
0 Likes
1,417

HI ALL,

HOW DO I SPLIT A STRING INTO A TABLE,

ACTUALLY THE STRING I AM USING IS SEPERATED BY SPACES.

eg:

this is my string 12 23 34 56 78 90 223 3 8

i want .

12

23

34

56

78

90

223

3

8

in my table.

regards,

nani

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,371

TYPES: X_LINES TYPE STRING.
DATA: T_TABLE TYPE STANDARD TABLE OF X_LINES WITH HEADER LINE.
DATA: MY_STRING TYPE STRING.

MY_STRING = '12 23 34 56 78 90 223 3 8'.

SPLIT MY_STRING AT SPACE INTO TABLE T_TABLE.

Greetings,

Blag.

11 REPLIES 11
Read only

Former Member
0 Likes
1,371

SPLIT string AT space INTO itab.

Rob

Read only

Former Member
0 Likes
1,372

TYPES: X_LINES TYPE STRING.
DATA: T_TABLE TYPE STANDARD TABLE OF X_LINES WITH HEADER LINE.
DATA: MY_STRING TYPE STRING.

MY_STRING = '12 23 34 56 78 90 223 3 8'.

SPLIT MY_STRING AT SPACE INTO TABLE T_TABLE.

Greetings,

Blag.

Read only

Former Member
0 Likes
1,371

Hi,

DATA: T_STRING TYPE STANDARD TABLE OF STRING.

SPLIT S_STRING AT SPACE INTO TABLE T_STRING..

Thanks,

Naren

Read only

0 Likes
1,371

HOW DO I USE THE INDVIDUAL FIELDS OF THIS TABLE.

REGARDS,

NANI

Read only

0 Likes
1,371

You should loop them...like this...


LOOP AT T_TABLE.
WRITE: T_TABLE.
ENDLOOP.

Or use

READ TABLE T_TABLE INDEX ...

Greetings,

Blag.

Read only

0 Likes
1,371

I AM USING THESE FIELDS IN A SAPSCRIPT SO HOW DO I DECLARE THESE FIELDS IN SAPSCRIPT.

REGARDS,

NANI

Read only

0 Likes
1,371

Ok...It depends on how you need to call this values into the SAPScript...My idea...You can create a new window and called like this from you ABAP Program...


DATA: STRING_VALUE TYPE STRING.

LOOP AT T_TABLE.
MOVE T_TABLE TO STRING_VALUE.
  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      ELEMENT = 'VALUES'
      WINDOW  = 'MAIN'
    EXCEPTIONS
      OTHERS  = 01.
ENDLOOP.

In your "VALUES" sub-window, you should call this...


Value: &STRING_VALUE&

Greetings,

Blag.

Read only

0 Likes
1,371

HI ALVARO

THE CODE U HAVE WROTE IS GOOD IF WE WANT TO DISPLAY THE DATA VERTICALLY BUT I LIKE TO DISPLAY IT HORIZONTALLY.

eg:

with your code we can display it as

12

23

34

56

78

but i like to display it as

12 34 78 56 23

Read only

0 Likes
1,371

I guess you are splitting it because you want to insert tabs when writing it horizontally?

REgards,

Rich Heilman

Read only

0 Likes
1,371

HI RICH,

I CAN DISPLAY THE STRING AS

12 23 34 56 78 90

BUT I LIKE TO DISPLAY IT AS

12 34 56 90 78 23

IN WHATEVER ORDER I WANT OR ONLY SOME OF THE FIELDS.

REGARDS,

NANI

Read only

0 Likes
1,371

I see, so what is the logic of the order of the values? If you know this, and it is always the same, you can simply build another string from the internal table that has been filled when using the SPLIT...INTO TABLE statement.

Regards,

Rich Heilman