Generating PeopleCode Using Drag-and-Drop

You can generate references to definitions using a drag-and-drop operation. You can also generate PeopleCode templates for accessing business interlinks and component interfaces.

This section discusses how to:

  • Generate references to definitions.

  • Generate PeopleCode for a business interlink.

  • Generate PeopleCode for a component interface.

  • Generate PeopleCode for a file layout.

When you drag definitions, such as menus, records, record fields, and pages, from a project into an open PeopleCode editor window, you generate a reference to the definition. For example, suppose your project contains a component named QEACTIVITY_GUIDE_1. If you drag the QEACTIVITY_GUIDE_1 component definition from the project into an open PeopleCode window, the word QEACTIVITY_GUIDE_1 prefixed with the keyword COMPONENT is written to the PeopleCode program in the place where you dragged the definition.

After you create a business interlink definition, you use PeopleCode to instantiate an interlink object and activate the interlink plug-in. This PeopleCode can be long and complex. Rather than write it directly, you can drag and drop the business interlink definition from the Application Designer Project view into an open PeopleCode edit pane. PeopleCode Application Designer analyzes the definition and generates initial PeopleCode as a template, which you can modify to suit your purpose.

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.*/

/* ===> Declare and instantiate: */
Local Interlink &QE_AE_NONSSL__1;
Local BIDocs &inDoc;
Local BIDocs &outDoc;
Local boolean &RSLT;
Local number  &EXECRSLT;
&QE_AE_NONSSL__1 =  GetInterlink(INTERLINK.QE_AE_NONSSL_BI);
.
.
.
.

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
    .
    .
    .
    .
    

After you create a file layout 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 file layout definition from the PeopleCode 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.

This example shows some of the code that is generated:

Function EditRecord(&REC As Record) Returns boolean ;
Local integer &E;

REM   &REC.ExecuteEdits(%Edit_Required + %Edit_DateRange + 
%Edit_YesNo + %Edit_TranslateTable + %Edit_PromptTable + 
%Edit_OneZero);

   &REC.ExecuteEdits(%Edit_Required + %Edit_DateRange + 
%Edit_YesNo + %Edit_OneZero);
   If &REC.IsEditError Then
      For &E = 1 To &REC.FieldCount
         &MYFIELD = &REC.GetField(&E);
         If &MYFIELD.EditError Then
            &MSGNUM = &MYFIELD.MessageNumber;
            &MSGSET = &MYFIELD.MessageSetNumber;
            &LOGFILE.WriteLine("****Record:" | &REC.Name | ", 
Field:" | &MYFIELD.Name );
            &LOGFILE.WriteLine("****" | MsgGet(&MSGSET, 
&MSGNUM, ""));
         End-If;
      End-For;
      Return False;
   Else
      Return True;
   End-If;
End-Function;
.
.
.
.