You are on page 1of 2

AS400 Automatically Logging Off Inactive Workstations

http://www.itjungle.com/mgo/mgo052303-story01.html

Hey, Shannon:

My users keep forgetting to log off of their AS/400 sessions at the end of the day before they
go home. Is there any way we can programmatically address this problem? Perhaps a
technique that will automatically log off a user?

--Ted

You are in luck, Ted. I just happen to have a great solution for logging off inactive
workstations!

You must code your DDS with the INVITE keyword. INVITE allows your RPG IV
program to "invite," or allow, input from devices other than the keyboard. In this case, we'll
be sending input to the device from the RPG program without pressing a key on the
keyboard, if the session goes beyond the allowable time. Code the INVITE keyword at the
file level of your display file. Use the following code as a guide.

A***************************************************
A*
A* CRTDSPF FILE(XXX/DSP00D1) SRCFILE(XXX/QDDSSRC) +
A* MBR(DSP00D1) WAITRCD(20)
A*
A***************************************************
A DSPSIZ(24 80 *DS3)
A CA01(01 'HELP')
A CA03(03 'EXIT')
A INVITE
A R SCREEN1
A 1 19'Test Waitrcd Paramter To Timeout D-
A isplay'
A DSPATR(HI)
A DSPATR(UL)
A 9 28'Input:'
A INPUT 1A B 9 35
A 22 7'F3=Exit'
A COLOR(BLU)

When you create the display file, prompt the Create Display File (CRTDSPF) command
and press F9 to display all of the parameters. Look for the WAITRCD (Wait Record)
parameter. This parameter, when used in combination with the INVITE keyword, specifies
how long the display file should wait before checking for a keyboard response. Enter a
value of 20 here, for 20 seconds for testing. In your real-world application, you'll want to
make this value a reasonable time limit, say 30 minutes. Create the display file.

In the RPG IV program, specify the number of devices for this display file by coding the
MAXDEV parameter on the F-spec. In addition, we need to access the display file's
Information File Data Structure (INFDS), so let's code this as well on the F-spec. Given a
display file name of DSP00D1, your F-spec in your RPG program will look similar to the
following:

FDsp00d1 CF E Workstn Infds(Infds)


F Maxdev(*File)

Next, you'll need to code the INFDS data structure on your D-spec, as follows:

D Infds DS
D Status *Status

And, finally, code a simple loop that will be terminated by the user pressing F3 on the
keyboard. Note, in the following code, that rather than using the traditional EXFMT op
code, we are instead using the WRITE and READ op codes on the display format. We do
this because we are using the INVITE keyword in the DDS. When you use INVITE, you
must use WRITE and READ for the process to read "other than keyboard" input. In this
case, if there was no activity for 20 seconds--the value we placed in the WAITRCD
parameter of the CRTDSPF command--then when the RPG program gets to the READ
statement, it will "read" that value from the display file and detect that there was no user
input. (The INFDS *STATUS will contain a value of 1331 and time-out the display.)

C Dow *IN03 = *Off


C Write Screen1
C Read Dsp00d1 99LR
C If *In99 = *On And Status = 1331
C Eval *IN03 = *On
C Endif
C If *In01 = *On
C Call 'HELP'
C Parm 'SCREEN1' Screen 10
C Parm 9 crow 15 5
C Parm 35 ccol 15 5
C Parm return 2
C Endif
C Enddo
C Eval *Inlr = *On

--Shannon O'Donnell

You might also like