Show TOC Start of Content Area

Procedure documentation Registering a New Callable Object Type  Locate the document in its SAP Library structure

Use

To use your new callable object type in Guided Procedures (GP), you need to register it in the framework first. This includes it in the list of available types, from which you can select when you are creating a callable object in GP, and also enables the implementation to interact with the framework.

You can implement the functions to register or remove a callable object type in an arbitrary Java component. For example, you may choose to create a Web Dynpro application, which provides a user interface where you can enter:

·        The parameters for the new callable object type, and then register it

·        The name of an existing type and remove it from the registry

You can implement similar functionality using a servlet.

Procedure

1. Set Up Your Project

...

       1.      Decide which development component type you need to use and create the relevant development component project.

For example, if you choose to implement a Web Dynpro application, create a new Web Dynpro type development component project.

       2.      Add a build-time dependency to the following DC:

¡        caf/eu/gp/api (public part external)

       3.      Create a component of the relevant type – that is, a Web Dynpro component, or a Java class.

2. Implement the Logic to Register a Type

       4.      In your component, get a reference to an instance of com.sap.caf.eu.gp.co.type.api.IGPCallableObjectTypeManager.

To do it, use the com.sap.caf.eu.go.co.type.api.GPCallableObjectTypeFactory.

Example

Getting a Reference to the IGPCallableObjectTypeManager

IGPCallableObjectTypeManager typeMan =

         GPCallableObjectTypeFactory.getCallableObjectTypeManager();

       5.      Check whether the callable object type registry also contains a type with the name that you want to use for your callable object type.

Example

Checking if the ID for the CO Type Exists

try {

      IGPCallableObjectType co = typeMan.getCallableObjectType("myType");

      if (co == null) {

...

       6.      If your check returns null, you can proceed with creating an instance of com.sap.caf.eu.gp.co.type.api.IGPCallableObjectType. This is the object that you register in the type registry.

You instantiate the object using the method createCallableObjectType() of the callable object type manager. The parameters of the method are explained in the code sample below.

 Note

For a resource accessor in Java implementations you can use the com.sap.caf.eu.gp.co.api.GPStandardResourceAccessor. You must create your own class that extends the GPStandardResourceAccessor, and put it in the same package as the implementation classes together with the resource bundle (a file with the extension .properties).

In Web Dynpro, you can use the com.sap.caf.eu.gp.co.api.GPWebDynproResourceAccessor.

The use of these resource accessors is described in Implementing a Callable Object for Background Execution and Implementing a Web Dynpro Callable Object.

Example

Creating an Instance of IGPCallableObjectType

//the unique ID for the new type in the registry

String typeName = "myType";

//the type icon name; you define it as a relative path using the standard Web Dynpro APIs

String iconName = "myType.gif";

//a flag indicating if the type defines a CO for background execution

boolean flagIsBackground = false;

//the default permission for the CO; when “ns” is used, no default permission is assigned and the GP Administrator should set the relevant permission level using the GP administration tools

String defaultPermission = "ns";

 

//the name of the WD implementation class and the deployable unit (Web Dynpro DC) for the design-time part

String wdComponentName = "com.sap.test.cotype.NewCOType";

String wdDevComponentName = "sap.com/caf~test~cotype";

 

//the type of the runtime container that runs the implementation

int containerType = IGPCallableObjectType.RUNTIME_CONTAINER_TYPE_WD;

 

//the name of the WD implementation and the deployable unit (Web Dynpro DC) for the runtime part

String containerCompName = "com.sap.test.cotype.NewCOType";

String containerDevCompName ="sap.com/caf~test~cotype";

 

//the JNDI path to the container session bean for containers of type RUNTIME_CONTAINER_TYPE_SESSION_BEAN

String containerJNIName = "";

           

//the resource accessor and the text and description keys for the CO type; if the relevant text is not available, the keys are displayed

GPWebDynproResourceAccessor accessor=null;

String textKey = "NAME";

String descriptionKey = "DESCRIPTION";

 

//flags indicating which design-time screens are relevant for the CO type          

boolean requiresInputScreen = true;

boolean requiresOutputScreen = true;

boolean requiresConfigScreen = false;

 

//flag indicating whether the CO can be used as a service - for prefilling, for example

boolean isServicePattern = false;

 

IGPCallableObjectType cotype =

      typeMan.createCallableObjectType(

            typeName,

            iconName,

            flagIsBackground,

            defaultPermission,

            wdComponentName,

            wdDevComponentName,

            containerType,

            containerCompName,

            containerDevCompName,

            containerJNIName,

            accessor,

            textKey,

            descriptionKey,

            requiresInputScreen,

            requiresOutputScreen,

            requiresConfigScreen,

            isServicePattern);

       7.      Finally, you register your callable object type using the type manager method registerCallableObjectType().

Example

Registering the New Type

typeMan.registerCallableObjectType(cotype);

Result

Your callable object type is available in the type registry, and you can create object instances of this type using the standard GP wizard for creating callable objects.

If you need to remove the type from the registry, you can do it by calling the type manager method unregisterCallableObjectType().

 

End of Content Area