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
 

 

Convert Binary to Text

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

New User


Joined: 05 May 2005
Posts: 26

PostPosted: Tue Feb 23, 2010 6:52 pm    Post subject: Convert Binary to Text
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: 7914
Location: Bellevue, IA

PostPosted: Tue Feb 23, 2010 6:58 pm    Post subject:
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

Senior Member


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

PostPosted: Tue Feb 23, 2010 6:58 pm    Post subject:
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: 26

PostPosted: Tue Feb 23, 2010 7:04 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 7:09 pm    Post subject: Reply to: Convert Binary to Text
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 7:16 pm    Post subject: Reply to: Convert Binary to Text
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: 26

PostPosted: Tue Feb 23, 2010 7:25 pm    Post subject:
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: 26

PostPosted: Tue Feb 23, 2010 8:13 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 8:19 pm    Post subject: Reply to: Convert Binary to Text
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: 26

PostPosted: Tue Feb 23, 2010 8:25 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 23, 2010 8:39 pm    Post subject: Reply to: Convert Binary to Text
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

Site Director


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

PostPosted: Wed Feb 24, 2010 12:37 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 24, 2010 1:12 am    Post subject: Reply to: Convert Binary to Text
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

Moderator Team Head


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

PostPosted: Wed Feb 24, 2010 1:24 am    Post subject: Reply to: Convert Binary to Text
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    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 convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


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