Hallo Christian,
vielleicht hilft Dir dies schon weiter:
How to Check Whether a User Is Signed On
by Scott Klement
Club Tech iSeries Programming Tips Editor

October 09, 2005 — *
Q: To report an error condition, I'd like to write a program that sends a user a message. If the user is signed on, I'd like to send a message to that user's message queue. If the user isn't signed on, I'd rather send an e-mail to the user's pager. How can I tell whether the user is signed on?
A: To determine whether a user is signed on, use the List Signed-On Users (QEZLSGNU) API. This API lists the terminals that a user is signed on to, and it excludes batch jobs. If the user is signed on to no terminals, you know to use e-mail. If some terminals are listed, you can send to the user's message queue instead.
To demonstrate this method, I've written a command called Check User (CHKUSR). This command is intended to be called from a CL program to see whether a user is online. The source for the command object follows:
CMD PROMPT('Check whether user is online')

PARM KWD(USERID) TYPE(*NAME) LEN(10) MIN(1) +
PROMPT('User ID to check')

PARM KWD(ONLINE) TYPE(*CHAR) LEN(4) RTNVAL(*YES) +
PROMPT('CL var for user is online') MIN(1)
This command accepts two parameters. The first one is the user ID that you'd like to check for. The second parameter is returned from the utility and is set to *YES if the user is online and *NO if the user is not online.
You can use this utility from your CL program as follows:
PGM

DCL VAR(&ONLINE) TYPE(*CHAR) LEN(4)

CHKUSR USERID(BOBK) ONLINE(&ONLINE)

IF (&ONLINE *EQ '*YES') DO
SNDMSG MSG('Hey, you! We have a problem!') TOUSR(BOBK)
ENDDO
ELSE DO
SNDDST TYPE(*LMSG) +
TOINTNET((bobspager@example.com)) +
DSTD('Problem') +
LONGMSG('Hey, you! We have a problem!') +
SUBJECT('Help! Help!')
ENDDO

ENDPGM
To make the CHKUSR command work, I need to write a command processing program (CPP) that can look up the user and report whether he or she is online. This CPP is called CHKUSRR4 and is written in ILE RPG. Here's the code for the CHKUSRR4 program:
D CHKUSRR4 PR Extpgm('CHKUSRR4')
D UserID 10A const
D Online 4A
D CHKUSRR4 PI
D UserID 10A const
D Online 4A

D QUSCRTUS PR ExtPgm('QUSCRTUS')
D usrSpc 20A CONST
D extAttr 10A CONST
D initSize 10I 0 CONST
D initValue 1A CONST
D publicAuth 10A CONST
D text 50A CONST
D replace 10A CONST
D error 32767A options(*varsize)

D QEZLSGNU pr extPgm('QEZLSGNU')
D usrSpc 20A const
D format 8A const
D user 10A const
D display 10A const
D incDiscon 10A const
D incSignOff 10A const
D errorCode 32767A options(*varsize)

D QUSPTRUS pr extPgm('QUSPTRUS')
D usrSpc 20A const
D pointer *

D dsListInfo ds based(p_ListInfo)
D offset 10I 0 overlay(dsListInfo:125)
D entry_count 10I 0 overlay(dsListInfo:133)
D entry_size 10I 0 overlay(dsListInfo:137)

D ErrorCode ds
D bytesProv 10i 0 inz(0)
D bytesAvail 10i 0 inz(0)
D msgid 7A

D UsrSpc c 'CHKUSER QTEMP'

/free

QUSCRTUS( UsrSpc
: 'QEZLSGNU'
: 1024 * 32
: x'00'
: '*ALL'
: *blanks
: '*YES'
: ErrorCode );

QEZLSGNU( UsrSpc
: 'SGNU0100'
: UserID
: '*ALL'
: '*NO'
: '*NO'
: ErrorCode );

QUSPTRUS( UsrSpc: p_ListInfo);

if (entry_count > 0);
Online = '*YES';
else;
Online = '*NO';
endif;

*inlr = *on;
/end-free
This program starts by creating a user space with the Create User Space (QUSCRTUS) API. The user space is needed because that's where the QEZLSGNU API writes its output.
The QEZLSGNU API is then used to load the list of signed-on users into the user space. In the third parameter, I tell the API which user should be listed. I can also specify which display stations are included, whether disconnected jobs should be included in the list, and whether signed-off users that have spooled files should be included in the list.
In this situation, I don't care whether the user has spooled files, and I'm not interested in disconnected jobs. I do want to know any place that the user is signed on from, so I specify *ALL for the workstation, *NO for the "include disconnected jobs" parameter, and *NO for the "include signed-off users with spooled files" parameter.
The QUSPTRUS API is used to get a pointer to the user space so that I can see what's in it. I overlay the start of the user space with the dsListInfo data structure and check to see whether there are any workstations that the user is signed on to.
If there are any, I return *YES; otherwise, I return *NO.
To compile this utility, run the following commands:
CRTBNDRPG PGM(CHKUSRR4) SRCFILE(my-lib/QRPGLESRC)

CRTCMD CMD(CHKUSR) PGM(CHKUSRR4) SRCFILE(my-lib/QCMDSRC) +
ALLOW(*IPGM *BPGM)
You can learn about the QEZLSGNU API at the following link:
http://publib.boulder.ibm.com/infoce...s/QEZLSGNU.htm