Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Entering and Reading Hex Data in Input to COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
cakask

New User


Joined: 20 Jan 2010
Posts: 11
Location: OH

PostPosted: Wed Feb 03, 2010 10:56 am    Post subject: Entering and Reading Hex Data in Input to COBOL
Reply with quote

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
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Feb 03, 2010 11:13 am    Post subject:
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 03, 2010 5:03 pm    Post subject: Reply to: Entering and Reading Hex Data in Input to COBOL
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 03, 2010 6:07 pm    Post subject: Reply to: Entering and Reading Hex Data in Input to COBOL
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us