Page 1 of 1

Calling an ile rpg service program procedure that returns a value from a java class

Posted: Thu May 14, 2026 1:28 pm
by LUCAG
Hi everyone, except for the example included in the source comments of the ServiceProgramCall class, I haven't found any other examples of this.
Can anyone point me to some info?
I'm stuck with what I thought was a small problem but can't seem to resolve.
From a Java class running on a Windows server, I need to:
1. connect to a certain IBM i power server; (done)
2. set a specific library list with a given custom command; (done)
3. call a service program procedure that returns a char(6) value. (And here I'm stuck.)
Despite several attempts, the procedure, assuming it's actually executed, doesn't produce any results.
This is the RPG prototype of the procedure:

Code: Select all

dcl-pr RtvSupplierCode Char(6) EXTPROC('RtvSupplierCode');
  codMec zoned(7:0) const options(*omit:*nopass);
  vatCode char(16) const options(*omit:*nopass);
  idColCode packed(13:0) const options(*omit:*nopass);
end-pr;
The returned char(6) field may also be empty.
The three parameters are alternative; those not passed must be marked with the *OMIT placeholder.
The possible values for the test are:
codMec=some numbers or vatCode=some numbers but as a string or idColCode=again some numbers

Normally, the call in rpgile would be

Code: Select all

supplierCode = RtvSupplierCode(1236547 : *omit : *omit);
supplierCode = RtvSupplierCode (*omit : '123456789012345' : *omit);
supplierCode = RtvSupplierCode (*omit : *omit : 12345);

Now on my class It just doesn't seem to work.

Has anyone ever used this call?
Does anyone have any working code examples I can try?
Thanks in advance for your attention.

Re: Calling an ile rpg service program procedure that returns a value from a java class

Posted: Sun May 17, 2026 11:29 pm
by Scott Klement
Last time I looked into this, the ServiceProgramCall class supported calling a procedure that had no return value, or that returned a 4-byte integer. So it would never work with a character return value.

That said, I haven't looked into this in probably 20 years.

I would recommend creating REST APIs and calling them. Or at least call it via SQL as a stored procedure or function.

Re: Calling an ile rpg service program procedure that returns a value from a java class

Posted: Mon May 18, 2026 3:57 pm
by jonboy49
If a Rest Service is not an option then only other thing would be to recompile the procedure specifying RTNPARM on the PR. It won’t affect the RPG callers but will allow the Java to work with the return value as an extra parm.

Those are your only options - you can’t make the Java classes do stuff they aren’t designed to do