Using the Component Interface SDK Sample in Java and C+ +
This section describes how to use the component interface SDK sample in Java and C++.
The component interface sample programs for Java and for C++ are provided as part of the component interface SDK and follow the same sequence of options. The source files are located in <PS_HOME>\sdk\pscompintfc\src\<java or c++>\samples\sdk_bus_exp.
The component interface sample program for Java is provided as part of the component interface SDK, located in <PS_HOME>\sdk\pscompintfc\src\java\samples\sdk_bus_exp.
The Java source code for the sample is in the following file: sdk_bus_exp.java
Before you run the sample, you must build the APIs and set up the Java environment.
To build the Java component interface sample:
Set your java classpath to include the external API classes you already built and the psoa.jar library delivered under <PS_HOME>\class\psjoa.jar
Compile the source using javac sdk_bus_exp.java
The component interface sample program for C/C++ is provided as part of the component interface SDK, located in <PS_HOME>\sdk\pscompintfc\src\cpp\samples\sdk_bus_exp.
The C++ source code for the sample is in the following file: sdk_bus_exp\sdk_bus_exp.cpp
Before you run the sample, you must build the APIs and set up the C++ environment. To build the C++ component interface sample:
Open the sdk_bus_exp workspace in the Microsoft Visual C++ editor.
Build the project by selecting Build, Rebuild All.
To run the compiled Java or C++ component interface sample:
In a DOS window, change directories to the location of the sdk_bus_exp directory.
After you launch the executable sdk_bus_exp, the system prompts you for parameters one at a time.
At each prompt, enter the appropriate value and press Enter.
Select option 1 to sign in. You are then prompted to provide the connect information.
If the connect succeeds, a menu appears where you can perform Get or Find functions.
Get details for an employee.
Select option 1 to get details for an employee. You are then prompted with the different update modes and the employee ID for which you want to display information. Enter the employee ID 8001 and press Enter. This displays the level 0 data and the options that you can perform.
Select a business expense period at collection level 1.
Select option 8, Item, to select a business expense period. Selecting this option displays a list of available business expense periods for the selected employee.
Select the expense period that you want to work with.
Select a business expense detail item at collection level 2..
Select option 18, Item, to select a business expense detail within the selected business expense period. Selecting this option displays a list of available business expense details within the selected business expense periods.
The following discussion refers to the Java sample program, sdk_bus_exp.java. (The code has been edited for length.) It explains the runtime options shown above.
Import all the required classes:
The code example shows how to import the required classes:
package sdk_bus_exp; import java.io.*; import java.util.*; import psft.pt8.joa.*; import PeopleSoft.Generated.CompIntfc.*; public class sdk_bus_exp { .....
Declare all the required objects.
Only one active period and one active detail record are possible at any time. Users are prompted to select the needed values if they are not active.
Collection Object
Level
Item Object for Collection
oSdkBusExpCollection
Root (SDK_BUS_EXP)
oSdkBusExp
oSdkBusExpPerCollection
Level 1 (SDK_BUS_EXP_PER)
oSdkBusExpPer
oSdkBusExpDtlCollection
Level 2 (SDK_BUS_EXP_PER_DTL)
oSdkBusExpDtl
In addition, the CompIntfPropInfoCollection object is used to access the structure of a component interface. It is not specific to a component interface.
Declare the PeopleSoft session object.
Connect to the application server.
Instantiate the component interface.
Perform a Get or Create to access the component interface.
You must provide the keys to access the record that you want to modify.
Use the appropriate methods to access the component interface properties.
There are standard methods and user-defined methods defined for the session, the component interface, and the component interface collections.
The executeMethod function is used to invoke a method specified as a function parameter (nMethodIn).
The component interface Java SDK sample has 25 options:
SDK Option |
Where Executed |
---|---|
1 through 5 |
On the component interface. |
6 through 15 |
SDK_BUS_EXP_PER collection. |
16 through 25 |
SDK_BUS_EXP_DTL collection |
Options 1 through 4 and options 6 through 25 are similar in behavior to those described in the product documentation for PeopleCode API Reference for a component Interface and its collections.
Option 5, InsertBusExpDtlDefaults, is the user-defined method of the SDK_BUS_EXP component interface. This method is defined in PeopleCode inside the component interface definition.
The logic used in the corresponding options of these collections is identical.
This is the main method. It performs such functions as starting the session, getting the component interface, and disconnecting:
public static final void main(String[] args)System.out.println(" ");
System.out.println("\t 1) Sign In ");
System.out.println("\t q) Quit ");
System.out.println(" ");
System.out.print("Command to execute (1, q) [1]: ");
charTemp = readCharacter();
switch (charTemp) {case 'q':case 'Q':.....
disconnectFromAppServer();
return;
default:
getConnectParameters();
if (connectToAppServer()) {
oSdkBusExp = (ISdkBusExp) oSession.getCompIntfc(m_strCIName);
while (getKeyType()) {
methodInt = selectMethod();
while (methodInt != 0) {
executeMethod(methodInt);
if (methodInt == 2) {
methodInt = 0;
} else {
methodInt = selectMethod();
.....
The following listings of code are taken from the C++ sample program, sdk_bus_exp.cpp. (The code has been edited for length.)
Include all the headers.
#ifdef PS_WIN32 #include "stdafx.h" #endif #include "cidef.h" #include "apiadapterdef.h" #include "PSApiExternalLib.h" #include "PSApiAdapterInter.h" #include "PeopleSoft_PeopleSoft_i.h" #include <stdio.h> #include <stdlib.h> #include <iostream.h> #include <wchar.h>
Declare the PeopleSoft session handle.
HPSAPI_SESSION hSession;
Declare all the required objects. Only one active period and one active detail record are possible at any time.
Collection Object
Level
Item Object for Collection
hSdkBusExpCollection
Root (SDK_BUS_EXP)
hSdkBusExp
hSdkBusExpPerCollection
Level 1 (SDK_BUS_EXP_PER)
hSdkBusExpPer
hSdkBusExpDtlCollection
Level 2 (SDK_BUS_EXP_PER_DTL)
hSdkBusExpDtl
Collection ObjectLevelItem Object for CollectionhSdkBusExpCollectionRoot (SDK_BUS_EXP)hSdkBusExphSdkBusExpPerCollectionLevel 1 (SDK_BUS_EXP_PER)hSdkBusExpPerhSdkBusExpDtlCollection Level 2 (SDK_BUS_EXP_PER_DTL)hSdkBusExpDtl
The function executeMethod is used to launch the appropriate method depending upon the user input (nMethodIn).
The component interface C++ SDK sample has 25 options:
SDK Option1 through 5 SDK_BUS_EXP_PER collection.6 through 25SDK_BUS_EXP_DTL collection
SDK Option |
Where Executed |
---|---|
1 through 5 |
On the component interface. |
6 through 15 |
SDK_BUS_EXP_PER collection |
16 through 25 |
SDK_BUS_EXP_DTL collection |
Options 1 through 4 and options 6 through 25 are similar in behavior to those described in the product documentation for PeopleCode API Reference for a component Interface and its collections.
Option 5, InsertBusExpDtlDefaults, is the user-defined method of the SDK_BUS_EXP component interface. This method is defined in peoplecode inside the component interface definition.
The logic used in the corresponding options of these collections is identical.