Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 How to display offset thru cobol prog... tvinodkumar7 CICS 2 Sun Apr 22, 2018 8:42 pm
No new posts Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 4 Fri Apr 20, 2018 4:17 pm
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts Call COBOL or PLI with a click from w... vaibhav gs All Other Mainframe Topics 1 Mon Apr 16, 2018 7:29 pm
No new posts COBOL MVS options BiswajitDG COBOL Programming 8 Fri Apr 06, 2018 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us