Dear Luis,

I was cleaning up some of my older e-mail recently and I read the thread
about your RPG bus ticket program. I think I know why it was coded to
require an end and a starting of the writer between the generation of every
bus ticket and what to change in the configuration of lp5250d to make it
compatible with the RPG program. Information for your reference is appended


The OS/400 print spooling subsystem sends all of the report formatting
information to a printer with the first job that is printed after the writer
is started. If the next print job in the queue uses the same exact format as
the previous job, the OS/400 operating system sends just the report text
with no formatting commands at all because it thinks the target system
printer is only attached to the IBM Server and therefore has already stored
the correct format within itself. For each following job, it will only send
report formatting commands for a new feature being enabled/disabled as
compared to the currently active format that it believes is being stored at
the printer. This information pertains to system printers receiving data in
an EBCDIC format and does not pertain to the ASCII format that will be
delivered to a printer serviced by an OS/400 device description with Host
Print Transform enabled.

The problem for an RPG application developer, who needs to send a very
special format to the printer and guarantee that this format will be active
in the printer when their data is received, is to determine how to best
prompt the OS/400 spooling system to always send the necessary print
formatting information with each spool file. The reason you need to send
this print formatting information ahead of each spool file is that many
printers receiving IBM AS/400 and iSeries print information are now attached
to networks where they receive print jobs from many hosts.

One simple way of insuring that the proper printer formatting commands are
sent ahead of each spool file is to end and then start the writer between
the printing of each group of bus tickets.

TN5250E Printers - How Are They Different Than Other IBM Host System

As originally architected, the OS/400 operating system usually controlled
the starting and stopping of all printers. Over the years, it has been
enhanced to support certain types of print clients that actually start and
end the writers themselves.

The TN5250E protocol is a reverse telnet protocol. This means that the
client is responsible for initiating a connection with an IBM host server.
The OS/400 device management process for TN5250E clients is controlled by
system value QAUTOVRT. This feature typically needs to be enabled to allow
the IBM host to build a display or printer device description automatically
when a request from a TN5250E client to begin a communication is received by
an IBM host server.

In the case of the TN5250E project, the OS/400 printer device description
will become active on the AS/400 or iSeries host when the lp5250d process is
started. When you start the lp5250d process it passes a set of configuration
variables, which you have provided, to the target IBM AS/400 or iSeries
host. The target host receives the query to start a print session on its
telnet port (usually TCP port 23) and uses the parameters received from
lp5250d to build an OS/400 printer instance. The device created uses the
virtual device type (*VRT) and will frequently be applied to the default
OS/400 system controller for virtual devices. The device will be
automatically varied on and the writer started as part of the initial
connection process.

The IBM host also expects the communication to be terminated by the client
that originally opened the communication. In the case of lp5250d, this means
the IBM host expects the printer session to be ended by the stopping of
lp5250d and not by the ending of the writer on the IBM host side of the

Because TCP/IP communications can be effected by network problems, all
TN5250E client programs include an automatic reconnection timer. If a client
is running and it loses its connection to an IBM host, it will try to
reconnect to that host to re-establish the communication in some number of
seconds. If you take action to stop the print writer on the IBM host and you
leave lp5250d running, the lp5250d process will believe the OS/400 writer
ending is a sign of a connection problem and it will activate its
reconnection timer. In the past, I have found that if you end the writer and
then also execute the WRKCFGSTS command to vary the device off as well, the
lp5250d re-connect timer will expire causing the device to be varied on and
the writer started just about when your request to vary the device off has
finished executing. The result of varying a printing device off and then
watching it magically vary itself back on and start its print writer with no
operator intervention on the IBM host at all usually confuses people new to
working with TN5250E protocol supported printing devices until someone tells
them how they work.

The Solution

Change the default reconnect timer for the lp5250d process to a value
greater than the amount of time needed for the RPG program to end and start
the writer on your host and everything should work fine.


Best Regards,

Paul Tykodi
National Product Manager
Intermate US Inc.

p: 603-431-0606 x115
f: 603-436-6432

>The problem is that the software in RPG (bus ticket) does this operation
>(END / START writer)  other applications from printing to it, it's really
>a stupid operation but the vendors of the software said that they can not
>change that.
>Every printing is working fine, the only program that don't work is that
>one that prints the bus ticket, using that stupid end/start writer
>The same operation is working using client access.
>Luis Otavio Da Ros Ribas
>>To try to understand your predicament, I did the following:
>>    1) Started up lp5250d on my FreeBSD 4.6-RELEASE system.
>>     2) Logged on to the AS/400
>>     3) Ended the print writer with: ENDWTR PRT01 *IMMED
>>     3) Re-started the print writer with: STRPRTWTR PRT01
>>     4) Sent a report to the printer.
>>     5) The report printed correctly.
>>You say "Aparently AS/400 x lp5250d can't do Start / End Writer
>> correctly." Why do you say that? From my test, above, it appears
>> to work correctly. What are you expecting it to do differently?
>>Do you have the same problem when you print from FreeBSD directly? Or
>> only when you use lp5250d?
>>What's the reason for stopping & starting the writer in the first place?
>> I've never heard of someone doing this. Are you trying to prevent other
>> applications from printing to it?
>>In addition to using lp5250d, you could also consider using the normal
>> FreeBSD lpd to receive spooled files from your AS/400. It doesn't have
>> as many options as lp5250d does, but it might be one way to avoid using
>> Windows.
>>On Tue, 20 Aug 2002 wrote:
>> >
>> > I am using FreeBSD with a minimal install for use only as terminals to
>> > our AS/400. I have installed TN5250 and it works great, but I'm having
>> > some problems with the lp5250d server.
>> >
>> > We use a system to sell bus tickets that need to have the writer
>> > "ended" to work. The printing operations works like that: Start writer
>> > send report / End writer.
>> > Aparently AS/400 x lp5250d can't do Start / End Writer correctly. This
>> > the only report that can not be printed... (Probably because this
>> > operation)...
>> >
>> > Any sugestion ? I just can not get used to the idea of using M$ Windows
>> > / Client Access again... :-)
>> >
>> > Thanks in advance for the help.
>> >
>> > Luis Otavio Da Ros Ribas
>> > IT Manager
>> > Sulamericana Transportes Ltda
>> > Curitiba - Parana - Brazil
>> >

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.