× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Scott,

Well, let's clarify things a bit before we get into absolutes shall we? Here is my comment reworded for clarity.

You can use the QUSRJOBI API to retrieve a job's current user. The API will ALWAYS return the current user.
If you perform a profile swap from within your RPG program to do some stuff and expect the current user
to reflect your swapped to profile you will be disappointed. The swap will not be reflected in the program
status data structure. It will be reflected in the job's information.

Now, as far as your example goes you are correct. The swapped to profile name will show up in RPG400PGM's PSDS. This occurs because you performed the switch BEFORE invoking RPG400PGM. The current user in the PSDS is set when the program starts.

RTVJOBA CURUSER(&CURUSER) from within your example after the swap will also return the profile you switched to. This is because the command uses the QUSRJOBI API.

Try rewriting your CL example program in any flavor of RPG you desire adding a dump statement before the call to RPG400PGM. You will see what I mean. In your rewritten program the swapped to profile will not be reflected in its PSDS. It will be reflected in RPG400PGM just like it was when called from your CL program.

At least at V5R4 this is true.

Gary Monnier



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Wednesday, June 20, 2012 9:47 AM
To: RPG programming on the IBM i / System i
Subject: Re: user profile

Hi Gary,

You can use the QUSRJOBI API. If you perform a profile swap it will
not be reflected in the program status data structure. It will be
reflected in the job's information.


Sorry, this simply isn't true.

I find it odd that you'd say something like this after such luminaries as Barbara Morris have already pointed out that RPG/400 will show the current user profile in positions 254-263, and that others (including
Barbara) have pointed out that in ILE RPG, it's in positions 358-367.

So in either version of RPG, you can get the current user profile from the PSDS, even in a swapped profile environment!

Here's something you can try... this is a simple CL program that swaps profiles, calls an RPG program, and then swaps back:

PGM
DCL VAR(&ORIGHANDLE) TYPE(*CHAR) LEN(12)
DCL VAR(&HANDLE) TYPE(*CHAR) LEN(12)

/* SAVE ORIGINAL HANDLE AND SWITCH TO QUSER */

CALL PGM(QSYGETPH) PARM(*CURRENT *NOPWDCHK &ORIGHANDLE)
CALL PGM(QSYGETPH) PARM(QUSER *NOPWDCHK &HANDLE)
CALL PGM(QWTSETP) PARM(&HANDLE)

/* CALL RPG/400 PROGRAM */

CALL RPG400PGM

/* SWITCH BACK AND FREE UP THE HANDLES */

CALL PGM(QWTSETP) PARM(&ORIGHANDLE)
CALL PGM(QSYRLSPH) PARM(&ORIGHANDLE)
CALL PGM(QSYRLSPH) PARM(&HANDLE)

ENDPGM


The OP was asking about RPG/400 (OPM) rather than today's RPG. Barbara said that positions 254-263 would work. So let's try it. Here's a trivial program that displays those positions of the PSDS, put this program in place of the "CALL RPG400PGM", above:

I SDS
I 254 263 USERID
C USERID DSPLY
C MOVE *ON *INLR

Again, this is an OPM (RPG/400) program. Make sure you use source type RPG and compile it with CRTRPGPGM.

Call it (using the CL program, above) and you get this:

DSPLY QUSER

So it's showing me the swapped-to user profile. Right?

Let's try it with ILE RPG:

d SDS
d ORIGUSER 254 263
d CURUSER 358 367
/free

dsply ('Orig=' + OrigUser + ' '
+'Curr=' + CurUser );
*inlr = *on;

Change the CL program, above, to call this ILE RPG program instead of
the OPM one. Then re-run it, and you'll get this (with your user
profile in place of mine)

DSPLY Orig=KLEMSCOT Curr=QUSER

So, clearly, you can get the current user profile from the PSDS, even with profile swapping, in either language.

Having said that... When coding in ILE RPG, I much prefer INZ(*USER) on the D-spec. It's just a lot easier to read and more intuitive than PSDS. But, PSDS _does_ work...
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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

This mailing list archive is Copyright 1997-2024 by midrange.com 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.