I work on a crossover communication with ile RPG and Java. I want to call a Class in a .jar File with some String Parameter and want to return a String to my RPG programm.
I get a Problem in my set Method. I cant call this method from RPG.
My "getOut()" method call, worked well. I get the right jString back. The CLASSPATH set is right.
Take a look on my Code:
RPG Code:
D FirstCall S O Class(*Java:'FirstCall')
D FirstCall1 S LIKE(FirstCall)
D*
D* Constructor in .jar File
D new_FirstCall PR O EXTPROC(*Java:
D 'FirstCall'
D :*CONSTRUCTOR)
D*
D* Create Java String Object
D makestring PR O EXTPROC(*JAVA:
D 'java.lang.String':
D *CONSTRUCTOR)
D bytes 30A CONST VARYING
D*
D* Prototype for Java String's getBytes method
D cvtToBytes PR 30A EXTPROC(*JAVA:
D 'java.lang.String':
D 'getBytes')
D Varying
D*
D* Get Methode in .jar File //this work well
D getOut PR o EXTPROC(*JAVA:
D 'FirstCall':
D 'getOut')
D Class (*JAVA:'java.lang.String')
D*
D* Set Methode in .jar File //Here i have some problems
D setOut PR O EXTPROC(*JAVA:
D 'FirstCall':
D 'setOut')
D Class (*Java:'java.lang.String')
D*
C* Parameter
C *entry plist
C parm $input
C parm $output
/Free
exSr setCLASSPATH;
FirstCall = new_FirstCall();
fldjString = makestring(%trimr($input));
//Set Method call
setOut(FirstCall:fldjString);
fldjString2 = getOut(FirstCall);
fldBty = cvtToBytes(fldjString);
$output = fldBty;
*INLR = *ON;
/End-Free
Java Code:
public class FirstCall
{
public String sOut;
public static void main(String[] args) throws Exception{
}
public FirstCall(){
}
public String getOut(){
return sOut;
}
public void setOut(String sIn){
sOut = sIn + " - java";
}
}
The setOut prototype should not have a return value. Remove the "O" from the setOut line.
D setOut PR EXTPROC(*JAVA:
D 'FirstCall':
D 'setOut')
D strparm O Class (*Java:'java.lang.String')
D CONST