6

With the ILE compiler, in RPG, you can use the PSDS to get information about the current user, job name etc..

How do you get the same information in a C++ program, using ILE?

John Y
  • 14,123
  • 2
  • 48
  • 72
Arsnow
  • 161
  • 1
  • 13
  • 4
    Why the close votes for "unclear what you're asking"? It's a very clear question, if you are at all familiar with the IBM midrange. Please refrain from voting on questions you know nothing about. – John Y Oct 13 '14 at 16:04
  • @JohnY Why the negative comment, and not an attempt to clarify what's being asked or a suggested edit? The majority of people who see this because of the C++ and not because of ibm-midrange would have had to google things to make any sense of the question. I've attempted an edit, but as I'm not familiar with IBM Midrange, I'm sure you could do better. – James Oct 13 '14 at 19:43
  • @James: I understand your point, and I could have been less negative. (I could have been more negative, too.) I didn't edit because I truly felt it didn't need it. Folks who would need any explanation at all would need to research the whole question from scratch. They wouldn't know what ILE is, what RPG is, what IBM midrange is, what PSDS is. They don't need clarification. They need a tutorial. On the other hand, if you *don't* need a tutorial, then you don't need clarification either, because the OP phrased things in a very clear way, even including examples of what's in the PSDS. – John Y Oct 13 '14 at 19:58
  • As Scott answered, there's no single PSDS equivalent in ILE C++. If you be more specific in the info you want, we can point you to the right combination of APIs. – Charles Oct 13 '14 at 21:12
  • I'm interested in job number, current user, and program library, but i asked for a general question cause i guess i'll need other kind of information in the future. – Arsnow Oct 14 '14 at 16:58

4 Answers4

5

The QUSRJOBI api will get you the info you mentioned. The returned struct jobInfo is defined in header QUSRJOBI.h (QSYSINC.H file) and will return the current job name/user name and job number plus more if called like this:

Qwc_JOBI0600_t jobInfo;
QUSRJOBI(&jobInfo, sizeof(Qwc_JOBI0600_t), "JOBI0600 ", "* ", " ", &errCode);

4

There is no direct equivalent to RPG's PSDS in C++.

(For those who are not aware, in the RPG programming language, you can declare a data structure called the "Program Status Data Structure" and it'll be automatically filled in with lots of information about the runtime environment, including the job identifier (like a process id), user name, last error that occurred, and lots of other information.)

If you can tell us specifically which information you're looking for, and what platform you need it on (or whether you need it to be cross-platform) then perhaps we can help.

  • I can't imagine the OP expecting to use this on any but the IBM i. But with specifics of what PSDS info he wants, we could better direct him to the right API(s). – Charles Oct 13 '14 at 21:10
3

To add to Scott's reply, a data structure in RPG is like a struct in C++ - it would be possible to construct a struct that would contain that data, and one could probably populate some of it with various calls to system APIs. Some things, however, are just not readily available.

2

You can get the program name and program library from the first parameter passed to a C or C++ program. argv[0] is a string in the form "MYLIB/MYPGM".

If you ever need the module name, probably the easiest way would be to send yourself a message using QMHSNDPM and then receive it using QMHRCVPM with format RCVM0300 which has "sender information"; the sender information has the sending module name and receiving module name. You could also get the program name and library this way.

Barbara Morris
  • 3,195
  • 8
  • 10