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
 

 

How to display a variable in the HEXADECIMAL format in Cobol

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

New User


Joined: 25 May 2005
Posts: 20

PostPosted: Tue Jun 14, 2005 10:18 am    Post subject: How to display a variable in the HEXADECIMAL format in Cobol
Reply with quote

Hi,
Suppose i move a value to a variable.

Is it possible to display a variable in the HEXADECIMAL format in Cobol

bye

lal
Back to top
View user's profile Send private message

j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Tue Jun 14, 2005 12:22 pm    Post subject: Re: How to display a variable in the HEXADECIMAL format in C
Reply with quote

Hi shajeeth,

Write the value into a file and type hex on so that the value will be displayed in hexadecimal form. Correct me if i am wrong.
Back to top
View user's profile Send private message
vel2k8

New User


Joined: 10 Jun 2005
Posts: 11
Location: Jacksonville

PostPosted: Tue Jun 14, 2005 1:56 pm    Post subject: Re: How to display a variable in the HEXADECIMAL format in C
Reply with quote

Hi,

Converting the contents of a data item to printable hexadecimal
notation... it's not as difficult as you think.
This solution is coded as a COBOL subroutine using 3 parameters. It does not DISPLAY anything, but converts
data into a displayable format. Each input character is
converted from 1 byte into 2 "displayable" bytes and is done 8
bytes at a time. This routine does not use any tables, DISPLAYs,
or MOVE CORRESPONDING and can handle an input field up to
16383 bytes.


Code:

IDENTIFICATION DIVISION.
PROGRAM-ID. HEXCOBOL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 FILLER.
05 I PIC S9(4) VALUE ZERO COMP.
05 J PIC S9(4) VALUE ZERO COMP.
05 L PIC S9(4) VALUE ZERO COMP.
05 WS-ONUM-DECIMAL-C.
10 WS-ONUM-DECIMAL PIC S9(17) VALUE ZERO COMP-3.
05 WS-ONUM-DISPLAY-C.
10 WS-ONUM-DISPLAY PIC 9(17) VALUE ZERO.
SKIP3
LINKAGE SECTION.

01 LK-OFLD-LEN PIC S9(4) COMP.
01 LK-IFLD-TXT PIC X(16383).
01 LK-OFLD-TXT PIC X(32767).
EJECT
PROCEDURE DIVISION USING LK-IFLD-TXT
LK-OFLD-LEN
LK-OFLD-TXT.
IF LK-OFLD-LEN > ZERO
IF LK-OFLD-LEN > LENGTH OF LK-IFLD-TXT
MOVE +4 TO RETURN-CODE
ELSE
MOVE +1 TO J
MOVE LK-IFLD-TXT (1:8) TO WS-ONUM-DECIMAL-C (1:8)
MOVE WS-ONUM-DECIMAL TO WS-ONUM-DISPLAY
COMPUTE L = LK-OFLD-LEN
PERFORM VARYING I FROM 9 BY 8
UNTIL L < 16
MOVE WS-ONUM-DISPLAY-C (1:16) TO LK-OFLD-TXT (J:16)
MOVE LK-IFLD-TXT (I:8) TO WS-ONUM-DECIMAL-C (1:8)
MOVE WS-ONUM-DECIMAL TO WS-ONUM-DISPLAY
ADD +16 TO J
ADD -16 TO L
END-PERFORM
IF L > ZERO
MOVE WS-ONUM-DISPLAY-C (1:L) TO LK-OFLD-TXT (J:L)
END-IF
INSPECT LK-OFLD-TXT (1:LK-OFLD-LEN)
CONVERTING X'FAFBFCFDFEFF' TO 'ABCDEF'
MOVE ZERO TO RETURN-CODE
END-IF
ELSE
MOVE +8 TO RETURN-CODE
END-IF.

GOBACK.

Thanks
Vel.
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 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 Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am


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