IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert Binary to Text


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sudhakarraju

New User


Joined: 05 May 2005
Posts: 31

PostPosted: Tue Feb 23, 2010 6:52 pm
Reply with quote

How do we convert Binary data into text using a COBOL program. Do we have any utility programs than can also do this conversion on Mainframe.

I am attaching the Binary file (File to be converted) and the Text file (File after conversion).
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Feb 23, 2010 6:58 pm
Reply with quote

Many people here are not allowed to download attachments, not to mention that binary data may be changed by using a text attachment, so your post is pretty much useless. Please post the binary and text data again, using BBcode (the Code button) which can be reviewed by everyone.

Finally, when you say "binary" what do you mean? Is the data
- binary numbers?
- floating point numbers?
- packed decimal numbers?
- non-display characters?
- non-EBCDIC data?
All of these are possible interpretations of "binary" and have very different formatting requirements.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Feb 23, 2010 6:58 pm
Reply with quote

Suggest you post the attached data using BBCode - not everyone can download them, so chances of getting good help reduces. When you say binary, did you mean COBOL COMP fields?
Back to top
View user's profile Send private message
sudhakarraju

New User


Joined: 05 May 2005
Posts: 31

PostPosted: Tue Feb 23, 2010 7:04 pm
Reply with quote

Please find the data below. I am also displaying the hex version of the data.

Code:


Binary Data
L     nL
D232239D
33319453



Text Data
<claim><
48988964
C33194EC
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 7:09 pm
Reply with quote

When posting, use hex-notation for the entire value. Then, there's no question and everyone can read it.

EG: '%' is a X'6C' in EBCDIC, whereas it is X'25' in ASCII.

We're assuming you're dealing with EBCDIC....

Bill
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 7:16 pm
Reply with quote

Do you need the Binary-Data converted to 16-Bytes?

X'D3233321293495D3'

converted to a 16-Byte value of -

C'D3233321293495D3'?

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

New User


Joined: 05 May 2005
Posts: 31

PostPosted: Tue Feb 23, 2010 7:25 pm
Reply with quote

I need X'D3233321293495D3' converted to X'4C83938189946E4C'.
Back to top
View user's profile Send private message
sudhakarraju

New User


Joined: 05 May 2005
Posts: 31

PostPosted: Tue Feb 23, 2010 8:13 pm
Reply with quote

If the Binary data in a text file and I FTP the file on to mainframe as Binary, the data gets converted into a readable text format.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 8:19 pm
Reply with quote

Give this a try (not tested) -

Code:

           03  WS-FROM-FIELD       PIC  X(008).
           03  WS-TO-FIELD         PIC  X(008)
      *
           MOVE X'D3233321293495D3'    TO WS-FROM-FIELD.
           MOVE WS-FROM-FIELD          TO WS-TO-FIELD.
      *
           INSPECT WS-TO-FIELD         CONVERTING X'D3233321293495'
                                       TO X'4C83938189946E'.

After the INSPECT, WS-TO-FIELD will equal X'4C83938189946E4C'.

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

New User


Joined: 05 May 2005
Posts: 31

PostPosted: Tue Feb 23, 2010 8:25 pm
Reply with quote

Bill,

Your code will only convert the first few bytes of the file. I have a much larger file to deal with and the whole file needs to converted from Binary to Text.

Raju
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 8:39 pm
Reply with quote

Well then, you need to expound upon my posting as you posted 8-Bytes to be converted.

Bill
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 24, 2010 12:37 am
Reply with quote

Hello,

I suspect that each byte will need to be converted individually rather than the "whole field" in one statement . . .
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 24, 2010 1:12 am
Reply with quote

Dick (et al),

I thought about that, because then other standalone characters, not associated with the "FROM" value, would be converted errorneously.

Here's an alternative (RECORD AREA is merely an example) -

Code:

           03  WS-FROM-VALUE       PIC  X(008).
           03  WS-TO-VALUE         PIC  X(008).
           03  WS-RECORD-AREA      PIC  X(500).
      *
           MOVE X'D3233321293495D3'    TO WS-FROM-VALUE.
           MOVE X'4C83938189946E4C'    TO WS-TO-VALUE.
      *
           INSPECT WS-RECORD-AREA      REPLACING WS-FROM-VALUE
                                       BY WS-TO-VALUE.

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

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Feb 24, 2010 1:24 am
Reply with quote

And maybe I've missed something here, but I haven't seen anything posted yet that indicates what the rules are for the translation process?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts TEXT-TO-PDF Compuware & Other Tools 1
Search our Forums:

Back to Top