Interacting with PeopleSoft through Java - Part I

PeopleSoft has some stuff which is really good to explore and learn. But they are kept far from the reach of normal developers, and it is often very tough to appreciate the importance of it.


One such feature is using PSJOA.jar to connect to PeopleSoft through Java.

In this first of the series of posts, we will see how this can be accomplished as a step by step tutorial. The usage of this feature is simply countless. It can be used for any purposes. It can even replace the integration broker stuff that is managed by PeopleSoft.

Before we start, we need to locate some files and keep them ready.

PSJOA.jar -> This is the interface jar file which would help Java to interact with PeopleSoft through a component interface. It will be available in %PS_HOME%\class directory.


Let us create a simple component to illustrate the usability of this feature. Then, we will see the errors thrown by PeopleSoft at each and every stage and see how we can address them.

Create a record with a single field and put this on a page. Create a component and move it to a component interface. The component interface should have the following methods :- Cancel, Create, Find, Get and Save.Now, open the component interface. Click on Build -> PeopleSoft APIs. This process would validate all the component interface and you will get some errors in this process. You can just skip the errors and continue the process. Select the "java" class option and specify the target location where the java files needs to be placed. For my component interface, PeopleSoft created the following four files

1) ITesterCi.java
2) ITesterCiCollection.java
3) TesterCi.java
4) TesterCiCollection.java


The next step would be to compile these four java files and construct class files. Believe me, this is one of the toughest step anybody can encounter and it needs to be carefully resolved. My version of PeopleSoft PeopleTools is 8.46.08. The errors and resolution might vary depending on the version of PeopleTools that you are using, however, the base approach would still remain the same.

I got a beautiful error when I compiled the java files.

javac -classpath D:\PT8.46\class\psjoa.jar *.java
ITesterCi.java:35: cannot resolve symbol
symbol : class ICompIntfcPropertyInfoCollection
location: interface PeopleSoft.Generated.CompIntfc.ITesterCi
public ICompIntfcPropertyInfoCollection getPropertyInfoCollection() throws JOA
Exception;
^
ITesterCi.java:36: cannot resolve symbol
symbol : class ICompIntfcPropertyInfoCollection
location: interface PeopleSoft.Generated.CompIntfc.ITesterCi
public ICompIntfcPropertyInfoCollection getCreateKeyInfoCollection() throws JO
AException

When I checked the iTesterCI.java, the declaration elements were

import java.math.*;
import psft.pt8.joa.*;
Some more errors like this were also present:
TesterCi.java:86: cannot resolve symbol
symbol : class ICompIntfcPropertyInfoCollection
location: class PeopleSoft.Generated.CompIntfc.TesterCi
return (ICompIntfcPropertyInfoCollection)m_oThis.getProperty("PropertyInfoCollection");
^
TesterCi.java:90: cannot resolve symbol
symbol : class ICompIntfcPropertyInfoCollection
location: class PeopleSoft.Generated.CompIntfc.TesterCi
return (ICompIntfcPropertyInfoCollection)m_oThis.getProperty("CreateKeyInfoCollection");
^
TesterCi.java:94: cannot resolve symbol
symbol : class ICompIntfcPropertyInfoCollection
location: class PeopleSoft.Generated.CompIntfc.TesterCi
return (ICompIntfcPropertyInfoCollection)m_oThis.getProperty("GetKeyInfoCollection");
^
TesterCi.java:98: cannot resolve symbol
symbol : class ICompIntfcPropertyInfoCollection
location: class PeopleSoft.Generated.CompIntfc.TesterCi
return (ICompIntfcPropertyInfoCollection)m_oThis.getProperty("FindKeyInfoCollection");
^
TesterCi.java:142: cannot resolve symbol
symbol : class ICompIntfcPropertyInfo
location: class PeopleSoft.Generated.CompIntfc.TesterCi
return (ICompIntfcPropertyInfo)m_oThis.invokeMethod("GetPropertyInfoByName", args);

This means, there is some problem in the java files generated by the Application Designer. The class files that are pointed out in the source files, are not the same as what this is contained in PSJOA.jar.

We will have to edit the class files and replace all such occurences with suitable class file names. This will ensure that the class files compiles successfully.

For my version of PeopleTools, that is what I did

Change the java code to
public CIPropertyInfoCollection getPropertyInfoCollection() throws JOAException {
return (CIPropertyInfoCollection)m_oThis.getProperty("PropertyInfoCollection");
}
public CIPropertyInfoCollection getCreateKeyInfoCollection() throws JOAException {
return (CIPropertyInfoCollection)m_oThis.getProperty("CreateKeyInfoCollection");
}
public CIPropertyInfoCollection getGetKeyInfoCollection() throws JOAException {
return (CIPropertyInfoCollection)m_oThis.getProperty("GetKeyInfoCollection");
}
public CIPropertyInfoCollection getFindKeyInfoCollection() throws JOAException {
return (CIPropertyInfoCollection)m_oThis.getProperty("FindKeyInfoCollection");
}

Note that this class is available in PSJOA.jar file. I also commented the following piece of code
// public CIPropertyInfo getPropertyInfoByName(String Name) throws JOAException {
// Object[] args = new Object[1];
//args[0] = Name;
//return (CIPropertyInfo)m_oThis.invokeMethod("GetPropertyInfoByName", args);
//}
as this is not required for my R & D. Further, this file implements ITesterCi which is evident from
public class TesterCi implements ITesterCi

So, we will have to edit the other Java file as well. Following lines were changed in that class file..
public CIPropertyInfoCollection getPropertyInfoCollection() throws JOAException;
public CIPropertyInfoCollection getCreateKeyInfoCollection() throws JOAException;
public CIPropertyInfoCollection getGetKeyInfoCollection() throws JOAException;
public CIPropertyInfoCollection getFindKeyInfoCollection() throws JOAException;

As before, I commented out this line
//public ICompIntfcPropertyInfo getPropertyInfoByName(String Name) throws JOAException;

Now, when I compiled the jar files, they got compiled successfully without any errors. One milestone gone. Part II of this blog will explain how to create a java template from the CI and make it interact with the class files generated out of this blog. We will create a key and update a table with a value in the end.!

4 comments:

  1. Hi,

    This is brilliant stuff..tried all over the web to connect PeopleSoft and Java and this tutorial explains this nicely....

    Cheers

    ReplyDelete
  2. Hi, Wonderful!! It is really helpful. But I am facing this issue: "(0,0) : PeopleTools release (8.52.07) for web server/ Application Designer '' is not the same as Application Server PeopleTools release (8.53.08). Access denied."

    I think I have psjoa.jar for pt 8.52 where as all our setup is pt 8.53. So anyone can help me how I can find psjoa.jar for PT 8.53?

    ReplyDelete
  3. Hi Fahad, are you not able to find it inside your Peopletools installation folder?

    ReplyDelete