View previous topic :: View next topic
|
Author |
Message |
cakask
New User
Joined: 20 Jan 2010 Posts: 11 Location: OH
|
|
|
|
I have an 8 character Hex field (which happens to be an IDMS dbkey) - for example: 3B823417 - and I need to be able to process an input file contains a number of records with this data.
Such as
//INFILE DD *
3B823417
3B82340C
/*
I know that I can turn HEX on in tso but to enter the values I will have to manually type them into the two rows.
so it would look like
000001 b b 17 3899960 23 0998389783
3831444444444383144FF4FFFFFFF4FF44FFFFFFFFFF4444
B247000000000B2470017038999600230009983897830000
or more simply
3831
B247
But I need to know how I can enter 8 characters of hex data 3B823417 and get the COBOL program to "understand" or read it as though it were a COMP with the 4 bytes = '3B823417'. (which converts to 0998389783 in decimal - which I will then be able to use as the DBKEY in an IDMS command "FIND DB-KEY w-dbkey"
The have DFSORT, so if there were convesion option I could try that as well.
Thank you for any ideas. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
One way to do what you want is to create an array that contains all of the 2-char values from 00 to FF and the one-byte hex equivelent.
For example the array entry for 3B would have a 1-byte result value of x'3B'. This entry might be:
05 char3B pic xx value '3B'
05 hex3B pic x value x'3B'
The array would have 256 entries - from 00 thru FF. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Give this a try -
Code: |
03 WS-DISPLAY PIC 9(08)V9.
03 WS-DISPLAY-X REDEFINES WS-DISPLAY PIC X(09).
03 WS-PACKED PIC 9(08)V9 COMP-3.
03 WS-PACKED-X REDEFINES WS-PACKED PIC X(05).
03 WS-SYSIN-VALUE PIC X(08) VALUE '3B823417'.
03 WS-HEX-VALUE PIC X(04).
MOVE WS-SYSIN-VALUE TO WS-DISPLAY-X.
MOVE ZERO TO WS-DISPLAY-X (9:).
INSPECT WS-DISPLAY-X CONVERTING 'ABCDEF' TO X'FAFBFCFDFEFF'.
MOVE WS-DISPLAY TO WS-PACKED.
MOVE WS-PACKED-X TO WS-HEX-VALUE.
|
At this point WS-HEX-VALUE equals X'3B823417'.
Note: WS-DISPLAY and WS-PACKED must be UNSIGNED, as illustrated.
Bill |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
After further review -
Code: |
03 WS-FWORD PIC 9(09) COMP.
03 WS-FWORD-X REDEFINES WS-FWORD PIC X(04).
03 WS-DBKEY PIC 9(10).
MOVE WS-HEX-VALUE TO WS-FWORD-X.
MOVE WS-FWORD TO WS-DBKEY.
|
You can probably get rid of a couple of fields and redefine them over others, resulting in less MOVE statements.
Bill |
|
Back to top |
|
|
|