‎2010 Feb 18 8:51 PM
Hi There,
VALUE = ' 1 2 3 4'.
sPLIT VALUE AT SPACE INTO BLANK1 ACTUAL1 BLANK2 ACTUAL2 BLANK3 ACTUAL3 BLANK4 ACTUAL4O/P IS
BLANK1 =
ACTUAL1 = 1
BLANK2 = 2
ACTUAL2 = 3
BLANK3 = 4
ACTUAL3 =
BLANK4 =
ACTUAL4 =
VALUE = ' 1 3 4'.
sPLIT VALUE AT SPACE INTO BLANK1 ACTUAL1 BLANK2 ACTUAL2 BLANK3 ACTUAL3 BLANK4 ACTUAL4O/P IS
BLANK1 =
ACTUAL1 = 1
BLANK2 =
ACTUAL2 =
BLANK3 = 3
ACTUAL3 = 4
BLANK4 =
ACTUAL4 =
I'm getting strange results
Actual this is what im trying to achieve
I have 4 words(1 or more characters) separted by single space some times the words may be space(just 1space) by itself.
So i expect to get my words in to actuals
For ex :
1 case
I expected the output to be
ACTUAL1 = 1
ACTUAL2 = 2
ACTUAL3 = 3
ACTUAL4 = 4
2 case
I expected the output to be
ACTUAL1 = 1
ACTUAL2 =
ACTUAL3 = 3
ACTUAL4 = 4
Can anyone tell me as to where i'm missing the trick
Thanks
Edited by: kajol sindi on Feb 18, 2010 9:51 PM
‎2010 Feb 19 5:49 AM
Hi,
I think you got confused with SPILT Statement.
SPLIT command is used to split a string into different varaibles.This is will be done on the basis character which you specify as pivot point.
For ex:str = "This is text for example".
SPLIT AT SPACE into VAR1 VAR2 VAR3 VAR4 VAR5.
Which will split into:
THIS into VAR1, IS into VAR2, TEXT into VAR3, FOR into VAR4, EXAMPLE into VAR5.
it will not consider space for splitting into any varaible.SPACE is just considered as a point where should the split occurs.
Your Split statement should look like this.
VALUE = '1 2 3 4'.
SPLIT VALUE AT SPACE INTO ACTUAL1 ACTUAL2 ACTUAL3 ACTUAL4.
This will have the required output.
Thanks & Regards,
Vamsi.
‎2010 Feb 18 9:16 PM
I don´t understand the second case
You say the words are separated by a space and a word can be a space.
In that case, to get the result you are expecting I would imply that the value you are looking is
VALUE = ' 1 3 4'.note the two spaces between 1 and 3.
‎2010 Feb 19 5:49 AM
Hi,
I think you got confused with SPILT Statement.
SPLIT command is used to split a string into different varaibles.This is will be done on the basis character which you specify as pivot point.
For ex:str = "This is text for example".
SPLIT AT SPACE into VAR1 VAR2 VAR3 VAR4 VAR5.
Which will split into:
THIS into VAR1, IS into VAR2, TEXT into VAR3, FOR into VAR4, EXAMPLE into VAR5.
it will not consider space for splitting into any varaible.SPACE is just considered as a point where should the split occurs.
Your Split statement should look like this.
VALUE = '1 2 3 4'.
SPLIT VALUE AT SPACE INTO ACTUAL1 ACTUAL2 ACTUAL3 ACTUAL4.
This will have the required output.
Thanks & Regards,
Vamsi.
‎2010 Feb 19 6:39 AM
VALUE = ' 1 2 3 4'.
sPLIT VALUE AT SPACE INTO BLANK1 ACTUAL1 BLANK2 ACTUAL2 BLANK3 ACTUAL3 BLANK4 ACTUAL4
in your case Split statement splits the string when the space occurs.
that is why you are getting the wrong result.
Modify your statement as follows:
VALUE = ' 1 2 3 4'.
SPLIT VALUE AT SPACE INTO ACTUAL1 ACTUAL2 ACTUAL3 ACTUAL4.
Now you will get the output as you want i.e.
ACTUAL1 = 1
ACTUAL2 = 2
ACTUAL3 = 3
ACTUAL4 = 4
For more details of split statement read F1 help.
‎2010 Feb 19 8:36 AM
You can just split it into internal table.
split lv_string at space into table itab.