Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

decoding packed signed field 1

Status
Not open for further replies.

sarduspater

Programmer
Jan 31, 2010
38
0
0
IT
Within Spufi I'm reading a field that contains three fields values in a string.
It appears as
01F0058
0C2017C in hex, where 0001758+ is the field I would use for join with an other table.
How can I convert this in numeric?

Thanks to all

Candu si tene su 'entu es prezisu bentolare.
 

Hex
[pre]
01F 0058
0C2 017[highlight #FCE94F]C[/highlight]
[/pre]
THERE is your packed binary coded decimal

The sign...
[pre]
Sign
Digit BCD
8 4 2 1 Sign Notes
A 1 0 1 0 +
B 1 0 1 1 −
[highlight #FCE94F]C 1 1 0 0 + Preferred[/highlight]
D 1 1 0 1 − Preferred
E 1 1 1 0 +
F 1 1 1 1 + Unsigned
[/pre]


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
The problem is not to decode the sign, but the number.
In other words, I try a function like f(right(myfield, 4)) returning 1578.

Thanks

Candu si tene su 'entu es prezisu bentolare.
 
Each NIBBLE of each BYTE is a NUMERAL in your number

[pre]
0058
017C

0
0
0
1
5
7
8
+

0001578+
[/pre]


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
This is clear, but if I want join to a field in another table, I'm looking for a function for

SELECT MT1.field1, MT1.field2, MT2.field1 in MyTable1 MT1, MyTable2 MT2
WHERE FUN(right(MT1.field4, 4)) = MT2.field2;

(MT2.field2 is numeric)

Candu si tene su 'entu es prezisu bentolare.
 
Link does not work...

Thanks

Candu si tene su 'entu es prezisu bentolare.
 
Really???

I just clicked on the activated link and it opend right up.

COPY the link and PASTE it into your brower's address bar.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
My router has a DNS problem.
Now I try.

Thenks for now.

Candu si tene su 'entu es prezisu bentolare.
 
I use spufi before embed code in JCL.

Thank you, SkipVought, it works fine.


Candu si tene su 'entu es prezisu bentolare.
 

Would you please post your solution for the benefit of other Tek-Tip members.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I apologize for delay, but my pc had some problem. This is the result:

SELECT
RSDR.CTIPSOM, RSDR.DANNCON, RSDR.NRIF, RSDR.CTERINS
, RSDR.COPRINS, RSDR.DDATINS, RSDR.COPRAGG
, RSDR.DDATAGG, RSDR.SSTA, RSDR.COPR, RSDR.DCON
, RSDR.NOPE, RSDR.CFIS
, RSDR.CTIPARC, RSDR.IIMP
, RSDR.SSTASOM, RSDR.SSTAUTI, RSDR.COPRRIM, RSDR.DRIM
, RSDR.NOPERIM, RSDR.SMODRIM, RSDR.NDOCRIM
, PDTR.DINTPAR, PDTR.NINTPAR, PDTR.NPRGTRI
, PDTR.DINTPRO, PDTR.STIPPRO, PDTR.NINTPRO
, CATR.NCAR
FROM ME.FETBRSDR RSDR,
ME.FETBPDTR PDTR,
ME.FETBCATR CATR
WHERE
RSDR.CTIPARC = 'PDI'
AND DEC(LEFT(HEX(LEFT(KARC, 2)), 3), 2, 0) = PDTR.CCOS
AND DEC(LEFT(HEX(SUBSTR(KARC, 3, 2)), 3), 2, 0) = PDTR.CCOC
AND DEC(LEFT(HEX(SUBSTR(KARC, 5, 3)), 5), 4, 0) = PDTR.DINTPRO
AND SUBSTR(KARC, 8, 1) = PDTR.STIPPRO
AND DEC(LEFT(HEX(SUBSTR(KARC, 9, 5)), 7), 6, 0) = PDTR.NINTPRO

AND RSDR.DRIM > 0
AND PDTR.CCOS = CATR.CCOS
AND PDTR.CCOC = CATR.CCOC
AND PDTR.DINTPAR = CATR.DINTPAR
AND PDTR.NINTPAR = CATR.NINTPAR
AND PDTR.NPRGTRI = CATR.NPRGTRI;

Thanks.

Candu si tene su 'entu es prezisu bentolare.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top