Comparing Hexadecimal value in program
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.
Marcin Pciak replied
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