API Repository

This chapter provides an overview of the PeopleSoft API Repository and discusses:

Click to jump to parent topicUnderstanding the PeopleSoft API Repository

This section discusses:

Click to jump to top of pageClick to jump to parent topicThe PeopleSoft API Repository

The PeopleSoft API Repository enables PeopleCode and third-party integrators to discover the internally available classes, methods, and properties that are provided by PeopleSoft for integration. The repository is useful to third-party integrators who integrate in a generic fashion: middleware providers, testing tool providers, and automated documentation providers.

The PeopleSoft API Repository is nota necessary interface for integrators who integrate at the business-rule level, such as integration with an expense report, and so on. Those integrators should use component interfaces.

The repository describes available PeopleSoft APIs and provides mechanisms to determine the classes that are available in the API, the properties of each class, the methods of a class (along with the required parameters), and information concerning which group a class belongs to (known as a namespace).

The process of determining information about the API is known as discovery. Third-party integrators use information found through discovery to drive generic integration tools.

The repository is divided into namespaces. Each namespace contains a collection of related classes. Example namespaces include "PeopleSoft," "ComponentInterface," "Trees," and "BusinessInterlinks".

A class defines a related set of methods and properties. Using the repository, you can determine the methods and properties that are available and that can be used on any object returned by a call to the PeopleSoft API. An instance of a class is known as an object.

A property is a data item of an object that has both a name and type (string, number, Boolean, and so on are examples of types). Some properties are used for inputting data to a class, some are used for getting data from a class, and some are used for both. Whether a property is used for input or output or both is known as usage.

A method is a function that you can call on an object. Methods have a name and a return type (string, number, Boolean, and so on). Methods also have a collection of arguments that must be set prior to invoking the method. Methods arguments have identical attributes to properties.

This diagram shows the different types of objects and collections instantiated from the repository:

Repository class hierarchy

Click to jump to top of pageClick to jump to parent topicExample of Accessing the Repository Using PeopleCode

This example gets information for the class ABS_HIST from the Namespace component interface and writes it to the file BC.TXT:

This is the complete code sample, followed by the flat file. The next section presents steps that explain each line.

Local ApiObject &MYSESSION; Local ApiObject &MYCI; Local string &OutTEXT; Local File &MYFILE; &MYSESSION = %Session; &MYFILE = GetFile("CI.txt", "A"); &NAMESPACES = &MYSESSION.Repository.Namespaces; &NAMESPACE = &NAMESPACES.ItemByName("CompIntfc"); &OutTEXT = "Namespace = " | &NAMESPACE.Name; &MYFILE.WriteLine(&OutTEXT); &CLASSES = &NAMESPACE.classes; &CLASS = &CLASSES.ItemByName("ABS_HIST"); &OutTEXT = " Class: " | &CLASS.Name; &MYFILE.WriteLine(&OutTEXT); &OutTEXT = " Methods"; &MYFILE.WriteLine(&OutTEXT); &METHODS = &CLASS.methods; For &K = 0 To &METHODS.Count - 1 &METHOD = &METHODS.item(&K); &OutTEXT = " " | &METHOD.name | ": " | &METHOD.Type &MYFILE.WriteLine(&OutTEXT); &ARGUMENTS = &METHOD.arguments; For &M = 0 To &ARGUMENTS.count - 1 &ARGUMENT = &ARGUMENTS.item(&M); &OutTEXT = " " | &ARGUMENT.name | ": " | &ARGUMENT.type; &MYFILE.WriteLine(&OutTEXT); End-For; End-For; &OutTEXT = " Properties"; &MYFILE.WriteLine(&OutTEXT); &PROPERTIES = &CLASS.properties; For &I = 0 To &PROPERTIES.count - 1 &PROPERTY = &PROPERTIES.item(&I); &OutTEXT = " " | &PROPERTY.name | ": " | &PROPERTY.type; &MYFILE.WriteLine(&OutTEXT); End-For; &MYFILE.Close();

The previous code produces the following flat file:

Namespace = CompIntfc Class: ABS_HIST Methods Get: Boolean Save: Boolean Cancel: Boolean Find: ABS_HIST GetPropertyByName: Variant Name: String SetPropertyByName: Number Name: String Value: Variant GetPropertyInfoByName: CompIntfcPropertyInfo Name: String Properties EMPLID: String LAST_NAME_SRCH: String NAME: String ABSENCE_HIST: ABS_HIST_ABSENCE_HISTCollection interactiveMode: Boolean getHistoryItems: Boolean componentName: String compIntfcName: String stopOnFirstError: Boolean propertyInfoCollection: CompIntfcPropertyInfoCollection createKeyInfoCollection: CompIntfcPropertyInfoCollection getKeyInfoCollection: CompIntfcPropertyInfoCollection findKeyInfoCollection: CompIntfcPropertyInfoCollection

The PeopleCode Example Explanation

This procedure goes through the PeopleCode example line by line.

To retrieve information from the API Repository:

  1. Get a session object.

    Before you can access the PeopleSoft API Repository, you have to get a session object. The session controls access to PeopleSoft, provides error tracing, enables you to set the runtime environment, and so on.

    &MYSESSION = %Session;

  2. Open the file.

    As this text will be written to a flat file, the next step is to open the file. If the file is already created, the new text is appended to the end of it. If the file hasn’t been created, the GetFile built-in function creates the file.

    &MYFILE = GetFile("CI.txt", "A");

  3. Get the namespace you want.

    Use the Namespaces property on the repository object to get a collection of available namespaces. We want to discover information about a component interface, so we specify CompIntfc in the ItemByName method to get that namespace. With ItemByName, you must specify a namespace that already exists. You’ll receive a runtime error if you specify one that doesn’t exist.

    &NAMESPACES = &MYSESSION.Repository.Namespaces; &NAMESPACE = &NAMESPACES.ItemByName("CompIntfc");

  4. Write the text to the file.

    Because all of the information discovered is being written to a file, the next step is to write text to the file. This code writes the string “Namespace”, followed by the name of the namespace, to the file.

    &OutTEXT = "Namespace = " | &NAMESPACE.Name; &MYFILE.WriteLine(&OutTEXT);

  5. Get the class that you want and write text to the file.

    Use the Classes property on the Namespace object to get a collection of all the available classes. We want to discover information about the component interface named ABS_HIST, so we specify that using ItemByName. Then we write that information to the file.

    &CLASSES = &NAMESPACE.classes; &CLASS = &CLASSES.ItemByName("ABS_HIST"); &OutTEXT = " Class: " | &CLASS.Name; &MYFILE.WriteLine(&OutTEXT);

  6. Get the methods and arguments, and write the information to the file.

    Use the Methods property on the Class object to get a collection of all the available methods. After you get each method and write the information to the file, loop through and find all of the arguments for the method, then write that information to the file.

    &OutTEXT = " Methods"; &MYFILE.WriteLine(&OutTEXT); &METHODS = &CLASS.methods; For &K = 0 To &METHODS.Count - 1 &METHOD = &METHODS.item(&K); &OutTEXT = " " | &METHOD.name | ": " | &METHOD.Type; &MYFILE.WriteLine(&OutTEXT); &ARGUMENTS = &METHOD.arguments; For &M = 0 To &ARGUMENTS.count - 1 &ARGUMENT = &ARGUMENTS.item(&M); &OutTEXT = " " | &ARGUMENT.name | ": " | &ARGUMENT.type; &MYFILE.WriteLine(&OutTEXT); End-For; End-For;

  7. Get the properties and write the information to the file.

    Use the Properties property on the Class object to get a collection of all the available properties. Write each property, with its type, to the file. At the end of the program, close the file.

    &OutTEXT = " Properties"; &MYFILE.WriteLine(&OutTEXT); &PROPERTIES = &CLASS.properties; For &I = 0 To &PROPERTIES.count - 1 &PROPERTY = &PROPERTIES.item(&I); &OutTEXT = " " | &PROPERTY.name | ": " | &PROPERTY.type; &MYFILE.WriteLine(&OutTEXT); End-For; &MYFILE.Close();

Click to jump to top of pageClick to jump to parent topicExample of Accessing the Repository by Using Visual Basic

This example gets information for the class ABS_HIST from the Namespace component interface.

Private Sub Command1_Click() '************************************************************** '* TacDemo: Example Repository Usage from Visual Basic '* '* Copyright (c) 1999 PeopleSoft, Inc. All rights reserved '************************************************************** ' Declare variables Dim oSession As New PeopleSoft_PeopleSoft.Session Dim oPSMessages As PSMessageCollection Dim oPSMessage As PSMessage ' Establish a PeopleSoft Session nStatus = oSession.Connect(1, "//PSOFTO070698:9001", "PTDMO", "PTDMO", 0) ' Enable error-handler On Error GoTo ErrorHandler ' Get a Component Interface "shell" Dim oNamespaces As NamespaceCollection Dim oNamespace As Namespace Dim oClasses As ClassInfoCollection Dim oClass As ClassInfo Dim oMethods As MethodInfoCollection Dim oMethod As MethodInfo Dim oArguments As PropertyInfoCollection Dim oArgument As PropertyInfo Dim oProperties As PropertyInfoCollection Dim oProperty As PropertyInfo Set oNamespaces = oSession.Repository.namespaces Set oNamespace = oNamespaces.ItemByName("ComponentInterface") Dim outText As String outText = "Namespace = " & oNamespace.Name & vbNewLine Set oClasses = oNamespace.classes Set oClass = oClasses.ItemByName("ABS_HIST") outText = outText & " Class: " & oClass.Name & vbNewLine outText = outText & " Methods" & vbNewLine Set oMethods = oClass.methods For k = 0 To oMethods.Count - 1 Set oMethod = oMethods.Item(k) outText = outText & " " & oMethod.Name & ": " & oMethod.Type & vbNewLine Set oArguments = oMethod.arguments For m = 0 To oArguments.Count - 1 Set oArgument = oArguments.Item(m) outText = outText & " " & oArgument.Name & ": " & oArgument.Type & vbNewLine Next Next outText = outText & " Properties" & vbNewLine Set oProperties = oClass.properties For k = 0 To oProperties.Count - 1 Set oProperty = oProperties.Item(k) outText = outText & " " & oProperty.Name & ": " & oProperty.Type & vbNewLine Next txtResults = outText ' Leave before we encounter the error handler Exit Sub ErrorHandler: If Err.Number = 1001 Then ' PeopleSoft Error Set oPSMessages = oSession.PSMessages If oPSMessages.Count > 0 Then For i = 1 To oPSMessages.Count Set oPSMessage = oPSMessages.Item(i) MsgBox (oPSMessage.Text) Next i oPSMessages.DeleteAll Else MsgBox ("PS Api Error. No additional information available from Session log") End If Else ' VB Error MsgBox ("VB Error: " & Err.Description) End If End Sub

Click to jump to parent topicRepository Properties

This section discusses the Repository properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicBindings

Description

The Bindings property returns a reference to a Bindings collection.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicNamespaces

Description

The Namespaces property returns a reference to a Namespaces collection.

This property is read-only.

Click to jump to parent topicBindings Collection Properties

This section discusses the Bindings collection properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of Bindings Properties objects in the Bindings collection object.

Note. All repository counts begin at zero, not one.

This property is read-only.

Example

&COUNT = &BINDINGS.Count;

See Also

Bindings Properties.

Click to jump to parent topicBindings Collection Methods

This section discusses the Bindings collection methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

The Item method returns a Bindings object that exists at the number position in the Bindings collection executing the method

Parameters

number

Specify the position number in the collection of the Bindings object that you want returned.

Returns

A reference to a Bindings object or NULL.

Example

For &N = 0 to &BINDINGS.Count - 1 &BINDING = &BINDINGS.Item(&N); /* do processing */ End-For;

Click to jump to parent topicBindings Properties

This section discusses the Bindings properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the object as a string.

This property is read-only.

Click to jump to parent topicBindings Methods

This section discusses the Bindings methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicGenerate

Syntax

Generate()

Description

This method is a reserved internal function and shouldn’t be used at this time.

Click to jump to parent topicNamespaces Collection Properties

This section discusses the Namespaces collection properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of Namespaces Properties objects in the Namespaces collection object.

Note. All repository counts begin at zero, not one.

This property is read-only.

Example

&COUNT = &NameC.Count;

See Also

Namespaces Properties.

Click to jump to parent topicNamespaces Collection Methods

This section discusses the Namespaces collection methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

The Item method returns a Namespaces object that exists at the number position in the Namespaces collection executing the method.

Parameters

number

Specify the position number in the collection of the Namespaces object that you want returned.

Returns

A reference to a Namespaces object or NULL.

Example

For &N = 0 to &NAMESPACES.Count - 1 &NAMESPACE = &NAMESPACES.Item(&N); /* do processing */ End-For;

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(name)

Description

The ItemByName method returns the item specified by name. Name is not case-sensitive.

Parameters

name

Specify the name of the Namespaces object that you want returned. This parameter takes a string value.

Returns

A reference to a Namespaces object or NULL.

Example

&NAMESPACE = &NAMESPACES.ItemByName("BusinessComponent");

Click to jump to parent topicNamespaces Properties

This section discusses the Namespaces properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicClasses

Description

This property returns a reference to a ClassInfo collection object.

This property is read-only.

Example

&CLASSC = &NAME.Classes;

See Also

ClassInfo Collection Properties.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the object as a string.

This property is read-only.

Click to jump to parent topicNamespaces Methods

This section discusses the Namespaces methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCreateObject

Syntax

CreateObject(classname)

Description

This method is a reserved internal function and shouldn’t be used at this time.

Click to jump to parent topicClassInfo Collection Properties

This section discusses the ClassInfo collection properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of ClassInfo Properties objects in the ClassInfo collection object.

Note. All repository counts begin at zero, not one.

This property is read-only.

Example

&COUNT = &InfoC.Count;

See Also

ClassInfo Properties.

Click to jump to parent topicClassInfo Collection Methods

This section discusses the ClassInfo collection methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

The Item method returns a ClassInfo object that exists at the number position in the ClassInfo collection executing the method.

Parameters

number

Specify the position number in the collection of the ClassInfo object that you want returned.

Returns

A reference to a ClassInfo object or NULL.

Example

For &N = 0 to &CLASSES.Count - 1 &CLASS = &CLASSES.Item(&N); /* do processing */ End-For;

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(name)

Description

The ItemByName method returns the item specified by name. Name is not case-sensitive.

Parameters

name

Specify the name of the ClassInfo object that you want returned. This parameter takes a string value.

Returns

A reference to a ClassInfo object or NULL.

Example

&CLASS = &CLASSES.ItemByName("ABS_HIST");

Click to jump to parent topicClassInfo Properties

This section discusses the ClassInfo properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicDocumentation

Description

This property doesn’t actually return all the documentation for the class, just a brief description of the class as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicMethods

Description

This property returns a reference to a MethodInfo collection object.

This property is read-only.

See Also

MethodInfo Collection Methods.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the object as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicProperties

Description

This property returns a reference to a PropertyInfo collection object.

This property is read-only.

See Also

PropertyInfo Collection Methods.

Click to jump to parent topicMethodInfo Collection Properties

This section discusses the MethodInfo collection properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of MethodInfo Properties objects in the MethodInfo collection object.

Note. All repository counts begin at zero, not one.

This property is read-only.

Example

&COUNT = &MethC.Count;

See Also

MethodInfo Properties.

Click to jump to parent topicMethodInfo Collection Methods

This section discusses the MethodInfo collection methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

The Item method returns a MethodInfo object that exists at the number position in the MethodInfo collection executing the method.

Parameters

number

Specify the position number in the collection of the MethodInfo object that you want returned.

Returns

A reference to a MethodInfo object or NULL.

Example

For &K = 0 To &METHODS.Count - 1 &METHOD = &METHODS.item(&K); &OutTEXT = " " | &METHOD.name | ": " | &METHOD.Type; &MYFILE.WriteLine(&OutTEXT); End-For;

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(name)

Description

The ItemByName method returns the item specified by name. Name is not case-sensitive.

Parameters

name

Specify the name of the MethodInfo object that you want returned. This parameter takes a string value.

Returns

A reference to a MethodInfo object or NULL.

Example

&METHOD = &METHODS.ItemByName("Save");

Click to jump to parent topicMethodInfo Properties

This section discusses the MethodInfo properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicArguments

Description

This property returns a reference to a PropertyInfo collection object.

This property is read-only.

See Also

PropertyInfo Collection Methods.

Click to jump to top of pageClick to jump to parent topicDocumentation

Description

This property doesn’t actually return all the documentation for the class, just a brief description of the class, as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the object as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicType

Description

This property returns the type of the method. Values include:

This property is read-only.

Click to jump to parent topicPropertyInfo Collection Properties

This section discusses the PropertyInfo collection properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicCount

Description

This property returns the number of PropertyInfo Properties objects in the PropertyInfo collection object.

Note. All repository counts begin at zero, not one.

This property is read-only.

Example

&COUNT = &PropC.Count;

See Also

PropertyInfo Properties.

Click to jump to parent topicPropertyInfo Collection Methods

This section discusses the PropertyInfo collection methods in alphabetical order.

Click to jump to top of pageClick to jump to parent topicItem

Syntax

Item(number)

Description

The Item method returns a PropertyInfo object that exists at the number position in the PropertyInfo collection executing the method.

Parameters

number

Specify the position number in the collection of the PropertyInfo object that you want returned.

Returns

A reference to a PropertyInfo object or NULL.

Example

For &K = 0 To &PROPERTIES.Count - 1 &PROPERTY = &PROPERTIES.item(&K); &OutTEXT = " " | &PROPERTY.name | ": " | &PROPERTY.Type; &MYFILE.WriteLine(&OutTEXT); End-For;

Click to jump to top of pageClick to jump to parent topicItemByName

Syntax

ItemByName(name)

Description

The ItemByName method returns the item specified by name. Name is not case-sensitive.

Parameters

name

Specify the name of the PropertyInfo object that you want returned. This parameter takes a string value.

Returns

A reference to a PropertyInfo object or NULL.

Example

&PROPERTY = &PROPERTIES.ItemByName(“GetHistoryItems”);

Click to jump to parent topicPropertyInfo Properties

This section discusses the PropertyInfo properties in alphabetical order.

Click to jump to top of pageClick to jump to parent topicDocumentation

Description

This property doesn’t actually return all the documentation for the class, just a brief description of the class, as a string. This property is read-only.

Click to jump to top of pageClick to jump to parent topicName

Description

This property returns the name of the object as a string.

This property is read-only.

Click to jump to top of pageClick to jump to parent topicType

Description

This property returns the data type. Values are:

This property is read-only.

Click to jump to top of pageClick to jump to parent topicUsage

Description

This property returns a number that describes in which direction the specified property (or argument) can be passed. The following table describes the valid values.

Value

Description

0

Can be passed into PeopleSoft API.

1

Can be passed out of PeopleSoft API.

2

Can be passed either into or out of PeopleSoft API.

This property is read-only.