cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert hexadecimal to integer in SAP BODS

kalyani_kolli
Explorer
0 Kudos

Hi All,

We have a value from source 0x000000000007D407 as timestamp datatype. which we take as varchar(255) in BODS(Because we checked the option unsupported datatype in datastore level). so value in BODS is 000000000007D407. Here our requirement is to convert the value into interger type.

How to achieve this in BODS.

Immediate response is much appreciated.

Thankyou in Advance 🙂

Accepted Solutions (1)

Accepted Solutions (1)

rajan_burad
Active Participant
0 Kudos

Hello Kalyani,

I've made a blog with some sample data out of your question.Hexadecimal to Integer

Let me know if it helps!

kalyani_kolli
Explorer
0 Kudos

Hi Rajan,

Thank you soo much for your efforts. It will help me to get the code made easier.

The below custom function i have used...

$LV_VIN = upper($P_VIN) ;
$LV_RESULT = DECODE(length(LTRIM(RTRIM($LV_VIN, ' '),' ')) > 0 , 0 , -1 );
$LEN = length(LTRIM(RTRIM($LV_VIN, ' '),' '));
#PRINT($LEN );
IF ($LV_RESULT =0)
begin
	$LV_VINMod = $LV_VIN ;
        $LV_Pos =0;
        $LV_Value =0;
WHILE   ($LV_Pos <= $LEN )
BEGIN
 $lv_char = substr($LV_VINMod ,$LEN-$LV_Pos , 1 );
 #print('position'||$lv_char);
 $LV_Value  = $LV_Value + (cast(decode($lv_char = 'A' ,10,
                                      $lv_char = 'B' ,11,   
                                      $lv_char = 'C' ,12,
			              $lv_char = 'D' ,13,
			              $lv_char = 'E' ,14,
				      $lv_char = 'F' ,15, $lv_char),'INT') * power(16,cast($LV_Pos,'INT')));
$LV_Pos = $LV_Pos + 1;
END
END
 
PRINT ($LV_Value);
RETURN $LV_Value ;

rajan_burad
Active Participant
0 Kudos

You're welcome Kalyani 🙂 Nice to know that the function helped to achieve your scenario. 🙂

Please close the thread if its done from your end.

Answers (2)

Answers (2)

0 Kudos
former_member187605
Active Contributor
0 Kudos

Write a custom function.

You'll find plenty of examples when you Google "SAP Data Services how to convert hexadecimal to integer". Please always search before posting.

kalyani_kolli
Explorer
0 Kudos

Hi Drik,

I didn't find any examples.can you please share me the link if you find anything.

former_member187605
Active Contributor
0 Kudos