Running jobs on a remote system

We need to initiate a job on one iSeries and execute it on another iSeries. We are trying to use SBMRMTCMD but have a few issues with it. The user id does not carry from system to system. The job on the target system runs as QUSER. We can't figure out how to pass variables as parms. Everything we try crashes. Has anyone found a way around these issues or used something other than SBMRMTCMD? We looked at using RUNRMTCMD but don't want to be passing passwords. Any help or direction would be appreciated.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I can’t help with the SBMRMTCMD problem (we don’t use it). But here’s how you would pass variable parameters (i just threw this together so, hopefully there are no typos).

dcl &cCmd1 *char 2000
dcl &cCmd2 *char 2000
dcl &cParm1 *char 50
dcl &cParm2 *char 15
dcl &nParm2 *dec (15 5)

chgvar &cParm1 ‘a character string’
chgvar &nParm2 100
chgvar &cParm2 &nParm2

/* if the remote pgm expects parm2 to be character +
and will translate it to decimal, do this: */

chgvar &cCmd1 (‘call pgm(RmtLib/RmtPgm1) +
parm(”’ || &cParm1 || ”’ +
”’ || &cParm2 || ”’)’)

/* if the remote pgm expects parm2 to be numeric +
do this: */

chgvar &cCmd1 (‘call pgm(RmtLib/RmtPgm2) +
parm(”’ || &cParm1 || ”’ +
|> &cParm2 || ‘)’)

sbmrmtcmd cmd(&cCmd) ddmf(LclDDMF)


&cCmd1 will translate to :
“call pgm(RmtLib/RmtPgm) parm(‘a character string’ ‘0000000100.00000’)”

&cCmd2 will translate to :
“call pgm(RmtLib/RmtPgm) parm(‘a character string’ 0000000100.00000)”

The most important things to remember are what is the called program expecting and then matching up the quotes. Every place you need a literal single quote, you have to type 2 of them, then surround the string with single quotes, then concatenate all the parts into one string:

‘call pgm(RmtLib/RmtPgm1) parm(”’
|| &cParm1
|| ”’ ”’
|| &cParm2
|| ”’)’

Some people find it easier to define a variable that contains a single quote…

dcl &Q *char 1 value(””)

…and then concatenate that into the sting. I find that to muddle things and prefer to use free formatting to make it clear, but that’s just personal style preference (like using ||, |>, |< instead of *CAT, *BCAT, *TCAT). Use whatever make the code readable.

Also remember that if the called program is expecting an numeric parameter, you DON’T want to surround that in quotes.

Hope this helps!

Discuss This Question: 4  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • MilesButler
    Hi Yep - always a problem getting the correct user Id / authority on the target system. You could try your target job, with all authority, submitting another job owned by the correct user id etc. As an alternative solution: SBMNETJOB Miles
    0 pointsBadges:
  • RussK1
    My notes on SBMRMTCMD are as follows: A DDM-related cmd to run a command (or call a CL pgm) on a remote system. SBMRMTCMD CMD('call pgm') DDMFILE(library/filename) CMD: Actual command or pgm call to execute on the remote system. DDMFILE: reference to a DDMF to tell it which system to run the cmd on - actual file not used. So to pass parms - you should be able to construct a variable w/the desired cmd and parms and use as the CMD parameter. As far as QUSER goes, it never was an issue when I've used it. If it's a security issue, I suppose you could grant the appropriate authority.
    0 pointsBadges:
  • rcl
    We have used the SBMRMTCMD several times in the past. I just scanned one of our source libraries and I see the following code example that should work for you. I think it is fairly self explanatory. I hope it is readable. Let me know if you have any questions. You first build the remote command in a CL variable (&RMTCMD in this example) and then run it: CHGVAR VAR(&RMTCMD) VALUE('CRTLIB LIB(' *CAT + &RSTLIB *TCAT ') TEXT(' *CAT &QUOTE *CAT + &LIBTEXT *TCAT &QUOTE *CAT ')') SBMRMTCMD CMD(&RMTCMD) DDMFILE(MYLIB/&RMTNAME) Rich
    45 pointsBadges:
  • Tmalik
    Use a simple Java program to call a CL or RPG program to process. Need help writing the Java let me know. DDM is another option. Insert a record in a DDM file and put a trigger on that file to launch another program on target system. Thanks Malik
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: