05-02-2009 12:43 PM
Hi friends,
I have requirement in this I have to pick a file and have to write some logic by comparing file contents.
File contents some hexadecimal character like '#'.
When I am writing simple if condition like
if var = '#'.
---
endif.
It is not going in that if condition even when the var has value from # from file. so i think as it is hexadecimal value there is some other way to compare it.
Please let me know how can I compare hexadecimal value.
05-02-2009 1:28 PM
Indeed # is a character representation of a separator (tab or space) which is seen as # in character mode.
Use below snippet to compare it
DATA: xsep TYPE xstring,
sep TYPE string.
xsep = '09'. "if separator is tab mark
xsep = '20'. "if it is space
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = xsep
IMPORTING
out_string = sep.
"now SEP contains character representation for separator (which is seen as #)
"you can i.e. split uploaded file data (in iternal table) based on that separator
SPLIT it_file_data AT sep INTO TABLE it_file_fields IN CHARACTER MODE.
"for comparing use
if var = sep.
...
endif.
Regards
Marcin
05-02-2009 1:28 PM
Indeed # is a character representation of a separator (tab or space) which is seen as # in character mode.
Use below snippet to compare it
DATA: xsep TYPE xstring,
sep TYPE string.
xsep = '09'. "if separator is tab mark
xsep = '20'. "if it is space
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = xsep
IMPORTING
out_string = sep.
"now SEP contains character representation for separator (which is seen as #)
"you can i.e. split uploaded file data (in iternal table) based on that separator
SPLIT it_file_data AT sep INTO TABLE it_file_fields IN CHARACTER MODE.
"for comparing use
if var = sep.
...
endif.
Regards
Marcin
05-02-2009 2:07 PM
Hi Marcin
I tried the method u showed but its not working, I think that # symbol there represent line feed or carriage return and not space.
What is the value of line feed and carriage return, as 20 for space?
05-02-2009 2:23 PM
Hex:
Carriage return - '0D'
Newline (so called line feed) - 'A'
Char:
Carriage return and line feed - use CL_ABAP_CHAR_UTILITIES=>CR_LF
Only newline - CL_ABAP_CHAR_UTILITIES=>NEWLINE
Regards
Marcin
05-02-2009 2:47 PM
Hi Marcin,
I was able to get the proper split value using hex decimal '0A'.
I got it from this link http://www.dynamoo.com/technical/ascii.htm
Thanks for your help...