2011 Dec 02 3:30 PM
Hi Folks,
I have a variable, lv_hash TYPE c LENGTH 1 VALUE '#'. and a constant, c_hidden_tab(2) TYPE x VALUE '0023'.
When I look in my debugger, the Hex value of both of these fields is 0023 but when I do the following code, it says they are not the same. What am I doing wrong?
IF lv_hash = c_hidden_tab.
2011 Dec 02 6:42 PM
Sorry, I'm wrong, the debugging session image on my previous post is accurate. But the IF statment still won't work.
Any Ideas?
It won't let me do a CS statement because "C_HIDDEN_TAB" must be a character-type data object (data type C, N, D, T, or STRING).
Hi Folks,
I have a variable, lv_hash TYPE c LENGTH 1 VALUE '#'. and a constant, c_hidden_tab(2) TYPE x VALUE '0023'.
When I look in my debugger, the Hex value of both of these fields is 0023 but when I do the following code, it says they are not the same. What am I doing wrong?
IF lv_hash = c_hidden_tab.
2011 Dec 02 3:37 PM
If it's a tab, declare con_tab(1) type x value '09'.
comparing a length 1 = '#' to a two byte hex values ( = 0023) will always mismatch....
also search the forum for use of CL_ABAP_CHAR_UTILITIES class which enables you to identify some of these characters quickly... in a Unicode-enabled system.
2011 Dec 02 4:00 PM
Hi Break Point,
Thanks for you reply, the problem is this is happening to me when reading in a file from the application server using OPEN DATASET.
When I look at the file with notepad there is no # at the end of the file, neither is there a TAB, there is just my line.
i.e.
201111
However, when this gets uploaded and I look at the value in debug, the value is this:
201111#
When I, excluded the 201111 part of my variable and just leave the # part, it's hexadecimal value is 000D.
So that is why I have tried to implement the code I have implemented. Do you recommend something different?
2011 Dec 02 4:48 PM
I don't see how two bytes is showing as '#', but the 0D is a line feed (LF).... It's not 0A0D? anyway....
data: con_lf(1) type x value '0D'.
if my_string cs con_lf.
replace con_lf with space into my_string.
endif.
or
data: con_junk(2) type x value '000D'.
if my_string cs con_junk.
replace con_junk with space into my_string.
endif.
If Unicode switch is on, search the forum from syntax for using class:
CL_ABAP_CHAR_UTILITIES
2011 Dec 02 6:38 PM
[Debugging Session|http://i43.tinypic.com/54sxtx.png]
I don't know why either but it seems to be.
When I replicated the scenario exactly, instead of using my own #, it does seem to check the statement correctly and allow me to remove the trailing "invisible #" which I agree, is probably a Line Feed. Not sure why the two leading 00 are there in the hex either though.
In any case, I'm happy now so thanks for your help.
Colm
2011 Dec 02 6:42 PM
Sorry, I'm wrong, the debugging session image on my previous post is accurate. But the IF statment still won't work.
Any Ideas?
It won't let me do a CS statement because "C_HIDDEN_TAB" must be a character-type data object (data type C, N, D, T, or STRING).
2011 Dec 02 7:08 PM
turn off the unicode switch in program attributes, then declare your X objects, or use the class mentioned earlier....
2011 Dec 02 7:13 PM
0D is Carriage return CR
0A is Line feed LF
If the file is transferred from a Windows system (that uses CRLF combination as record separator) to UNIX (that use only LF as record separator), without conversion (that is FTP in binary mode), then you will see #s when you upload that file into SAP.
You can try two things here
Try replacing with any of these three, it should work with one of these depending on whether CRLF or LF is the record separator that appears as # to you in debugger
CONSTANTS: c_crlf(2) TYPE x VALUE '0D0A',
c_lf TYPE x VALUE '0A',
c_cr TYPE x VALUE '0D'.
REPLACE c_crlf WITH '' INTO lv_string.
REPLACE c_lf WITH '' INTO lv_string.
REPLACE c_cr WITH '' INTO lv_string.
2011 Dec 05 11:31 AM
Folks,
After a lot of playing around, this was the statement that finally worked. Many thanks for all your help.
CONSTANTS: lc_cr_lf TYPE abap_cr_lf VALUE cl_abap_char_utilities=>cr_lf.
REPLACE lc_cr_lf(1) WITH '' INTO wa_data_tab.