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 command

Former Member
0 Likes
623

Hi all,

I have a requirement, as i want to split into seperate fields where the ',,' or ',,,,'

ex: Due Date,,Amount,,,,Invoive no,,Status,,Timing

want to split as 5 fields.

can you anyone help me

Thanks

4 REPLIES 4
Read only

sudhindra_chandrashekar
Product and Topic Expert
Product and Topic Expert
0 Likes
599

Hi,

With as example

Data: l_str type string value 'Due Date or Amount',

l_var1 type string,

l_var2 type string.

split l_str at 'or' into l_var1 l_var2 in character mode .

If you have unknown number of variables then you can use a internal tables as well. I would suggest that you take the F1 help on the SPLIT command to learn more.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
599

You can split it into a table, since all values between ,, and ,,,,, are blank, they are simply not added to the internal table.



report zrich_0001 .

data: istr type table of string.
data: xstr type string.
data: str type string.

str = 'Due Date,,Amount,,,,Invoive no,,Status,,Timing'.

split str at ',' into table istr.

loop at istr into xstr.
  write:/ xstr.
endloop.

Regards,

Rich Heilman

Read only

0 Likes
599

You can use the internal table like this:

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
599

Hi!!

Try out the following code:

data :

string(40) type c,

part1(20) type c,

part2(20) type c,

part3(20) type c,

part4(20) type c,

part5(20) type c,

spli(4) value ',,,,'.

string = 'Due Date,,Amount,,,,Invoive no,,Status,,Timing'.

SPLIT STRING AT SPLI INTO PART1

PART2

PART3

PART4

PART5.

WRITE 😕 PART1,

/ PART2,

/ PART3,

/ PART4,

/ PART5.

Plzz award points if this was useful.

Regards,

Swapna.