Skip to Content
0

how to convert hexadecimal to integer in SAP BODS

Mar 13 at 01:14 PM

43

avatar image

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 :)

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Rajan Burad Mar 14 at 09:18 AM
0

Hello Kalyani,

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

Let me know if it helps!

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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 ;

0

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.

0
Dirk Venken
Mar 14 at 06:10 AM
0

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Drik,

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

0
0
avatar image
Former Member Mar 14 at 08:03 AM
0
Share
10 |10000 characters needed characters left characters exceeded