‎2011 Mar 02 10:12 AM
Hi Community,
I have the following problem.
I have to split a string at a dynamic separator.
I collect the separator from a customizing table. In the debugger I can see the correct separator in the field-symbol, but it does not split the string.
When I hardcode the same separator it works without a problem. In the debugger the separator (hardcoded or dynamic from table) is the same.
Works:
ASSIGN ' INTO:
TABLE it_bcode_value IN CHARACTER MODE.
Doesn't work:
ASSIGN ls_bcode_def-separator TO INTO:
TABLE it_bcode_value IN CHARACTER MODE.
Does anyone have some advice for me?
Thanks,
Cédric
‎2011 Mar 02 10:31 AM
Hm,
maybe it is a length problem, if ls_bcode_def-separator has trailing spaces.
What is the value of <sep> in both cases in debugger (hexadecimal) ?
Maybe you should move it to a string field without trailing spaces and use this instead.
Regards,
Klaus
‎2011 Mar 02 10:21 AM
Change the code to assign the value of value to the field symbol. SO, it would be like,
ASSIGN (ls_bcode_def-separator) TO <sep>.
SPLIT gv_bcode_value AT <sep> INTO:
TABLE it_bcode_value IN CHARACTER MODE.
Check for the opening and closing brackets that i have added for the field ls_bcode_def-separator.
Regards
Ranganath
‎2011 Mar 02 10:31 AM
Hi Ranganath,
the problem is not assigning the FS. The problem is the split part. It does also not work when I write the code without FS:
SPLIT gv_bcode_value AT ls_bcode_def-separator INTO:
TABLE it_bcode_value IN CHARACTER MODE.Thanks,
Cédric
‎2011 Mar 02 10:44 AM
I agree to the Klaus comment, it might be because of the trailing space. I have tried three option, in two of them it worked,
Works- Case 1
data : it_bcode_value type STANDARD TABLE OF string.
data : gv_bcode_value type string value '123<1D>456',
sep type char4 value '<1D>'.
FIELD-SYMBOLS : <sep> type any.
ASSIGN sep TO <sep>.
SPLIT gv_bcode_value AT <sep> INTO:
TABLE it_bcode_value IN CHARACTER MODE.
Works - Case 2
data : it_bcode_value type STANDARD TABLE OF string.
data : gv_bcode_value type string value '123<1D>456',
sep type char4 value '<1D>'.
FIELD-SYMBOLS : <sep> type any.
SPLIT gv_bcode_value AT sep INTO:
TABLE it_bcode_value IN CHARACTER MODE.
Now if i change the lenght of sperator to CHAR5 instead of CHAR4 in the second case, it does not work.
Does not Work
data : it_bcode_value type STANDARD TABLE OF string.
data : gv_bcode_value type string value '123<1D>456',
sep type char5 value '<1D>'.
FIELD-SYMBOLS : <sep> type any.
SPLIT gv_bcode_value AT sep INTO:
TABLE it_bcode_value IN CHARACTER MODE.
Regards
Ranganath
‎2011 Mar 02 10:29 AM
Hi Cedric,
I tried to pass the seperator through a parameter to make it dynamic and it worked for me.
You may want to look into the type of Field symbol. I assigned it type ANY.
Hope it works.
Khushboo.
‎2011 Mar 02 10:31 AM
Hm,
maybe it is a length problem, if ls_bcode_def-separator has trailing spaces.
What is the value of <sep> in both cases in debugger (hexadecimal) ?
Maybe you should move it to a string field without trailing spaces and use this instead.
Regards,
Klaus
‎2011 Mar 02 10:36 AM
Thanks a lot Klaus.
This is the solution.
DATA: lv_sep type string.
move ls_bcode_def-separator to lv_sep.
SPLIT gv_bcode_value AT lv_sep INTO:
TABLE it_bcode_value IN CHARACTER MODE.Regards,
Cédric