Previous     Contents     Index     DocHome     Next     
iPlanet Application Server Enterprise Connector for PeopleSoft Developer's Guide



Chapter 4   Programming Examples


To program for iPlanet Application Server Enterprise Connector for PeopleSoft, you must know how to acquire Unified Integration Framework (UIF) objects and execute functions by using function objects. You also need to know how to use servlets with the iPlanet Application Server Enterprise Connector for PeopleSoft to access functions on a PeopleSoft EIS. This chapter includes the following information:



PeopleSoft Samples

The PeopleSoft Samples provided show the general flow of a connector program.


Note You must build the message definition, described in Building Message Definitions", before running samples on either NT or Solaris.

Ensure that iPlanet Web Server and iPlanet Application Server are up and running.




Activation

The PeopleSoft sample consist of servlets which activate PeopleSoft programs that access the Peoplesoft management system.

You must have set up the environment before activating the samples. See Post Installation Issues in Chapter 2 of the iPlanet Application Server Enterprise Connector for PeopleSoft Administrator's Guide.


To Run the Peoplesoft Samples on NT

  1. Select Programs>iPlanet Application Server 6.0>PEOPLESOFT Connector 6.0 - Start Worker Process.

  2. Select Programs>iPlanet Application Server 6.0>PEOPLESOFT Connector 6.0 - Sample Applications.

    The PeopleSoft sample script is displayed with links to the samples.

  3. Click on the link "To Start The Simple Sample - ProcessMsg Demo" to activate the sample shown in Figure 4-1.

Figure 4-1    PeopleSoft Customer Details Samples



To run the Employee Details Sample on Solaris

  1. From <iPlanet Install directory>/ias/APPS/bin, type:

    ./startpsftworker.sh start

  2. Start your browser.

  3. Enter the following URL: <host name>:<web server port>/psftSamples.

    The PSFT Employee Details Samples appears, showing links to the ProcessMsg and SearchDialog samples.

  4. Click on: To Start The ProcessMsg Demo link

    The Employee Details samples opening screen appears.

  5. Type in the information in the text fields, or accept the default values, and click on Execute.

Figure 4-2    startForm.jsp


  1. After the data finishes processing the ProcessMsg End Form appears.

Figure 4-3    Employee's Details.




Code Example



This is a fully operational example. You can use it as a model for building your own application.

The code listings for the Process Message and Search Dialog samples are detailed in Code Example 4-1 and Code Example 4-2.

Code Example 4-1 SimpleProcessMsg.java

package SimpleProcessMsg;

import java.util.*;

import javax.servlet.http.*;

import java.io.*;

import javax.servlet.*;

import javax.naming.*;

import netscape.bsp.*;

import netscape.bsp.runtime.*;

import netscape.bsp.dataobject.*;

import netscape.bsp.BspException.*;

public class main extends HttpServlet

{

   protected String getInputString(HttpServletRequest request, String parameterName,ServletOutputStream out) throws IOException

   {

      // This method is useful since getValString returns null on

      // some platforms and an empty string on other platforms for

      // missing input parameters.   It also removes any whitespace

      // characters that the user my have inadvertantly entered.

      String parameter = request.getParameter(parameterName);

      if (parameter != null)

      {

         parameter = parameter.trim();

      }

      else

         out.println("\n<BR>parameter "+ parameterName+" is null");

      return parameter;

   }

   protected ServletOutputStream setOutputStream (HttpServletResponse res)

      throws ServletException, IOException

   {

      res.setContentType("text/html");

      ServletOutputStream out = res.getOutputStream();

      return out;

   }

   private IBSPRuntime getRuntime() throws BspException

   {

      com.kivasoft.IContext _ctx = ((com.netscape.server.servlet.platformhttp.PlatformServletContext)    getServletContext()).getContext();

      IBSPRuntime ibspruntime = access_cBSPRuntime.getcBSPRuntime(_ctx, null, null);

      return ibspruntime;

   }

   private IBSPServiceProvider getServiceProvider(IBSPRuntime runtime) throws BspException

   {

      if(runtime != null)

         return runtime.createServiceProvider("PSFT", "connection");

      else

         return null;

   }

   public void doGet (

      HttpServletRequest   request,

      HttpServletResponse   response ) throws ServletException, IOException

   {

      int hr=0;

      IBSPServiceProvider sp=null;

      IBSPFunctionObject fn = null;

      IBSPDataObject data = null, prop = null;

      ServletOutputStream out = setOutputStream(response);

      try

      {

         String WebUserId=new String(getInputString(request,"WebUserId",out));

         IBSPRuntime runtime = getRuntime();

         if(runtime != null )

         {

            sp = getServiceProvider(runtime);

            if(sp != null )

            {

               IBSPDataObject config=sp.getConfig();

               config.setAttrFString("WebUserId",WebUserId);

               fn = runtime.createFunctionObject("PSFT", "UpdateEmployeeDetails.DisplayEmployeeDetails.ProcessMsg");

               hr = sp.enable();

               if(hr!=0)

                  return;

               if( fn != null )

               {

                  hr = fn.useServiceProvider(sp);

                  if(hr!=0)

                     return;

                  hr = fn.prepare("Execute");

                  if(hr!=0)

                     return;

                  data = fn.getDataBlock();

                  if(data !=null)

                   setInputData(request,data,out);

                  prop = fn.getProperties();

                  if( prop != null )

                     setInputProperties(prop);

                  hr = fn.execute();

                  if( hr == 0 )

                  {

                     data = fn.getDataBlock();

                     if(data != null )

                        getOutputData(out,data);

                  } // if(hr == 0)

                  else

                     out.println("\n<BR>Execute Failed");

               } // if(fn != null)

               else

                  out.println("\n<BR>Create function object Failed");

            } // if( sp != null )

            else

               out.println("\n<BR>Create service provider Failed");

            hr = sp.disable();

         }

         else

            out.println("\n<BR>Create runtime Failed");

      }//try.

      catch(BspException BspError)

      {

         if(sp!=null)

         {

            hr = sp.disable();

         }

         String errorMessage="BspException:"+BspError.getMessage();

         IBSPDataObjectStructure info = null;

         info=BspError.getInfo();

         if (info != null && info.attrExists("msgid") )

         {

            errorMessage += " Error code : " + info.getAttrInt("msgid") ;

         }

         out.println("\n<BR>"+errorMessage);

      }

      catch(Exception exception)

      {

         if(sp!=null)

         {

            hr = sp.disable();

         }

         String errorMessage="Exception:"+exception.toString();

         out.println("\n<BR>"+errorMessage);

      }

      return;

   }//doGet.

   public void setInputData(HttpServletRequest request,IBSPDataObject data,ServletOutputStream out) throws BspException,IOException

   {

       data.setAttrFString("INPUT.EmplId",getInputString(request,"INPUT.EmplId",out)) ;

       data.setAttrFString("INPUT.OperClass",getInputString(request,"INPUT.OperClass" ,out));

   }

   public void getOutputData(ServletOutputStream out,IBSPDataObject data) throws BspException,IOException

   {

      out.println("\n<BR>EmplRcd:"+data.getAttrInt("OUTPUT.EmplRcd"));

       out.println("\n<BR>NationalIdType:"+data.getAttrFString("OUTPUT.NationalIdType "));

       out.println("\n<BR>AccessCode:"+data.getAttrFString("OUTPUT.AccessCode"));

      out.println("\n<BR>Name:"+ data.getAttrFString("OUTPUT.Name"));

      out.println("\n<BR>LastName:"+ data.getAttrFString("OUTPUT.LastName"));

      out.println("\n<BR>ACName:"+ data.getAttrFString("OUTPUT.ACName"));

      out.println("\n<BR>DepartmentSetid:"+ data.getAttrFString("OUTPUT.DepartmentSetid"));

      out.println("\n<BR>Department:"+ data.getAttrFString("OUTPUT.Department"));

      out.println("\n<BR>NidType:"+ data.getAttrFString("OUTPUT.NidType"));

      out.println("\n<BR>NidShortDescription:"+ data.getAttrFString("OUTPUT.NidShortDescription"));

      out.println("\n<BR>NationalId:"+ data.getAttrFString("OUTPUT.NationalId"));

   }

   public void setInputProperties(IBSPDataObject prop) throws BspException

   {

      prop.setAttrInt("ProcessingMessages.OperationType",0);

   }

}//main



Search Dialog Demo Code Examples

Code Example 4-2 SimpleProcessMsg.jsp

<HTML>

<HEAD>

   <TITLE>SimpleProcessMsg Demo</TITLE>

</HEAD>

<BODY>

<center>

<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="600" >

   <tr>

   <td VALIGN=TOP WIDTH="420" >

   <form action="/NASApp/SimpleProcessMsg/main" method=get>

   <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=6 WIDTH="100%">

      <tr>

         <td BGCOLOR="#8979C8">

            <b><font face="sans-serif,arial,helvetica" color=white>

            SimpleProcessMsg Start Form</font></b>

         </td>

      </tr>

      <tr VALIGN=TOP>

         <td BGCOLOR="#666699">

         <p>

         <center>

         <TABLE BORDER=0 cellspacing=0 cellpadding=0>

            <tr>

               <td><font face="arial, helvetica, sans-serif" color=white size="-1">WebUserId:</font></td>

               <td><font face="arial, helvetica, sans-serif">

                  <input type="text" name="WebUserId" size=20 maxsize=50 value="W2" ></font>

               </td>

            </tr>

            <tr>

               <td><font face="arial, helvetica, sans-serif" color=white size="-1">EmplId:</font></td>

               <td><font face="arial, helvetica, sans-serif">

                  <input type="text" name="INPUT.EmplId" size=20 maxsize=50 value="8001" ></font>

               </td>

            </tr>

            <tr>

               <td><font face="arial, helvetica, sans-serif" color=white size="-1">OperClass:</font></td>

               <td><font face="arial, helvetica, sans-serif">

                  <input type="text" name="INPUT.OperClass" size=20 maxsize=50 value="ALLPANLS" ></font>

               </td>

            </tr>

         </TABLE>

         </center>

         </td>

      </tr>

   </TABLE>

   <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" >

   <tr>

      <td BGCOLOR="#666699" >

         <TABLE>

            <tr>

               <td valign=top ><input type="submit" name="execute" value="EXECUTE">

               </td>

            </tr>

         </TABLE>

      </td>

   </tr>

</TABLE>

</form>

</td>

</tr>

</TABLE>

<P>

<CENTER>

<TABLE BGCOLOR="#cccccc" BORDER="0" CELLPADDING="1" CELLSPACING="0" WIDTH="600">

<tr>

   <td><p>&nbsp;</P>

      <FONT size="-2" face="PrimaSans BT, Verdana, sans-serif">Copyright © 1999

         <A HREF="http://home.netscape.com/" NAME="Link3">Netscape Communications Corp</A>

         All rights reserved.</FONT>

   </td>

</tr>

</TABLE>

</CENTER>

</P>

</center>

</BODY>

</HTML>




Building Message Definitions



Message Definitions are the metadata, which describe the format of data associated with a particular PeopleSoft panel. This section includes the procedures for building your own message definitions. You must build the message definition before you run a sample.

For more information on PeopleSoft application development, go to the PeopleSoft web site at:

http://www.peoplesoft.com/en/us/products/technology/index.html

You build message definitions by using the following procedures:


To Create a Project

  1. Select Start > Programs > PeopleSoft 7.5 > Application Designer.

    The PeopleSoft Signon screen appears.

  2. Select Oracle from the drop-down list in the Connection Type list box.

    Accept the default PSOR in the Database Name dialog box.

  3. Type in your Operator ID and Password and click on the OK button.

    The PeopleSoft Application Designer window appears.

  4. Select File > New.

  5. From the New dialog, select Project and click OK.


To Select Project Options

  1. Select Tool > Options.

    The Options dialog box appears.

  2. Select When Object is modified and saved from the Insert Object into Project radio button group.

  3. Select Do not insert related objects with current object radio button from the Related Objects Options radio button group.

  4. Click OK to save these options.


To Define a New Employee Record Field

You must include the new field, EMPL_RCD, to run the samples.

  1. Select File > New > Field.

  2. Click OK.

    The New Field drop-down list box appears.

  3. Select Number from the drop-down list and click OK.

  4. Type:

    • Employee Record in the Long Name field.

    • EmplRcd in the Short Name field.

  5. Dismiss the dialog box.

  6. Select File > Save As and type EMPL_RCD in the Save Name As field of the dialog box.

  7. Click OK to save the new field.

  8. Select File > Save Project As.

  9. Type DEMO_PROJECT in the Save Name As text box and then click OK.


To Add Existing Fields To Your Project

  1. Select File > Open.

  2. Select Field from the Object Type drop-down list box.

  3. Type EMPLID into the Name text field.

  4. Click on Select.

    A list of all fields that start with that prefix appear. If there is only one field with the prefix, the field definition dialog box opens.

  5. Double-click the EMPLID field to open the field definition dialog box.

  6. Press <F7> to insert the currently selected object into the project.

  7. Close the Open Object dialog box.

  8. Repeat the procedure starting with step 1 to add the following fields to the project.

    • EMPL_RCD

    • OPRCLASS

    • ACCESS_CD

    • NAME

    • LAST_NAME_SRCH

    • SETID_DEPT

    • DEPTID

    • NAME_AC

    • NID_COUNTRY

    • NATIONAL_ID_TYPE

    • NID_DESCRSHORT

    • NATIONAL_ID

    Your screen should look like this when you finish inserting all the necessary fields.


To Define The Record And Build A Search Dialog Box

  1. Select File > New.

  2. Select Record from the Object Type drop-down list box.

  3. Click OK.

  4. Drag-and-drop the EMPLID field to the new record.



    Note The sequence of inserting fields in the record is important.



  5. Drag-and-drop all the other designated fields to the record in the order shown in the following figure.

    When you are finished your record should look like this.

  6. Select File > Save As.

  7. Type in the new record name and click OK.


To Set the Record Field Properties

  1. Select the EMPLID field and then click the right mouse button to display the list box.

  2. Choose Record Field Properties to display the Record Field properties dialog box.

  3. Mark the following check boxes:

    • Key

    • Search Key

    • List Box Item (this is automatically selected if you select either Key or Search Key)

  4. Click OK.

  5. Continue selecting each field in turn until the record field properties have been specified for each field according to the following table.


    Table 4-1 Message Definition Options

    Field

    Key

    Search

    List

    System

    EMPLID  

    Key  

    Yes  

    Yes  

    No  

    EMPL_RCD  

     

    No  

    Yes  

    No  

    OPRCLASS  

    Key  

    No  

    No  

    No  

    ACCESS_CD  

     

    No  

    No  

    No  

    NAME  

    Alt  

    No  

    Yes  

    No  

    LAST_NAME_SEARCH  

    Alt  

    No  

    Yes  

    No  

    SETID_DEPT*  

    Alt  

    No  

    Yes  

    No  

    DEPTID*  

    Alt  

    No  

    Yes  

    No  

    NAME_AC  

    Alt  

    No  

    Yes  

    No  

    NID_COUNTRY  

     

    No  

    No  

    No  

    NATIONAL_ID_TYPE  

     

    No  

    No  

    No  

    NID_DESCRSHORT  

     

    No  

    No  

    No  

    NATIONAL_ID  

     

    No  

    No  

    No  



Note

Alt - check the Alternate Search Key check box




To Set the Edit Field Options



Note

These edit options must be set only for the SETID_DEPT and DEPTID fields.



  1. Select the SEPTID_DEPT field and then click the right mouse button to display the list box.

  2. Choose Record Field Properties to display the Record Field properties dialog box.

  3. Select the Edit tab to display the Record Field properties Edit dialog box.

  4. Select the Edit options as specified inTable 4-2.

    Table 4-2 Record Field Properties Edit Options

    Record

    Edit Type

    Type

    Prompt_Table

    SETID_TBL  

    Table Edit  

    Prompt Table Edit  

    SETID_TBL  

    PERS_DEPT_VW  

    Table Edit  

    Prompt Table Edit  

    PERS_DEPT_VW  

  5. Select File > Save.


To Set Table Space

  1. Select Tools > DataAdministration > Set_TableSpace.

  2. Click on Set_TableSpace to display the Select Tools data administrator.

  3. Click on Set_TableSpace to display the Change Space dialog box.

  4. Select HRAPP and click OK button.

  5. Click Save All button.


To Build The Record

  1. Select the record you built.

  2. Select Build > Current Object to display the Build dialog box.

  3. Select:

    • Create Tables check box

      The Create Indexes check box is automatically selected also.

    • Execute-and-build-script button.

  4. To build the new record, click the Build button.

    Check that there are no error messages in the Output window.

    If there are error messages, consult your PeopleSoft documentation.


To Build a Panel

  1. Select File > New.

  2. Select Panel from the Object Type drop-down list box.

  3. Click OK.

  4. Drag-and-drop the fields from the new record that you built onto the panel.

    The field prompt display sequence will be the same as the sequence that the fields were dragged-and-dropped.

  5. Double-click the EMPLID field, the Panel Field Properties dialog box is displayed.

  6. Click the Use tab to display the Field Use Options dialog box. Mark the Display Only check box.

  7. Click OK.

  8. Double-click the National ID Type field to display the Panel Field Properties dialog box.

  9. Mark the Related Display Field check box.

  10. Click OK.

  11. Double-click the NID Short Desc. field to display the Panel Field Properties dialog box.

  12. Mark the Display Control Field check box and then select National ID Type Field from the Related Control Field list.

  13. Click OK.

  14. Select File > Save As.

  15. In the Save As dialog box, type in the Panel name and then click OK.


To Define a Panel Group For This Panel

  1. Select File>New.

  2. Select Panel Group from the Object Type drop-down list box.

  3. Click OK.

  4. Drag-and-drop the EMPL_DETAILS panel to the Panel Group window.

  5. Click the Property button.

    The Panel Group Properties dialog box is displayed.

  6. Click on the Use tab.

  7. From the Search record drop-down menu, select the Record you defined in the previous step.

  8. Accept the default Actions: Add and Update/Display, and the default 3-Tier Execution Location.

  9. Click OK.

  10. Select File > Save As.

  11. In the Save As dialog box, type the Panel Group name,

  12. Select the default Market type from the drop-down list

  13. Click then OK button.


To Define Your Menu

  1. Select File > New.

  2. Select Menu from the Object Type drop-down list box and then click OK.



    The Menu bar is displayed.

  3. Double-click on the broken-line box on the menu bar.



    The Bar Item Properties dialog box is displayed.



  1. Type Use in the Name and Label text boxes and then click OK.

    The Menu bar now displays a new Bar item: Use.

  2. Drag -and drop the panel group to the menu item.



  3. Select File > Save As.

  4. Type the Menu name in the Save As dialog box, and click OK.




To Define a New Business Process

  1. Select File > New > Business Process and click OK.

    The Business Process workspace and toolbar appears.



  1. Select the Activity icon by clicking with the left-mouse button.

  2. When the Activity is at the location you want, click the left-mouse button to display the Activity Choice dialog box.



  3. Select the Create New Activity radio button and click OK.

    An Activity tool appears on the worksheet.



  1. Select the Activity tool and then click the right-mouse button.

    The Activity Definition dialog box appears.

  2. Type the activity definition in the Name text box and then press the tab key on you keyboard; the name is automatically copied to the Icon Description. text box.



    Do not leave spaces in the activity definition name.

  3. Click OK.

  4. Select File > Save.

    Type the name of the business process into the text box of the Save As dialog box.



  1. Click OK to create a business process.


To Define a Message Agent

  1. Double-click the activity.

    A business process palette appears.

  2. Left click on the Other App icon.

  3. Position the cursor in the worksheet.

  4. Click the left-mouse button.



  5. Click the right-mouse button to display the Message Agent Definition dialog box.



  6. Type in the Message Agent Definition name.

    Do not leave spaces within the Message Agent Definition name.

  7. Click the Attribute button and select the fields from the Message Attribute dialog box drop-down lists.



  8. Click OK.

    You need to build a new message for each action.

  9. Click the Level Mapping button and select the following radio buttons and checkbox

    • If Row Found - Update

    • If Row Not found - Insert

    • Output all occurrences - Mark check box



  1. Click OK.


To Specify the Message Agent Field Map

  1. Click on the Field Mapping button on the Message Agent Definition dialog box.

  2. Click the Add button.

    For each field you must select the source Record, the Field name, and Input and/or Output.

  3. Type in the Field name.

  4. Select the record from the Record list box.

    EmplId and OperClass must be selected from the Search Record.

    All other records must be selected from the appropriate source record.


    Note

    When you define a Message Definition that is used to add a record, the key field must have in the Map When drop-down list box Input.



  5. The following table is the end result of the complete process.


To Give Authorization To The Panel

  1. Select Go > PeopleTools > Security Administrator.



    .

  2. Select File > Open.



  1. Select ALLPANLS and click OK.



  1. Click the Insert-Menu-Name button on the tool bar to display the Insert Name panel.



The Select Menu Items panel appears.



  1. Select the Menu you created.



  2. Click the Select All button.

  3. Click OK.

  4. Click the Save All button.


To Initiate a Step

  1. Open the Business Process folder.

  2. Double-click the Business Process that you created.



  3. Double-click on the Business Process to display the Activities.



  1. Click on the Step icon on the Business Process palette.

  2. Position the cursor on the worksheet and click the left-mouse button.



  1. Click the right-mouse button to open the Step Definition panel.

  2. Type in the Name and Icon Description.



  1. Click the Attribute button.



  1. Select the inputs from the drop-down lists.

  2. Click OK.

  3. Choose the Save As button.



Note You need to build a new step for each action.




Previous     Contents     Index     DocHome     Next     
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.

Last Updated November 03, 2000