Hex to decimal and Ascii conversion in Server jobs
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 12
- Joined: Sat Jun 27, 2009 5:44 am
Hex to decimal and Ascii conversion in Server jobs
Hi,
I have got 1 requirment to convert the hexadecimal value from input file to Ascii and Decimal using Server jobs?
Ex:Say for column di=21 47 37 63 is hex value to be coverted
into Decimal and ascii.
Datatype for input column is number.
output:
Asci value: !G7c
Decimal value : 33715599
I need to do this in server Jobs.so if anyone knows then please share your thoughts.?
Thanks
Sandeep
I have got 1 requirment to convert the hexadecimal value from input file to Ascii and Decimal using Server jobs?
Ex:Say for column di=21 47 37 63 is hex value to be coverted
into Decimal and ascii.
Datatype for input column is number.
output:
Asci value: !G7c
Decimal value : 33715599
I need to do this in server Jobs.so if anyone knows then please share your thoughts.?
Thanks
Sandeep
For the moment, let us not use "hex" conversion, but ask what datatype you are converting from. Is is a COBOL type COMP-3 field? If so, there are builtin conversions in the SDK or the CFF stage available to you.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 12
- Joined: Sat Jun 27, 2009 5:44 am
Hi,
Its not a cobol type 3 field.
Input is coming from Datastage Tx.we can incorporate this conversion at Tx level itself but there are lot of columns to be applied so each column there will be three fields di_hex,di_dec_di,asc .so we wwant to restrict these column.
So we want to incorporate this logic at datastage level an there are some transformation to be applied and load in to target database.
Its not a cobol type 3 field.
Input is coming from Datastage Tx.we can incorporate this conversion at Tx level itself but there are lot of columns to be applied so each column there will be three fields di_hex,di_dec_di,asc .so we wwant to restrict these column.
So we want to incorporate this logic at datastage level an there are some transformation to be applied and load in to target database.
Regards,
Sandeep Jajee
Sandeep Jajee
Is it a pure binary format? Try reading it as "binary" into an integer.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Naah, I'm just doing long multiple job compiles and surf DSXchange while they run:)
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 12
- Joined: Sat Jun 27, 2009 5:44 am
Hi,
Its not a Pure Binary format.
i would like to tell with 1 example.
Say for column DI and its values which are in Hex Format.
DI
--
31 32 33 34 35 36 37 38
21 47 37 63
31 32 33 34
My requirment
-----------
if length of DI field is<=4 the i have to use Decimal Value
else if Length is >=5 then i have to use Ascii Value.
So for field 31 32 33 34 35 36 37 38 ,length is >=5 then target value should be Ascii equivalent 12345678.
I am trying to write user defined routine.
Its not a Pure Binary format.
i would like to tell with 1 example.
Say for column DI and its values which are in Hex Format.
DI
--
31 32 33 34 35 36 37 38
21 47 37 63
31 32 33 34
My requirment
-----------
if length of DI field is<=4 the i have to use Decimal Value
else if Length is >=5 then i have to use Ascii Value.
So for field 31 32 33 34 35 36 37 38 ,length is >=5 then target value should be Ascii equivalent 12345678.
I am trying to write user defined routine.
Regards,
Sandeep Jajee
Sandeep Jajee
You are making it too complex. the hex values you showed "31 32 33 34 35 36 37 38" are simple ASCII representations of the numbers you need, just read the field as ASCII instead of as a binary one.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 12
- Joined: Sat Jun 27, 2009 5:44 am
Hi,
I have got the solution.one of my friend helped me to write this Routine.
Thanks for your Response.
*********************************************************************************************************************************
* Remove the FF value and convert the multiple occurences of space to single space and then convert space to comma delimeter
*********************************************************************************************************************************
VarArg = Ereplace(Trim(Trim(InHexBaseNumber,"FF","A"),' ','R'),' ',',')
TokenCnt = Dcount(VarArg,',')
* Set the flag depending on number of tokens
TokenFlag = 0
If TokenCnt <= 4 Then TokenFlag =1
If TokenCnt >=5 Then TokenFlag =2
Ans = ''
*********************************************************************************************************************************
* If Number of tokens <=4 then convert Hex to Decimal
* If Number of tokens >=5 then covert Hex to Ascii
*********************************************************************************************************************************
If TokenFlag > 0 Then
For vcnttoken = 1 to TokenCnt step 1
var = Field(VarArg,',',vcnttoken)
Begin Case
Case TokenFlag =1
Ans= Ans:Iconv(var,'MX')
Case TokenFlag =2
Ans= Ans:Iconv(var,'MX0C')
End Case
Next
End
*********************************************************************************************************************************
I have got the solution.one of my friend helped me to write this Routine.
Thanks for your Response.
*********************************************************************************************************************************
* Remove the FF value and convert the multiple occurences of space to single space and then convert space to comma delimeter
*********************************************************************************************************************************
VarArg = Ereplace(Trim(Trim(InHexBaseNumber,"FF","A"),' ','R'),' ',',')
TokenCnt = Dcount(VarArg,',')
* Set the flag depending on number of tokens
TokenFlag = 0
If TokenCnt <= 4 Then TokenFlag =1
If TokenCnt >=5 Then TokenFlag =2
Ans = ''
*********************************************************************************************************************************
* If Number of tokens <=4 then convert Hex to Decimal
* If Number of tokens >=5 then covert Hex to Ascii
*********************************************************************************************************************************
If TokenFlag > 0 Then
For vcnttoken = 1 to TokenCnt step 1
var = Field(VarArg,',',vcnttoken)
Begin Case
Case TokenFlag =1
Ans= Ans:Iconv(var,'MX')
Case TokenFlag =2
Ans= Ans:Iconv(var,'MX0C')
End Case
Next
End
*********************************************************************************************************************************
Regards,
Sandeep Jajee
Sandeep Jajee
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: