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

retrieving & displaying spool file

627 views
Skip to first unread message

nis

unread,
Oct 13, 2006, 2:28:46 PM10/13/06
to
Hi,

I am trying to read a spool file on AS400 thru java and am trying to
convert the retrieved bytes into String. It seems it is reading some
junk characters(may be spaces ) and than starts reading the actual
data. It also prints "?{.' at the start of each line. It doesn't read
the data till the end of file and stops half way thru....

Here is the code snippet that I am using

InputStream in = null;

SpooledFile splf= new SpooledFile(....);

in = splf.getInputStream();

byte[] byteArr = new byte[in.available()];

in.read(byteArr);

String output = new String(byteArr,"Cp037");

It gives me the same output even if I use BufferedReader.

InputStreamReader inp = new InputStreamReader(in,"Cp037");
BufferedReader reader = new BufferedReader(inp);
String output = reader.readLine();

I tried using AS400Text class also....
AS400Text text = new AS400Text(byteArr.length,"Cp037");
String output = ((String)text.toObject(byteArr));

All of them give the same output. Is it something to do with the
encoding type ??
If I don't use "Cp037" encoding type, it prints all junk....

Any ideas where I am wrong...??
Thanks in advance....I am new in this area n any help would be
appreciated...

Thanks,
nis

Rodney A. Johnson

unread,
Oct 14, 2006, 7:11:32 PM10/14/06
to
Take a close look at the documentation for the method. The read from
the spooled file sounds like raw data stream (i.e. scs). You would need
to know the data stream and strip out everything that wasn't text
(essentially everything below '40'x...beware of '0e'x and '0f'x for
double byte and the carriage return, line feed, and form feed controls).
SCS is described to some extent in the iSeries Information Center (in
the appendix of the Printer Device Programming book for verions V5R3 or
earlier).

The code page to use really depends upon what the data is encoded in in
the spooled file. If your i5/OS is using the defaults for US English,
37 would be the correct choice.

The CHRID attribute of the spooled file might have the encoding of the
data, but typically it doesn't and just has special value for *DEVD.

In V5R4, a new spooled file attribute was added...the attribute is a
capture of the job's CCSID at the time the spooled file was created. It
might represent the encoding of the data and it might not...since the
encoding of the data is really under the control of the application
generating the spooled file.


--
Rodney A Johnson
Technical Team Lead for i5/OS (AS/400) Spool
Dept GJC
IBM Rochester, Minnesota

The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, IBM. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.

FT

unread,
Oct 16, 2006, 12:32:09 PM10/16/06
to
Hi NIS,

You can also use the SCS conversion..... check out
http://www.brooksnet.com/as400-printing.html and the SCS page at
http://lpd.brooksnet.com/scstoascii-translation.html for your
translations...

Hope this helps,

FT

nis

unread,
Oct 16, 2006, 3:35:05 PM10/16/06
to
Thanks for your reply.

But I am totally new to this world of AS400, so plz pardon me if my
questions sound silly.

I checked the type for the spool file and it indeed is SCS format. Now,
when I try to print out the bytes thru a for loop, I get kinda
following signed output.
52, -60, 1, 0, 43, -46, 3, 69, -1, 0, 43, -46, 4, 76, 0, 3, 0, 43,
-46, 4, 13, 0, 0, 0, 43, -46, 10,
-123, 1, 1...etc

I am not sure what this raw data represents out of the spool
file.....but when I print it after converting it to string(as mentioned
before)....except for 2 lines in the start and a couple of character
for each line in the beginning ...everything else gets printed.

I am all confused as to what it is going on..

I tried to get some info regarding SCS, but as per my understaning
there is SCS5256Writer, etc available for writer thingy, but what do I
do to read it.

Waiting for your input,

Thanks,
Nisarg.

Dr.UgoGagliardelli

unread,
Oct 17, 2006, 2:46:15 AM10/17/06
to
nis wrote:
> Thanks for your reply.
>
> But I am totally new to this world of AS400, so plz pardon me if my
> questions sound silly.
>
> I checked the type for the spool file and it indeed is SCS format. Now,
> when I try to print out the bytes thru a for loop, I get kinda
> following signed output.
> 52, -60, 1, 0, 43, -46, 3, 69, -1, 0, 43, -46, 4, 76, 0, 3, 0, 43,
> -46, 4, 13, 0, 0, 0, 43, -46, 10,
> -123, 1, 1...etc
This is the decimal notation of signed chars (the primitive Java type
byte), to print them you should at least cast to unsigned (the primitive
Java type char) then they possibly are EBCDIC codes so you will not see
nothing unless you convert from an EBCDIC code page (e.g. new
String(chars, "Cp280").
Further more I see values under hex 40 (dec 64) that should be control
characters of the SCS datastream.
To get the spool text you should use the gettransformedinputstream method.

--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

nis

unread,
Oct 18, 2006, 10:05:08 AM10/18/06
to
hey guys,

thanks for d replies...
I got d solution ...i need to use printparameterlist and
getTransformedInputStream() to extract text out of spool file.

The encoding thingy still bounces my head off.

Thanks,
Nisarg.

Jonathan Bailey

unread,
Oct 19, 2006, 6:46:50 AM10/19/06
to

nis wrote:
> hey guys,
>
> thanks for d replies...
> I got d solution ...i need to use printparameterlist and
> getTransformedInputStream() to extract text out of spool file.
>
> The encoding thingy still bounces my head off.
>
> Thanks,
> Nisarg.
>

If you look at it another way..A spool file is data more or less ready
to be printed. If you printed plain text on a windows system using the
printer driver but to a file, then try reading the output from that you
would have quite a good time. On old dot matrix printers the output for
just 1 line of text could be a couple of kilobyes.

Jonathan.

nis

unread,
Oct 19, 2006, 9:41:34 AM10/19/06
to
ohh yeh...
i am new in this area of spool file and dealing with printers...but i
remember one of my co-worker redirected the output to a file instead of
printer.....n it again bounced my head off...but luckily as of now i
dun have to deal with it...but i m sure i wil have to come accross it
some day!

Thanks,
Nisarg.

mrd.chak...@gmail.com

unread,
Jan 2, 2020, 2:41:40 AM1/2/20
to
Can u please send the code ? with PrintParam list

Frederick P.

unread,
Apr 22, 2020, 4:11:51 PM4/22/20
to
I don't have access to an iSeries at the moment, but you can use CPYSPLF I believe. It's something like
CPYSPLF OUTPUT(*FILE) OUTFILE(*LIBL/MYSPLF)
There are someother parameters like "Create File/Member", so if you're going to write and CLP or a CMD, keep that in mind.

Thanks
0 new messages