MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hex Display

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
tcdcit
Beginner


Joined: 16 Sep 2003
Posts: 3
Topics: 2

PostPosted: Sat Nov 19, 2005 11:10 pm    Post subject: Hex Display Reply with quote

I have the following requirement.

One of the field in a file is 13 char long and contains somevalue like below.
.YA..........

When view this is HEX mode
0EC4444444400
381BBBBBBBB01

So my requirement is to print the above hex char in vertical like
03E8C14B4B4B4B4B4B4B4B0001 into a 26 char field into another file.

How can I do this in Cobol? Is there any special functions available in cobol ? I think I am clear in describing the problem, if not please let me know.
_________________
Tcd Cit
India
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Sun Nov 20, 2005 6:22 am    Post subject: Reply with quote

tcdcit,

Please search before posting. check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=2592&highlight=hex

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tcdcit
Beginner


Joined: 16 Sep 2003
Posts: 3
Topics: 2

PostPosted: Mon Nov 21, 2005 10:07 pm    Post subject: Reply with quote

Hi Kolusu,
Thanks for the reply.
But still I am facing the problem. All of the codes are working fine when I initialize the input field with the required value. Where as when I am trying to convert the from a file I am not able to do.
Case 1:
THE INPUT IS:XYZ@!$123*;6B
THE RESULT IS:E7E8E97C5A5BF1F2F35C5EF6C2

Case 2 :
THE INPUT IS: YA........
THE RESULT IS:
THE INPUT IS: YAA......0
THE RESULT IS:
THE INPUT IS: YAAA......
THE RESULT IS:

In case 1 , I have initialized the input field with XYZ@!$123*;6B , So I got the answer.
In case 2 , I was reading one file and passing those value for translation.
In this case I am getting only spaces. Where is the problem? Any help? Sad
_________________
Tcd Cit
India
Back to top
View user's profile Send private message
kbn
Beginner


Joined: 14 Nov 2005
Posts: 13
Topics: 10

PostPosted: Tue Nov 22, 2005 2:13 am    Post subject: Reply with quote

tcdcit,

Please try this.
It worked for me
Code:

FILE-CONTROL.                                         
                                                     
    SELECT I01-INPUT-FILE       ASSIGN TO UT-S-INPUT.
    SELECT O01-OUTPUT-FILE      ASSIGN TO UT-S-OUTPUT.
                                                     
DATA DIVISION.                                       
FILE SECTION.
FD I01-INPUT-FILE                                 
      RECORDING MODE IS F                         
      DATA RECORD IS I01-INPUT-FILE-RECORD.       
01 I01-INPUT-FILE-RECORD              PIC X(10). 
FD O01-OUTPUT-FILE                               
      RECORDING MODE IS F                         
      DATA RECORD IS O01-OUTPUT-FILE-RECORD.     
01 O01-OUTPUT-FILE-RECORD             PIC X(20). 
                                                 
WORKING-STORAGE SECTION.                         
01 VARIABLES.                                               
   05 NUM                PIC 999 COMP.                       
   05 HIGH               PIC 99 COMP.                       
   05 LOW                PIC 99 COMP.                       
   05 WS-INPUT           PIC X(10).                         
   05 WS-OUTPUT          PIC X(20).                         
   05 WS-HEX-DIGITS      PIC X(16) VALUE '0123456789ABCDEF'.
   05 FILLER REDEFINES WS-HEX-DIGITS.                       
      10 WS-HEX-DIGIT    PIC X(01) OCCURS 16 TIMES.         
                                                             
   05 SUB                PIC 9(04).                         
   05 SUB1               PIC 9(04) VALUE 0.                 
   05 WS-EOF             PIC X(01) VALUE 'N'.               
      88 EOF                       VALUE 'Y'.               
                                                             
PROCEDURE DIVISION.                                         
0000-MAIN.                                                   
                                                             
    OPEN INPUT I01-INPUT-FILE                               
         OUTPUT O01-OUTPUT-FILE.                             
                                                             
    PERFORM READ-INPUT     THRU READ-INPUT-EXIT.             
    PERFORM PROCESS-INPUT  THRU PROCESS-INPUT-EXIT UNTIL EOF.
                                                             
    CLOSE I01-INPUT-FILE                                     
          O01-OUTPUT-FILE.                                   
                                                             
0000-EXIT.                                                   
    GOBACK.                                                 
                                                             
READ-INPUT.                                                 
                                                             
    READ I01-INPUT-FILE                                     
         AT END SET EOF TO TRUE                             
    END-READ.                                       
                                                     
READ-INPUT-EXIT.                                     
    EXIT.                                           
                                                     
PROCESS-INPUT.                                       
    MOVE I01-INPUT-FILE-RECORD  TO WS-INPUT         
    MOVE 0                      TO SUB1             
    MOVE SPACES                 TO WS-OUTPUT         
                                                     
    PERFORM VARYING SUB FROM 1 BY 1 UNTIL SUB > 10   
        COMPUTE NUM = FUNCTION ORD (WS-INPUT(SUB:1))
        COMPUTE NUM = NUM + 1                       
        DIVIDE NUM BY 16 GIVING HIGH REMAINDER LOW   
        ADD 1 TO HIGH LOW                           
        ADD 1 TO SUB1                               
        MOVE WS-HEX-DIGIT(HIGH) TO WS-OUTPUT(SUB1:1)
        ADD 1 TO SUB1                               
        MOVE WS-HEX-DIGIT(LOW)  TO WS-OUTPUT(SUB1:1)
                                                 
    END-PERFORM.                                 
                                                 
    WRITE O01-OUTPUT-FILE-RECORD FROM WS-OUTPUT 
                                                 
    PERFORM READ-INPUT     THRU READ-INPUT-EXIT.
PROCESS-INPUT-EXIT.                             
    EXIT.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group