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

Conversion issue from Character into Hexadecimal

Former Member
0 Likes
1,148

Dear Team,

Need a solution while converting value to Hexadecimal

A is of type C.

case 1

At the time of initial run, value of A = 0

Used the following code :

the below code is within

Loop     

IF NOT <X> IS ASSIGNED.

ASSIGN A TO <X> CASTING.

ENDIF.

**endloop

the issue is the value of <X> for A=0 in my  system is 0030, whereas when i debug the same in user systemfrom china, i got the value as 3000 and when A=1, the value in my system is 0031 whereas in the user system it is 3001. This is happening only in users production system only, in Quality system the value is coming correctly like if A=0, the hexadecimal value is 0030 and for 1 the Hexa value as 0031.

reference ascii is from http://www.asciitable.com/

Kindly help me how to handle this.

Dear Team,

Need a solution while converting value to Hexadecimal

A is of type C.

case 1

At the time of initial run, value of A = 0

Used the following code :

the below code is within

Loop     

IF NOT <X> IS ASSIGNED.

ASSIGN A TO <X> CASTING.

ENDIF.

**endloop

the issue is the value of <X> for A=0 in my  system is 0030, whereas when i debug the same in user systemfrom china, i got the value as 3000 and when A=1, the value in my system is 0031 whereas in the user system it is 3001. This is happening only in users production system only, in Quality system the value is coming correctly like if A=0, the hexadecimal value is 0030 and for 1 the Hexa value as 0031.

reference ascii is from http://www.asciitable.com/

Kindly help me how to handle this.

2 REPLIES 2
Read only

Former Member
0 Likes
799

Hi,

I dont know  solution for above problem.

But I think you can use function  module in place of using casting.

DATA:  conv      TYPE REF TO cl_abap_conv_out_ce,  

    l_data        TYPE string,   

    l_buffer      TYPE xstring.  

" l_data holds char data 

conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8'                              

                                                                       endian   = 'L'         

                                                                       ignore_cerr = 'X'                                   

                                                                        replacement = '#' ).

  CALL METHOD conv->write( data = l_data ).

  l_buffer = conv->get_buffer( ).                                 " l_buffer holds the hexa values

Thanks

Santosh.

Read only

kumud
Active Contributor
0 Likes
799

Hello,

You could do F1 on 'CASTING' keyword and see that it highlights byte order which could be of two types and is also platform dependent. I ran your code and it shows me 3000 for 0, 3100 for 1, 3200 for 2 and likewise. You could check the data element ABAP_ENDIA. Default value would be different in your client system. In your system it would be 'L' . If it's 'B' the order of digits reverses.

However, coding given by Santosh works fine.If you execute the same code with parameter endian = 'B' you would see the digits reversed.

F1 shows many other details, you might be interested in.

Regards,

Kumud

Message was edited by: Kumud Singh