× 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 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...

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.