defineProc for getenv

Use this board to ask questions or have discussions with other Profound.js users.
jleander
New User
Posts: 6
Joined: Tue Apr 05, 2016 3:19 pm
First Name: James
Last Name: Leander
Company Name: Victaulic
Contact:

defineProc for getenv

Post by jleander »

Has anyone done a pjs.defineProc for service program QSYS/QP0ZCPA procedure getenv? I could get around this with a RPG service program to wrap it, but I was curious if there was a cleaner way to just do within the Profound JS framework. As simple as the prototype is in RPG, the pointers with the *string without a true length definition are giving me difficulty to try to define it without causing errors when I actually try to call it.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: defineProc for getenv

Post by Scott Klement »

Node.js has built-in support for environment variables. Can you use that?
https://nodejs.org/api/process.html#process_process_env

I would only consider calling an API like this if the built-in Node support didn't work for some reason.
jleander
New User
Posts: 6
Joined: Tue Apr 05, 2016 3:19 pm
First Name: James
Last Name: Leander
Company Name: Victaulic
Contact:

Re: defineProc for getenv

Post by jleander »

Hi Scott, I was trying to truly get the IBM i job level environmental variables, unfortunately the process.env object doesn't include those. We run 3 PUI servers with 3 associated PJS servers (DEV/UAT/PROD), so those variables (PROFOUNDJS_COMM_HOST and PROFOUNDJS_COMM_PORT) are set at the job level and I planned on using them to get the correct host:port to call from Rich display jobs to the corresponding PJS server's webservice without creating additional objects/data areas on our side.

In this specific use case, I have a Rich display PUI job calling a PJS module that would then be calling out to a PJS webservice, so I was trying to get the correct port within the PJS module. So for example if the PUI job is running on "server:8081" I'd want to be able to get to "server:8091/servicename".

Nothing I can't work around, and an RPG service procedure wrapper probably makes more sense as I will likely need the same information in RPG-driven rich displays as well, this was more curiosity than anything. Seemed like a nice complex example for the forums for people to reference!
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: defineProc for getenv

Post by Scott Klement »

That is, indeed, what process.env returns -- the job-level environment variables. (System-level variables are an IBM specific thing, so you typically won't find routines for system-level variables outside of IBM APIs. But job-level is available on almost all operating systems out there, Windows, Unix, MacOS, etc.)

However, it's very possible that the variables you want to retrieve are in a different job from the one where your Node.js code runs. In that case, you'd need to do something that makes a call to a program in that other job (such as an ILE procedure call).

Sounds like you're on the right track, here.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests