Generating PeopleCode for a Component Interface

After you create a component interface definition, you can use PeopleCode to access it. This PeopleCode can be long and complex. Rather than write it directly, you can drag and drop the component interface definition from the Application Designer Project view into an open PeopleCode edit pane. Application Designer analyzes the definition and generates initial PeopleCode as a template, which you can modify to meet your requirements.

The following is a snippet of the code that is generated:

/* ===>
This is a dynamically generated PeopleCode template to be 
used only as a helper to the application developer.
You need to replace all references to '<*>' OR default values 
with references to PeopleCode variables and/or a Rec.Fields. */
Local ApiObject &oSession;
Local ApiObject &oCurrencyCdCi;
Local ApiObject &oPSMessageCollection;
Local ApiObject &oPSMessage;
Local File &LogFile;
Local number &i;
Local String &strErrMsgSetNum, &strErrMsgNum, &strErrMsgText, 
&strErrType;
.
.
.

You can also access a component interface using the component object model (COM). You can automatically generate a Visual Basic template, a Java template, or a C template, similar to the PeopleCode template, to begin.

To generate a template:

  1. Open a component interface in Application Designer.

  2. Right-click anywhere in the open component interface and select a template type.

    You must save the component interface before generating the template.

    When the template is successfully generated, a message appears with the full path and name of the file containing the template.

  3. Open the generated file and modify the source code to meet the needs of your application.

    The following is the initial code snippet that is generated for a Visual Basic template:

    Option Explicit
    '===>
    'This is a dynamically generated Visual Basic template to be 
    'used only as a helper to the application developer.
    'You need to replace all references to '<*>' OR default 
    'values with  references to Visual Basic variables.
    
    Dim oSession As PeopleSoft_PeopleSoft.Session
    
    Private Sub ErrorHandler()
    '***** Display PeopleSoft Error Messages *****
    If Not oSession Is Nothing Then
       If oSession.ErrorPending Or oSession.WarningPending Then
          Dim oPSMessageCollection As PSMessageCollection
          Dim oPSMessage As PSMessage
          Set oPSMessageCollection = oSession.PSMessages
          Dim i As Integer
          For i = 1 To oPSMessageCollection.Count
             Set oPSMessage = oPSMessageCollection.Item(i)
             Debug.Print "(" & oPSMessage.MessageNumber & "," & 
    oPSMessage.MessageSetNumber & ") : " & oPSMessage.Text
          Next i
          '***** Done processing messages in the collection; 
          '***** OK to delete *****
          oPSMessageCollection.DeleteAll
       End If
    End If
    End Sub
    .
    .
    .
    .