IDENTIFICATION DIVISION.                                    
                                                             
 PROGRAM-ID.     CONVHEX.                                    
                                                             
* MODULE TO CONVERT CHARS TO HEX                             
*                                                            
* MODIFICATION HISTORY:                                      
*                                                            
                                                             
 ENVIRONMENT DIVISION.                                       
                                                             
 DATA DIVISION.                                              
 WORKING-STORAGE SECTION.                                    
                                                             
                                                             
 01  CHARS-POINTER       PIC S9(8) COMP.                     
                                                             
 01  HEX-POINTER         PIC S9(8) COMP.                     
                                                             
 01  TAB-INDX.                                               
 04  TAB-IND             PIC S9(8) COMP.                     
                                                             
 01  TAB.                                                    
  04 T0 PIC X(32) VALUE  '000102030405060708090A0B0C0D0E0F'. 
  04 T1 PIC X(32) VALUE  '101112131415161718191A1B1C1D1E1F'. 
  04 T2 PIC X(32) VALUE  '202122232425262728292A2B2C2D2E2F'. 
  04 T3 PIC X(32) VALUE  '303132333435363738393A3B3C3D3E3F'. 
  04 T4 PIC X(32) VALUE  '404142434445464748494A4B4C4D4E4F'. 
  04 T5 PIC X(32) VALUE  '505152535455565758595A5B5C5D5E5F'. 
  04 T6 PIC X(32) VALUE  '606162636465666768696A6B6C6D6E6F'. 
  04 T7 PIC X(32) VALUE  '707172737475767778797A7B7C7D7E7F'. 
  04 T8 PIC X(32) VALUE  '808182838485868788898A8B8C8D8E8F'. 
  04 T9 PIC X(32) VALUE  '909192939495969798999A9B9C9D9E9F'. 
  04 TA PIC X(32) VALUE  'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'. 
  04 TB PIC X(32) VALUE  'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'. 
  04 TC PIC X(32) VALUE  'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'. 
  04 TD PIC X(32) VALUE  'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'. 
  04 TE PIC X(32) VALUE  'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'. 
  04 TF PIC X(32) VALUE  'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
                                                            
                                                            
                                                            
                                                            
 LINKAGE SECTION.                                           
                                                            
 01  CHARS               PIC X(100000).                     
                                                            
 01  HEX                 PIC X(200000).                     
                                                            
 01  LEN                 PIC S9(8) COMP.                    
                                                            
                                                            
 PROCEDURE DIVISION USING CHARS HEX LEN.                    
                                                            
                                                            
     MOVE 'N' TO HEX(1:1)                                   
                                                            
     IF LEN NOT > 0 GOBACK END-IF                           
                                                            
     MOVE 1 TO CHARS-POINTER                                
     MOVE 1 TO  HEX-POINTER                                 
                                                            
     PERFORM UNTIL CHARS-POINTER > LEN                      
                                                            
                                                            
         MOVE 0 TO TAB-IND                                  
         MOVE CHARS(CHARS-POINTER:1) TO TAB-INDX(4:1)       
         COMPUTE TAB-IND = (TAB-IND * 2) + 1                
         MOVE TAB(TAB-IND:2) TO HEX(HEX-POINTER:2)          
         ADD 1 TO CHARS-POINTER                             
         ADD 2 TO  HEX-POINTER                              
                                                            
                                                            
     END-PERFORM                                            
                                                            
     GOBACK.                                                

http://www.thenightland.co.uk/MYWEB/mvsxmitmail.html

Ddownload it, and look for



 ~~~~~~~~~~~~ Andy Robertson   telephone mobile 0777 214 9545 home 01308 420797



-----IBM Mainframe Discussion List <IBM-MAIN@bama.ua.edu> wrote: -----


To: IBM-MAIN@bama.ua.edu
From: Donald Johnson <dej....@gmail.com>
Sent by: IBM Mainframe Discussion List <IBM-MAIN@bama.ua.edu>
Date: 06/09/2010 09:36PM
Subject: Cobol routine to convert TEXT to displayable HEX

Hi guys and gals!

Does anyone have a routine (COBOL preferable) that converts a standard text
field into its HEX values?

For example, if I have a field 'BEFORE,' I want to be able to translate it
to
CCCDDC
256695

or to C2C5C6D6D9C5.

My ultimate goal is the first choice (vertical format), but I can deal with
either. I will code this in my COBOL program, so that is why COBOL...I can
do it in other places easily, but I am trying to create a model program that
is self contained.

Thanks in advance!
* Don *

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
**********************************************************************
This email is confidential and may contain copyright material of the John Lewis 
Partnership. 
If you are not the intended recipient, please notify us immediately and delete 
all copies of this message. 
(Please note that it is your responsibility to scan this message for viruses). 
Email to and from the
John Lewis Partnership is automatically monitored for operational and lawful 
business reasons.
**********************************************************************

John Lewis plc
Registered in England 233462
Registered office 171 Victoria Street London SW1E 5NN
 
Websites: http://www.johnlewis.com 
http://www.waitrose.com 
http://www.greenbee.com
http://www.johnlewispartnership.co.uk
 
**********************************************************************

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to