Before and After Provisioning Action for IBM i Connector
You can configure a before and after provisioning action to support Before/After Actions. The JTOpen library provides an API to execute Command or CL scripts on the IBM i host, which are used to perform pre/post provisioning actions.
Prerequisites
-
Configure IBM i application
-
Configure CL scripts on IBM i host
Creating CL scripts
Complete the following procedure to create the CL scripts on IBM i computer:
-
Create a library as follows:
CRTLIB library-name
For example:
CRTLIB MTEST
-
Make the library as current library
CHGCURLIB library-name
For example:
CHGCURLIB MTEST
-
Create source physical file in that library
CRTSRCPF QCLSRC
(
QCLSRC
is the standard naming convention in the IBM i for CLP source members). -
Add member to ADDPFM file and enter the following details:
-
Physical File – QCLSRC
-
Library – MTEST
-
Member – Test123
-
Text – *BLANK
-
Press <ENTER>
-
-
Enter the following command:
STRPDM
Select option 3 – work with members and enter the following details:
-
File – QCLSRC
-
Library – MTEST
-
Press <ENTER>
-
-
To create members, press F6 and enter the following details:
-
Source member – TEST123
-
Source Type – CLP
-
Press <ENTER>
-
-
List of members will appear. To write CL script or edit member file:
-
Opt – 2 (edit)
-
Member – Test123
-
Type – CLP
The member file opens in seu editor.
Type I (for insert) on the first line as shown in the following figure and press Enter.
-
-
Write your CL script program in the seu editor and press F3.
Options for saving the file are displayed.
Enter Y (Yes) and press Enter. The file is saved.
-
To compile, use option 14 in front of member file name. Enter Y in the following field:
Delete existing object …….. Y Y=Yes, N=No
-
Navigate to where IBM i application is configured. Select IBM i application.
Open IBM i application Rules tab. Select the following option as required:
-
Before Provisioning Rule
-
After Provisioning Rule
-
-
Write java code in Rule Editor section. Specify the Rule Name and Save it.
Select the rule name you saved in earlier step by using the Select Rule option.
Perform any provisioning task and check if before/after provisioning action is executed.
For example, java code to run CL-script:
Copyimport java.io.IOException;import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400Exception;
import com.ibm.as400.access.AS400Message;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.CommandCall;
import com.ibm.as400.access.ErrorCompletingRequestException;
import com.ibm.as400.access.ObjectDoesNotExistException;
AS400 system = null;
String host = "NDS400.isr.bmc.com";
String user = "UMITTAL";
String password = "UMITTAL4";
system = new AS400(host, user, password);
System.out.println ("Connected successfully!!!!");
CommandCall cmd = new CommandCall(system);
try{
if(cmd.run("CALL PGM(MTEST/Test123)") != true){
// Test123 is member file in library MTEST which gets called here.
//similarly we can use - command.run("CRTLIB FOREST");
}
else {
AS400Message[] messagelist = cmd.getMessageList();
for (int i = 0; i < messagelist.length; ++i){
System.out.println(messagelist[i].getText());
System.out.println("Command Success!!");
}
}
}catch(Exception e){
System.out.println("error" + e.getMessage());
}
System.out.println("ending program");
Note
In this example, hostname and related parameters have been hardcoded, you can access these parameters from IdentityIQ objects (Application, AccountRequest, Items).