Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

converting from ASCII to EBCDIC

1,786 views
Skip to first unread message

Ward Able, Grant

unread,
Mar 12, 2013, 10:59:58 AM3/12/13
to
Hi REXXers,



I need to read a file that resides in an USS directory and search for some text. However the data in the file in in ASCII format. I have done some searching but am not able to discover a method of converting the data. I am pretty sure that this must have been done a number of times by the members of this list, so can someone please give me a pointer to some document that I can read up on it?



I have tried reading it, but all I get is: "?? _%? ?>??????? > ? > ?? ??????? ? ( % ? _%> ? ?? >? ? >%?> ? "







Regards - Grant





Grant Ward Able

Senior Systems Architect

Transaction and Messaging Technologies

DTCC London

gwar...@dtcc.com

Phone 0207 650 1496







<BR>_____________________________________________________________

<FONT size=2><BR>

DTCC DISCLAIMER: This email and any files transmitted with it are

confidential and intended solely for the use of the individual or

entity to whom they are addressed. If you have received this email

in error, please notify us immediately and delete the email and any

attachments from your system. The recipient should check this email

and any attachments for the presence of viruses. The company

accepts no liability for any damage caused by any virus transmitted

by this email.</FONT>

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

Ted MacNEIL

unread,
Mar 12, 2013, 11:03:01 AM3/12/13
to
OCOPY
-
Ted MacNEIL
eama...@yahoo.ca
Twitter: @TedMacNEIL

Steve Comstock

unread,
Mar 12, 2013, 11:15:29 AM3/12/13
to
On 3/12/2013 8:59 AM, Ward Able, Grant wrote:
> Hi REXXers,
>
> I need to read a file that resides in an USS directory and search for some text. However the data in the file in in ASCII format. I have done some searching but am not able to discover a method of converting the data. I am pretty sure that this must have been done a number of times by the members of this list, so can someone please give me a pointer to some document that I can read up on it?
>
> I have tried reading it, but all I get is: "?? _%? ?>??????? > ? > ?? ??????? ? ( % ? _%> ? ?? >? ? >%?> ? "
>
>
>
> Regards - Grant
>
>
> Grant Ward Able
> Senior Systems Architect
> Transaction and Messaging Technologies
> DTCC London
> gwar...@dtcc.com
> Phone 0207 650 1496
>
>
>

If you just want to read the file, use ISPF 3.17 on
the directory and then on the file selection list
enter va next to file name to view the file and it
will translate to EBCDIC for you before displaying
the data. Then you have all the familiar 'find'
command options.

If you enter ea instead, you will be in edit of the
file; if you make changes they will be saved (in
ascii) on exit.






--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-355-2752
http://www.trainersfriend.com

* To get a good Return on your Investment, first make an investment!
+ Training your people is an excellent investment

* Try our tool for calculating your Return On Investment
for training dollars at
http://www.trainersfriend.com/ROI/roi.html

Adrian Stern

unread,
Mar 12, 2013, 11:23:41 AM3/12/13
to
If you open the file in the ispf editor there's a command, ebcdic I think,
that will display the file in ebcdic.

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Ward Able, Grant
Sent: den 12 mars 2013 15:59
To: TSO-...@VM.MARIST.EDU
Subject: [TSO-REXX] converting from ASCII to EBCDIC

Paul Gilmartin

unread,
Mar 12, 2013, 11:35:12 AM3/12/13
to
On Mar 12, 2013, at 08:59, Ward Able, Grant wrote:
>
> I need to read a file that resides in an USS directory and search for some text. However the data in the file in in ASCII format. I have done some searching but am not able to discover a method of converting the data. I am pretty sure that this must have been done a number of times by the members of this list, so can someone please give me a pointer to some document that I can read up on it?
>
I've used iconv(1) for this. It can be as simple as:

iconv -f IS0859-1 -t IBM-1047 <ASCII-FILE-NAME

Can the file be tagged as ASCII and autoconversion employed,
or is autoconversion a feature solely of the C RTL?

-- gil

John McKown

unread,
Mar 12, 2013, 12:05:33 PM3/12/13
to
As gil said, have you tried autoconvert? I have it set up. I uploaded a
Linux text file in Binary mode into my z/OS UNIX directory, resulting in an
ASCII encoded text file. I did a

chtag -tc iso8859-1 ascii.text.file

and then ran a simple z/OS UNIX REXX script:

/* rexx */
do while lines() >0
say linein()
end

chtag 755 x.rexx

./x.rexx <ascii.text.file

and it wrote out properly in EBCDIC.
--
This is a test of the Emergency Broadcast System. If this had been an
actual emergency, do you really think we'd stick around to tell you?

Maranatha! <><
John McKown

Paul Gilmartin

unread,
Mar 12, 2013, 12:24:39 PM3/12/13
to
On Mar 12, 2013, at 10:05, John McKown wrote:
>
> chtag -tc iso8859-1 ascii.text.file
>
> /* rexx */
> do while lines() >0
> say linein()
> end
>
> chtag 755 x.rexx
> ./x.rexx <ascii.text.file
>
> and it wrote out properly in EBCDIC.
>
Is this because linein() is implemented in C? Would it
work if you used "SYSCALL read?"

Brad Whiting

unread,
Mar 12, 2013, 12:40:40 PM3/12/13
to
Not sure how helpful this is but I did this read_ascii function using rexx
syscall functions to look at and process WebSphere Z files:

tmp_pth = '/tmp/someascii_file.txt'
call read_ascii tmp_pth
parse var ebc_buf . 'name="'clong.cell_t'"' .
parse var ebc_buf . 'shortName="'cshort.cell_t'"' .
parse var ebc_buf . 'cellType="'ctype.cell_t'"' .

read_ascii:
parse arg full_path
ebc_buf = ""
address syscall "open (full_path) "O_RDONLY
if retval = -1 then do
say "Function read_ascii failed to open file"
say full_path
say "err" errno "=" errnojr
return
end
fd_ascii = retval

cmd = cvt_setcvton
pccsid = '0417'x
fccsid = '0333'x

address syscall "f_control_cvt (fd_ascii) cmd pccsid fccsid"

address syscall "read (fd_ascii) ebc_buf 999999"

address syscall "close (fd_ascii)"
return



-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of

Paul Gilmartin

unread,
Mar 12, 2013, 12:58:41 PM3/12/13
to
On Mar 12, 2013, at 10:38, Brad Whiting wrote:

> Not sure how helpful this is but I did this read_ascii function using rexx
> syscall functions to look at and process WebSphere Z files:
>
Thanks for the example!

I've been doing something similar, using the Rexx TRANSLATE()
function. This is likely more efficient.

> cmd = cvt_setcvton
> pccsid = '0417'x
> fccsid = '0333'x
>
I assume these are, or could be, some code for IBM-1047
and ISO8859-1. I need to RTFM.

So, apparently, either autoconversion doesn't depend on the
C RTL, or address SYSCALL is implemented in C.

Thanks again,

Ward Able, Grant

unread,
Mar 12, 2013, 1:06:51 PM3/12/13
to
Brad - this has done the trick! Thanks very much. I had played about with f_control_cvt earlier, but obviously did not get everything specified correctly.





Regards - Grant.

Telephone Internal: 201496 (London)

Telephone External: +44 (0)207 650 1496





-----Original Message-----

From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Brad Whiting

Sent: 12 March 2013 16:39
<BR>_____________________________________________________________

<FONT size=2><BR>

DTCC DISCLAIMER: This email and any files transmitted with it are

confidential and intended solely for the use of the individual or

entity to whom they are addressed. If you have received this email

in error, please notify us immediately and delete the email and any

attachments from your system. The recipient should check this email

and any attachments for the presence of viruses. The company

accepts no liability for any damage caused by any virus transmitted

by this email.</FONT>

Bill Schoen

unread,
Mar 12, 2013, 5:32:15 PM3/12/13
to
Autoconvert does not depend on C RTL and address syscall is written in C
but it doesn't use the C RTL (uses SPC).

Bill Schoen
> .

Paul Gilmartin

unread,
Mar 12, 2013, 11:29:44 PM3/12/13
to
On Mar 12, 2013, at 15:31, Bill Schoen wrote:

> Autoconvert does not depend on C RTL and address syscall is written in C
> but it doesn't use the C RTL (uses SPC).
>
Thanks. f_control_cvt is working great for me in a PoC. Strangely
I need to convert an EBCDIC descriptor to an ASCII buffer because
NFS client performs a superfluous ASCII->EBCDIC conversion on a
binary file. I could override this in the mount command, but there
are also text files in the filesystem that I want converted.

In:
Title: z/OS V1R12.0 Using REXX and z/OS UNIX System Services
Document Number: SA22-7806-13
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/bpxzb6a0/3.36
I read:

3.36 f_control_cvt
...
Parameters
fd
The file descriptor (a number) for the file. It must be a regular
file, FIFO, or character special file.

Does "character special file" include a socket? Apparently
not, because when (just an experiment) I try connecting a
socket to iconv(1), it fails with:

iconv: Could not turn autoconversion off for [standard input]:
EDC5113I Bad file descriptor.

(unless I misunderstand my test case). There's an extreme irony
if this is so -- I can't imagine a situation in OMVS where
ASCII<->EBCDIC conversion is more useful than with a socket.

-- gil

Mickey

unread,
Mar 14, 2013, 7:49:02 AM3/14/13
to
I'm with Ted on this one, OCOPY is just simpler, especially if you code up a
quick rexx to take the input and output file names.

-----Original Message-----
From: Paul Gilmartin
Sent: Tuesday, March 12, 2013 12:23 PM
To: TSO-...@VM.MARIST.EDU
Subject: Re: [TSO-REXX] converting from ASCII to EBCDIC

Paul Gilmartin

unread,
Mar 14, 2013, 9:32:48 AM3/14/13
to
On Mar 14, 2013, at 05:48, Mickey wrote:

> I'm with Ted on this one, OCOPY is just simpler, especially if you code up a
> quick rexx to take the input and output file names.
>
The wrongest thing with OCOPY is that it works only from the TSO
side, not the USS side. And I'm in a Rexx EXEC on the USS side.

And I want the data in Rexx variables, not in another file.

There's also the matter of dreadful USS process overhead.

Brad's suggestion of cvt_setcvton is working fine for me.

Thanks,

Walter Pachl

unread,
Mar 14, 2013, 9:41:52 AM3/14/13
to
Dumb question:
Why not eline=translate(aline,translatetable,xrange(...))
With translatetable appropriately defined?

Thomas Berg

unread,
Mar 14, 2013, 9:46:32 AM3/14/13
to
> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On
> Behalf Of Paul Gilmartin
> Sent: Thursday, March 14, 2013 2:32 PM
> To: TSO-...@VM.MARIST.EDU
> Subject: Re: [TSO-REXX] converting from ASCII to EBCDIC


< snip >

> The wrongest thing with OCOPY is that it works only from the TSO side,
> not the USS side. And I'm in a Rexx EXEC on the USS side.
>
> And I want the data in Rexx variables, not in another file.
>
> There's also the matter of dreadful USS process overhead.

Are there any numbers available for the overhead ?



Regards
Thomas Berg
____________________________________________________________________
Thomas Berg Specialist z/OS\RQM\IT Delivery SWEDBANK AB (Publ)

Ward Able, Grant

unread,
Mar 14, 2013, 10:34:48 AM3/14/13
to
Walter, that sounds like something I tried, with no success either. I must have not define the xrange() tables correctly, but I ended up with my output looking the same as my input. For me, this has now become academic, as I was able to achieve the required result using the f_control_cvt function.



I would like to learn to use the xrange method though. Do you have a sample of such translate tables that you would be willing to share (privately, if required)? My source CCSID is 819 and my target is 1047.





Regards - Grant.

Telephone Internal: 201496 (London)

Telephone External: +44 (0)207 650 1496





-----Original Message-----

From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Walter Pachl

Sent: 14 March 2013 13:41

To: TSO-...@VM.MARIST.EDU

Subject: [TSO-REXX] AW: [TSO-REXX] converting from ASCII to EBCDIC
<BR>_____________________________________________________________

<FONT size=2><BR>

DTCC DISCLAIMER: This email and any files transmitted with it are

confidential and intended solely for the use of the individual or

entity to whom they are addressed. If you have received this email

in error, please notify us immediately and delete the email and any

attachments from your system. The recipient should check this email

and any attachments for the presence of viruses. The company

accepts no liability for any damage caused by any virus transmitted

by this email.</FONT>

Paul Gilmartin

unread,
Mar 14, 2013, 11:22:28 PM3/14/13
to
On Mar 14, 2013, at 07:41, Walter Pachl wrote:

> Dumb question:
> Why not eline=translate(aline,translatetable,xrange(...))
> With translatetable appropriately defined?
>
I had been doing that. I switched to the cvt_setcvton method
without even evaluating performance because I could delete
my "translatetable appropriately defined" and rely on a
SYSCALL intrinsic.

-- gil

Paul Gilmartin

unread,
Mar 14, 2013, 11:30:24 PM3/14/13
to
On Mar 14, 2013, at 07:45, Thomas Berg wrote:
>>
>> There's also the matter of dreadful USS process overhead.
>
> Are there any numbers available for the overhead ?
>
No numbers; just my subjective experience of running GNU
configure on z/OS, Solaris, and OS X. Feels like at least
a factor of 10, perhaps 50. And z/OS invented spawn (only
slightly different from POSIX spawn, and z/OS has the better
one), and relies heavily on it, and provides _BPX_SHAREAS.
Such features are rare on other OSes where address space
creation is relatively cheap. I shudder whenever I think
of "BPXAS ON INTRDR". fork() submits a batch job on punch
card images when it needs to create an address space!?
Really.

-- gil
0 new messages