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

Get UserID

531 views
Skip to first unread message

Robert Meier

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

Hi All,

I'm running Cobol/400 on an IBM AS/400. I need to get the current user-id
into the program, by either calling the program with a certain system
parameter or use Cobol code to get it in the program.

You know the syntax:
accept ws2-date from date

That will put the current system date into the variable ws2-date. But how
do I get the user id to be passed the same way? Or should I get it from
the system before I call the program and pass it as a parameter to the
program?

Please help.

Thank you.

Robert Meier
dpr...@mhs7.tns.co.za

Perka

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

Hi Robert!

I don't know the Cobol stuff, but I assume there is the same possibility to
access the program status data structure as within RPG, since it's copied
from data management. The current USERID is availible through this
structure. (Within RPG it's in position 254-263.)

Regards

Perka

Robert Meier <dpr...@mhs7.tns.co.za> skrev i inlägg
<01bd62b2$184333c0$9d4cc5a3@dprmrmei>...

Robert Meier

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

Hi Perka,

Wow, that confused me. What structure are you talking about?

As you say, if it's available to RPG it should be available to Cobol. How
do you access the data structure from within RPG?

Thanks
Robert

Perka <perka_st...@hotmail.com> wrote in article
<01bd62bb$afeb9420$6e9dedc2@pcperka>...

Paul Nicolay

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

Hi Robert,

The datastructure is called the System Data Structure and declared in
ILE-RPG as follows;

Iname SDS
I field x y

For contents and positions, take a look at the "Data Management Manual"
(http://as400bks.rochester.ibm.com/cgi-bin/bookmgr/bookmgr.cmd/BOOKS/QBJAUG0
0/CCONTENTS) Maybe it also explains how to access it in COBOL. In case it
doesn't work, you can also write a small CL that does a RTVJOBA and returns
the user as parameter.

Regards,
Paul
_______________
Robert Meier <dpr...@mhs7.tns.co.za> wrote in article
<01bd62e9$0250e580$9d4cc5a3@dprmrmei>...


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

Mike Cravitz

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

Robert,

You are receiving a lot of wrong information. The fault is not that of
the responders. The problem is only about 15% of the AS/400 community
is Cobol. The people that have responded so far are pretty much in the
other 85% (mostly RPG). The fact is there is no equivalent to the PSDS
from RPG in Cobol. Neither is there any native Cobol instruction that
will retrieve the user. I will post a solution here, but first....

Let me encourage you and all other Cobol people to visit us at
NEWS/400's Cobol Community
(http://www.news400.com/redir/redir.cfm?story=/cobol/index.htm). We
have probably the largest concentration of AS/400 participation on our
forum. A regular visitor to the forum is IBM Cobol developer Chris
Tandy. I notice he doesn't hang out here and neither do any of the
other IBM Cobol developers. Unfortunately the Cobol Community is
accessed with a browser not a USENET reader. It is funded through
advertisements and you don't have the ability to work with it the same
way you can with a nice News Group reader like Agent. But if it's
AS/400 Cobol you're interested in, we've got it there. I am the SYSOP
and will try to either answer your questions or get an answer from
somewhere.

Below is a Cobol subroutine I wrote which retrieves the job name, user
and job number into a 26 byte parameter passed. You invoke the routine
with the following...

Call "RTVJOBI" Using Any26ByteParameter.

=====Start of RTVJOBI subroutine====

Identification Division.
Program-Id. GETJOBI.
Data Division.
Working-Storage Section.
01 Rcvr.
02 Filler Pic X(04).
02 Filler Pic S9(09) Binary Value 34.
02 RcvrJobInf Pic X(26).
01 RcvrLen Pic S9(09) Binary Value 34.
01 FmtName Pic X(08) Value "JOBI0100".
01 QlJobName Pic X(26) Value "*".
01 IntJobId Pic X(16) Value Spaces.
Linkage Section.
01 JobInf.
02 JiJobName Pic X(10).
02 JiUserName Pic X(10).
02 JiJobNum Pic X(06).
Procedure Division Using JobInf.
GetJobiMain.
Call "QUSRJOBI"
Using Rcvr
RcvrLen
FmtName
QlJobName
IntJobId.
Move RcvrJobInf to JobInf
GoBack.
=====End of RTVJOBI subroutine====

Mike Cravitz

NEWS/400 Technical Editor

Richard Knechtel

unread,
Apr 9, 1998, 3:00:00 AM4/9/98
to

Robert Meier wrote:
>
> Hi Perka,
>
> Wow, that confused me. What structure are you talking about?
>
> As you say, if it's available to RPG it should be available to Cobol. How
> do you access the data structure from within RPG?
>
> Thanks
> Robert
>
> Perka <perka_st...@hotmail.com> wrote in article
> <01bd62bb$afeb9420$6e9dedc2@pcperka>...
> > Hi Robert!
> >
> > I don't know the Cobol stuff, but I assume there is the same possibility
> to
> > access the program status data structure as within RPG, since it's copied
> > from data management. The current USERID is availible through this
> > structure. (Within RPG it's in position 254-263.)
> >
> > Regards
> >
> > Perka

I don't know if this is what your looking for but here is a sample of
some code I used. (it doesn't get the user ID, But I am sure you can
find the field position to add to this.)
(I am by NO MEANS an expert COBOL programmer, I am still learning, but I
felt that since I got help here before I would give some back. Hopefully
I gave the right info.)(Sorry if I didn't).

--------cut here------------------------------

01 WS-I-O-FEEDBACK.
03 WS-COMMON-I-O-FEEDBACK-AREA.
05 WS-DEVICE-DEPENDENT-AREA PIC 9(4) COMP-4.
05 WS-DEVICE-DEPENDENT-OFFSET PIC 9(8) COMP-4.
05 WS-PUT-OPERATION-COUNT PIC 9(8) COMP-4.
05 WS-GET-OPERATION-COUNT PIC 9(8) COMP-4.
05 WS-WS-OTHER-IO-COUNT PIC 9(8) COMP-4.
05 FILLER PIC X(1).
05 WS-CURRENT-OPERATION PIC X(1).
05 PASSED-FORMATNAME PIC X(10).
05 WS-DEVICE-CLASS PIC X(2).
05 WS-PROGRAM-DEVICE-NAME PIC X(10).
05 WS-RECORD-LENGTH PIC 9(8) COMP-4.
05 WS-ROUTING-DATA PIC X(80).
05 WS-NUMBER-OF-RECORDS-RETRIEVED PIC 9(4) COMP-4.
05 FILLER PIC X(4).
05 WS-CURRENT-BLOCK-COUNT PIC 9(8) COMP-4.
05 FILLER PIC X(8).
03 WS-SCREEN-I-O-FEEDBACK-AREA.
05 WS-BIT-FLAG PIC X(2).
05 WS-AID PIC X(1).
05 PASSED-CURSOR PIC X(2).
05 PASSED-CUR-POS REDEFINES PASSED-CURSOR PIC 9(4) COMP-4.
05 PASSED-ACTUAL-DATA-LENGTH PIC 9(8) COMP-4.
05 WS-REL-RECORD-NUMBER PIC 9(4) COMP-4.
05 WS-LOWEST-SUBFILE-REL-REC-NUM PIC 9(4) COMP-4.
05 WS-NUM-REC-IN-SUBFILE PIC 9(4) COMP-4.
05 WS-MAJOR-RETURN-CODES PIC X(2).
05 WS-MINOR-RETURN-CODES PIC X(2).
05 WS-NEGATVE-RESPONSE-CODE PIC X(8).
05 WS-SAFE-INDICATOR PIC X(1).
05 WS-SHUT-DOWN-REQUEST PIC X(1).
05 WS-WRITE-REQUEST PIC X(1).
05 WS-MAP-NAME PIC X(10).
05 WS-REQUEST-RESPONCE PIC X(4).
05 WS-MODE-NAME PIC X(8).
05 FILLER PIC X(9).

--

Richard Knechtel
EDS
(Systems Engineer/System Administrator)
(Aspiring AS/400 GURU)
(Aspiring Linux GURU)
(Aspiring VB Programmer)

The contents of this message express only MY opinion.


This message does not necessarily reflect the policy or views of

my employer, EDS. All responsibility for the statements
made in this posting resides solely and completely with the
ME.
I Ex-Spaminate spammers!
See US Code Title 47, Sec.227(a)(2)(B), Sec.227(b)(1)(C)
and Sec.227(b)(3)(C).

Charles R. Pence

unread,
Apr 9, 1998, 3:00:00 AM4/9/98
to

Mike, your code example does not give the Current User... for which a
special note of the fact is worthwile; not to imply there is a problem
with that given.

Regards, Chuck
-- Comments provided "as is" with no warranties of any kind whatsoever.

Robert Meier

unread,
Apr 9, 1998, 3:00:00 AM4/9/98
to

Hi Mike,

Thanks very much for your info and help.

Your site looks very good and I'll definitely know where to look for
Cobol/400 help in future.

Thanks again
Robert

tho...@inorbit.com

unread,
Apr 9, 1998, 3:00:00 AM4/9/98
to

Mike:

Although this code does return 'job user', there'll be some small fraction of
times when 'job user' will not be the same as the 'current user'. If a higher
level of certainty is required, 'current user' can be found at decimal
offset(91) of format JOBI0600. (That is, positions 92-101 of format JOBI0600
contain CurrentUser.) For most purposes, though, the code you supplied should
be plenty good enough.

Tom Liotta

In article <352c97e5...@www.newslink400.com>,


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading

Miroslav Vacula

unread,
Apr 9, 1998, 3:00:00 AM4/9/98
to Robert Meier

Robert,

I mean simple way to get user-id is writing a small CL program e.g.

MYPGM: PGM PARM(&USERID)
DCL &USERID TYPE(&CHAR) LEN(10)
RTVJOBA USER(&USERID)
ENDPGM

and in COBOL program e.g.
....
....
01 CURRENT-USER-ID PIC X(10).
....
....
CALL "MYPGM" USING
CURRENT-USER-ID.

Of course, you can use another ways to get current user-id but I guess the
method described above is most simple.

Good luck

Miroslav Vacula
mva...@minolta.cz

Mike Cravitz

unread,
Apr 11, 1998, 3:00:00 AM4/11/98
to

Thanks for pointing this out. Forgot the job user can be different
from the actual user.

Bradley V. Stone

unread,
Apr 11, 1998, 3:00:00 AM4/11/98
to

mcra...@worldnet.att.net (Mike Cravitz) wrote:

>Robert,

-snip-

>Mike Cravitz

>NEWS/400 Technical Editor

Why not just call a CL that returns the user name? Only a 4 liner
compared to all the lines in your COBOL program.

Bradley V. Stone
http://prairie.lakes.com/~bvstone
"Robble robble!" - The Hamburgler


Joris.M...@village.uunet.be

unread,
Apr 16, 1998, 3:00:00 AM4/16/98
to

If you Cobol/400 program does have a so-called Transaction File (Workstation
file in RPG) (i.e. if it's suppsoed to interact with a user), you can code in
the SPECIAL-NAMES Section a mnemonic name for te ATTRIBUTE-DATA special name.

In the procedure division you can then accept the ATTRIBUTE-DATA into data
structure declared in working-storage. Such a data strucuture could be
someting like this

01 Attribute-fields.
03 program-device-name Pic X(10).
03 device-description-name Pic X(10).
03 device-user-id Pic X(100.

The third field will give you the User profile running this program.

For programs NOT having a Display file, it's best indeed to use the "QUSRJOBI"
API.

Cheers,

Joris Moorkens

0 new messages