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
 

 

Hex value conversions ASCII

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

New User


Joined: 05 Nov 2008
Posts: 7
Location: RI

PostPosted: Thu Nov 06, 2008 9:13 pm    Post subject: Hex value conversions ASCII
Reply with quote

I'm new to this site and have searched in vain to find a solution to my little problem. I need to convert some data that is in ASCII.

The situation is I have ASCII field coming in, convert it to EBCIDIC and run it through some encription software, it comes back out as a PIC 9(16) with hex values of

3333333333333333
4444123456789012

I need to convert this to hex values:

44135791
44246802

I have tried moving it to a Comp, Comp-3 and Comp-4 field to no avail, any suggestions on how this may be done would be greatly appreciated. I've never run aything like this before.

regards,
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Nov 06, 2008 10:02 pm    Post subject:
Reply with quote

I would rather do this in rexx than cobol. (or assembler).
I imagine Bill will be along in a while and whip up one of his COBOL solutions.
Talk about bit fiddeling.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Thu Nov 06, 2008 10:21 pm    Post subject:
Reply with quote

Quote:
run it through some encription software, it comes back out as a PIC 9(16)
Huh? Encryption software should be generating PIC X(16) values since, unless the encryption is explicitly limiting itself to an output range of values, any possible collating sequence value can be generated.

I suspect the COBOL code to get rid of the threes and pack the nybbles into bytes will be convoluted -- I'd much rather do something like that in Assembler (which could be a subroutine callable from the COBOL module).
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: Thu Nov 06, 2008 10:35 pm    Post subject: Re: Hex value conversions ASCII
Reply with quote

Bob,

Can the ZONE nibbles of each byte be discarded, regardless of their value and the NUMERIC nibbles can be in the range of a 4-Bit '0' thru a 4-Bit 'F'?

Regards,

Bill
Back to top
View user's profile Send private message
Bob Ream

New User


Joined: 05 Nov 2008
Posts: 7
Location: RI

PostPosted: Thu Nov 06, 2008 10:59 pm    Post subject:
Reply with quote

Bill,
Can the ZONE nibbles of each byte be discarded, regardless of their value and the NUMERIC nibbles can be in the range of a 4-Bit '0' thru a 4-Bit 'F'?

Not sure. The values that I need are going into another software product and if I try and feed them the way they are it really messes things up. Since this is credit card data I really don't want to screw up someone's account....would not be a pretty picture. At this point I'm willing to try just about anything, including an assembler routine if that is the only possible way of doing this...of course then again I would have to learn assembler.
Back to top
View user's profile Send private message
Bob Ream

New User


Joined: 05 Nov 2008
Posts: 7
Location: RI

PostPosted: Thu Nov 06, 2008 11:02 pm    Post subject:
Reply with quote

The encryption product is returning a pic 9(16) as described above, then I need to convert it so the next software product will take it in.
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: Thu Nov 06, 2008 11:14 pm    Post subject: Re: Hex value conversions ASCII
Reply with quote

Bob,

Check if this will work for you....

Code:

           03  WS-XLATE-INPUT      PIC  X(016).                           
           03  WS-XLATE-WORK       PIC  X(016).                           
           03  WS-XLATE-OUTPUT     PIC  X(008).                           
           03  WS-SUB              PIC  9(008)     BINARY.               
           03  WS-SUB-X            REDEFINES WS-SUB                       
                                   PIC  X(004).                           
           03  WS-PACKED           PIC  9(017)     PACKED-DECIMAL.       
           03  WS-PACKED-V9        REDEFINES WS-PACKED                   
                                   PIC  9(016)V9   PACKED-DECIMAL.       
           03  WS-PACKED-X         REDEFINES WS-PACKED                   
                                   PIC  X(009).                           
           03  WS-DISPLAY          PIC  9(017).                           
           03  WS-DISPLAY-V9       REDEFINES WS-DISPLAY                   
                                   PIC  9(016)V9.                         
           03  WS-DISPLAY-X        REDEFINES WS-DISPLAY                   
                                   PIC  X(017).                           
      *                                                                   
           MOVE X'303132333435363738393A3B3C3D3E3F'                       
                                       TO WS-XLATE-INPUT.                 
           MOVE WS-XLATE-INPUT         TO WS-XLATE-WORK.                 
           MOVE ZERO                   TO WS-SUB.                         
           MOVE 1                      TO TALLY.                         
      *                                                                   
      *    EACH BYTE WILL TRANSLATE TO X'F0' THRU X'FF', WITH THE ZONE   
      *    NIBBLE OF THE ORIGINAL DATA-BYTE DISCARDED. THE TRANSLATED     
      *    ZONE NIBBLE IS DISCARDED DURING A 'PACK', WHEN THE DISPLAY-V9 
      *    FIELD IS MOVED TO THE PACKED-V9 FIELD AND ONLY THE 4-BIT       
      *    NUMERIC NIBBLES ARE RETAINED.                                 
      *                                                                   
           PERFORM UNTIL TALLY > LENGTH OF WS-XLATE-WORK                 
               MOVE WS-XLATE-WORK (TALLY:1)                               
                                       TO WS-SUB-X (4:)                   
               COMPUTE WS-SUB          = (WS-SUB * 16)                   
               COMPUTE WS-SUB          = (WS-SUB / 16)                   
               MOVE LOW-VALUE          TO WS-SUB-X (3:1)                 
               ADD  240                TO WS-SUB                         
               MOVE WS-SUB-X (4:)      TO WS-XLATE-WORK (TALLY:1)         
               ADD  1                  TO TALLY                           
           END-PERFORM.                                                   
      *                                                                   
           MOVE WS-XLATE-WORK          TO WS-DISPLAY-X (1:16).           
           MOVE ZERO                   TO WS-DISPLAY-X (17:).             
           MOVE WS-DISPLAY-V9          TO WS-PACKED-V9.                   
           MOVE WS-PACKED-X            TO WS-XLATE-OUTPUT.               
      *                                                                   
      *    THE RESULT IN WS-XLATE-OUTPUT WILL BE X'0123456789ABCDEF'     
      *                                                                   

Regards,

Bill
Back to top
View user's profile Send private message
Bob Ream

New User


Joined: 05 Nov 2008
Posts: 7
Location: RI

PostPosted: Thu Nov 06, 2008 11:19 pm    Post subject:
Reply with quote

Thanks, I'll give it a shot and let you know.
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: Thu Nov 06, 2008 11:25 pm    Post subject: Re: Oops!
Reply with quote

Bob,

In the above code -

Code:

              COMPUTE WS-SUB          = (WS-SUB / 16)                   
              MOVE LOW-VALUE          TO WS-SUB-X (3:1) 

Needs to be changed to -

Code:
               
               MOVE LOW-VALUE          TO WS-SUB-X (3:1)                 
               COMPUTE WS-SUB          = (WS-SUB / 16)     

Went too fast....

Regards,

Bill
Back to top
View user's profile Send private message
Bob Ream

New User


Joined: 05 Nov 2008
Posts: 7
Location: RI

PostPosted: Fri Nov 07, 2008 12:34 am    Post subject:
Reply with quote

Bill,

Looks like this will work, I am however off one byte, dropping the 1st postion and picking up the FF at the end. Here is the output displayed in hex.

4444123456789012
FFFFFFFFFFFFFFFF
4444123456789012

à..îÌ°..
4135791F
4246802F

I will have to play around with it and see if I can get it down.
Thank you for the assist.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Nov 07, 2008 1:03 am    Post subject:
Reply with quote

Bob: at least you're not having to deal with PCI compliant encryption -- I spent a good part of last year dealing with that issue and it wasn't fun!
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: Fri Nov 07, 2008 1:20 am    Post subject:
Reply with quote

Robert,

I'm dealing with this same issue in my shop as we speak. Did you have to interact with CyberSource in California or did you use someone else?

We're going live on 11 November and right now, I'm not overly optimistic.

Regards,

Bill
Back to top
View user's profile Send private message
Bob Ream

New User


Joined: 05 Nov 2008
Posts: 7
Location: RI

PostPosted: Fri Nov 07, 2008 1:22 am    Post subject:
Reply with quote

Robert,

I am dealing with encryption compliance now....what a pain. It is dealing with Mainframe calling unix, calling web server and back to mainframe also mixed in with C+ code. This all goes on in between 2 programs that are part of a package bought in 1996 and maintenance was dropped in 1999. Dealing with ASCII to EBCDIC conversions and back to ASCII then into one of the packaged programs that convert it back to EBCDIC.

My head hurts, I'm going home.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Nov 07, 2008 1:25 am    Post subject:
Reply with quote

Bill: We wound up using ZIP-390 from Data/21 which supports field-level PCI-compliant encryption. The routines are called from COBOL batch, COBOL CICS, and batch SAS programs.

Bob: I hear you -- my head's hurting and I don't even deal with that mess! icon_smile.gif
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: Fri Nov 07, 2008 1:28 am    Post subject:
Reply with quote

Bob,

Because I typically over engineer things some times icon_wink.gif , if you need to discard the ZONES, then the PACK will discard them for you, regardless of their value.

So, the perform loop may not be needed.

However, I am getting the resulting value of X'0123456789ABCDEF' in WS-PACKED-X (1:8) after all is said and done, with a X'0F' in byte-09.

Just make sure that you're using the "V9" numeric-fields as this makes a difference as well as make sure you apply the fix to the supplied-code, which I posted after the fact if you decide to keep the perform loop.

Regards,

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 EBCDIC to ASCII conversion using OCOPY mistah kurtz All Other Mainframe Topics 5 Tue Sep 06, 2016 2:26 pm
No new posts How to display data in separate lines... salilnigam1970 DFSORT/ICETOOL 2 Tue Jan 26, 2016 9:49 pm
No new posts How to display data in separate lines... salilnigam1970 JCL & VSAM 6 Tue Jan 26, 2016 5:30 pm
No new posts IBM Encryption Facility OpenPGP - ASC... Mark Walker69 IBM Tools 3 Thu Oct 15, 2015 10:43 pm
No new posts change report from ASCII to base64 yincw CLIST & REXX 9 Fri Jan 09, 2015 7:29 pm


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