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

why the CS does not work?

Former Member
0 Likes
990

I have the code as below. p_value = '#', and when i debug,the <dyn_field> contain the character '#'.

but after execute the <dyn_field> CS p_value, the sy-subrc <> 0;i think the sy-subrc should be 0.

I do not know why? Could you please help me

**********************code **********************************************

FORM check_value.

DATA l_value(225) TYPE c.

DATA s TYPE string.

WRITE: / 'Detail Updated Information: '.

CLEAR g_lines.

LOOP AT <dyn_table> INTO <dyn_wa>.

ASSIGN COMPONENT g_tabix

OF STRUCTURE <dyn_wa> TO <dyn_field>.

IF <dyn_field> CS p_value.

l_value = <dyn_field>.

REPLACE ALL OCCURRENCES OF REGEX p_value IN <dyn_field> WITH p_repla.

IF sy-subrc = 0.

WRITE: /2(25) c_old_v, 27 '->',30(25) c_new_v.

WRITE: / l_value UNDER c_old_v.

WRITE: <dyn_field> UNDER c_new_v.

MODIFY <dyn_table> FROM <dyn_wa>.

g_lines = g_lines + 1.

ENDIF.

ENDIF.

ENDLOOP.

3 REPLIES 3
Read only

former_member156446
Active Contributor
0 Likes
748

hi if I can guess correct .. you would have read some file from app server or presentation server and loded data into internal table..

  1. symbolizes the carriage return or page breaker.. search the forum for this key words.. you will find a solution.

Read only

MarcinPciak
Active Contributor
0 Likes
748

Sometimes chars may look similar but in fact they're not. It is especially encountered when reading the file. Debug the code and ensure that '#' sign has the same hex code that your p_value, which I guess is a char.

If not do following:

- declare p_value_hex as xstring

- assing it a hex value for # sign (check in ASCII table)

- give on input of FM HR_KR_XSTRING_TO_STRING this hex value to convert it to string

- then check if your statement "F <dyn_field> CS p_value_string." works

Read only

Former Member
0 Likes
748

it may be a horizontal tab or a new line character.

try one of these..

cl_abap_char_utilities=>horizontal_tab

cl_abap_char_utilities=>newline

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab  IN <dyn_field> WITH p_repla.

or

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline  IN <dyn_field> WITH p_repla.