Passing Parameters to RPG Program

dcs

Member
I am trying to call an RPG program on the iSeries, from a c business function, and have the RPG program return a parameter value. I have tried B34A1030, but that only executes a command. You cannot see the results of the command. I have tried the following, but have not had any luck:

in the header file:
void tss_tstps(JCHAR *, JCHAR *);
#pragma map(tss_tstps,_J("PTSTPASS"))
#pragma linkage(tss_tstps, OS)
in the .c file I call the function and pass in two parameters:

This spins off multiple threads, but the process seems to kill itself and the only messages in the log are:

INFO: Done setting IPC Handle State structures to abandoned, process exiting immediately: iParam: 1311972135
INFO: Entering kernel signal handler, process exiting soon: iParam: 1311972135
INFO: Loop detected in signal handler, process exiting immediately: iParam: 1311972135.

Oracle has an example on their website, but it looks like it is pre-unicode coding. Has anyone tried this before in E900?
 
dcs,

B34A1030 - Execute External Program, does not return the results of the command/program that was run, as you have discovered. It only returns a parameter that indicates if the command/program ran successfully.

The way around this situation is to create a JCL (I think that is what a command script is called in AS400/iSeries speak - it has been a while), either programmatically from the same place you are attempting to run the B34A1030, or independently on the OS. The JCL will run the command/program and save the returned values to a file with a predefined name and location. Then your process can run the JCL using B34A1030 and then read the file and get the value(s). The process would be something like:

1) create JCL using JDE business functions (if not creating it on OS)
2) run JCL using B34A1030
3) read data from file using JDE business functions.
 
dcs,

We do this all the time. The RPG progams we call do not use Unicode, so they are defined with char*. The parms are converted from JCHAR* to char* using jdeFromUnicodeSimple. From our code, I also see we make sure the string parms are padded with spaces.

Hope this helps,
Craig
 
Craig,

I made it work with ZCHAR*. I tried both null-terminated ZCHAR and a ZCHAR with the exact size of the RPG parameter length and it didn't seem to matter, both worked (I did pad both strings with spaces out to three characters and of course had the null character for the one string). Example:

ZCHAR zszCurrencyCode[4]
ZCHAR zszCurrencyCode[3]
in RPG the CurrencyCode parameter is defined as 3.

Normally in c you use null-terminated strings. My question is, does it matter when calling RPG?

dcs
 
Back
Top