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

Nonprintable characters in file


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

New User


Joined: 05 Apr 2006
Posts: 4

PostPosted: Fri Feb 09, 2007 5:54 pm
Reply with quote

A COBOL program is reading a file and printing it but the file contains some nonprintable characters. How to locate those nonprintable characters and replace them with spaces.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Feb 09, 2007 6:15 pm
Reply with quote

anil_jdh wrote:
A COBOL program is reading a file and printing it but the file contains some nonprintable characters. How to locate those nonprintable characters and replace them with spaces.
You have three possibilities:
You know what the unprintable character is but not where;
You know where the unprintable character is but not what;
You don't know where or what the unprintable character is.
The first case is a simple INSPECT CONVERTING and the second is a simple move. The third will need a byte-by-byte scan thru the data testing every byte for "printableness" or "unprintableness".
Have fun.... icon_biggrin.gif
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: Fri Feb 09, 2007 9:56 pm
Reply with quote

Hello,

If you can look at the file in tso/browse or view, you can find the "unprintable" characters by typing "find p'.' " in the command area and pressing enter. The editor will move the sursor from one unprintable character to the next.

If the file is too large to look at, use a utility to create a small set of the data and then look at that.

Once you know what kind of "unprintables" you are dealing with, you can code for them.
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Fri Feb 09, 2007 11:06 pm
Reply with quote

Wouldn't one just need to check for data transparency?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Feb 09, 2007 11:15 pm
Reply with quote

superk wrote:
Wouldn't one just need to check for data transparency?
Yes, sure..... icon_confused.gif BTW, what means "data transparency" and how would I do it?
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Sat Feb 10, 2007 2:16 am
Reply with quote

When EBCDIC data is transparent (i.e. non-displayable), it contains hex values less than a blank (x'40'). I guess I was wondering if each byte of data could be checked for a hex value < x'40', and then translated to x'40' if detected.
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: Sat Feb 10, 2007 2:33 am
Reply with quote

Hello,

There are also the 'unprintable' values above x'40' - for example x'61' or x'AA' or x'FE' etc.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Feb 12, 2007 12:41 am
Reply with quote

This solution might be a little tedious, but it should work fine. Using the link below create an INSPECT stmt with a sending string that contains the hex values of each non-displayable char you want to replace with a space.

The hex values you can get from the link below, for e.g.:

The chart shows that X'00' thru X'39', X'80', X'90', X'9A thru X'A0', and so on are not displayable. You would have to code the INSPECT stmt something like this:

INSPECT YOUR-REC CONVERTING X'00010203...3980909A9B9C...9E9FA0...' TO 'bbb...bbbb...'

The (...) above exposes my laziness [you'll have to fill in the (...) and the blanks (b)]. Note that the number of blanks coded in the receiving field must EQUAL the number of 2 digit hex values coded in the sending field.

BTW, you can use X'4040...40' in the receiving field. Also, don't use a variable to define the fields, make them in-line literals; it's much more efficient (only one assembler instr).

You can also blank any obscure printables from the record.

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGY3LR10/APPENDIX1.3.1
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top