Application Development 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: 

split at dynamic seperator

cdric_jordi
Explorer
0 Kudos

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

1 ACCEPTED SOLUTION

former_member195402
Active Contributor
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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.

former_member195402
Active Contributor
0 Kudos

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

0 Kudos

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