Show TOC Start of Content Area

Procedure documentation Implementing the Runtime for a New Callable Object Type  Locate the document in its SAP Library structure

Use

In the runtime part of the callable object type implementation, you enable communication with the framework at execution.

You read the parameters set to the physical callable object at design time, and also manage the status of the callable object in the process.

Procedure

1. Set Up Your Component

...

       1.      In your Web Dynpro development component project, create a new Web Dynpro component.

Note

You are not required to use the same DC that you used to implement the design time for the callable object type.

       2.      Add the interface com.sap.caf.eu.gp.co.rt.IGPVisibleCOContainer to the list of implemented interfaces.

The component instances are created for a single view and destroyed afterwards.

2. Implement the Method for Callable Object Execution

The IGPVisibleCOContaineradds the following methods to the component controller of the implementing Web Dynpro component:

·        initialize

The GP framework calls this method before the execute() method to create an object of type com.sap.caf.eu.gp.api.co.IGPVisibleCOContainerContext. Later on you can use this object in the execute method to retrieve details about the callable object. For example, using IGPVisibleCOContainerContext.getProcessor() method, you can retrieve the processor when the callable object execution completes.

·        execute

The GP framework uses the execute() method of the IGPVisibleCOContainer interface to trigger the execution of the relevant physical callable object.

       3.      Implement the execute() method of the component controller of the Web Dynpro component.

In this method, you must read the parameters that have been set to the physical callable object at design time. The definition of the logical and physical callable object, as well as the input data structure is provided by the framework.

The input data type is com.sap.caf.eu.gp.structure.api.IGPStructure. You can use the interface methods to retrieve the values of the parameters in a convenient form – for example, as a string, or integer.

In this method, you do not set any parameters to the physical callable object.

Example

Execution Method in the Component Controller

public void execute( com.sap.caf.eu.gp.co.api.IGPCallableObject callableObject, com.sap.caf.eu.gp.co.api.IGPPhysicalCallableObject physicalCallableObject, com.sap.caf.eu.gp.structure.api.IGPStructure inputData, boolean isExecuteState, boolean isTestMode, boolean isInProcess, com.sap.caf.eu.gp.process.api.IGPProcessRoleInstance processRole, com.sap.security.api.IUser initiator, java.lang.String processInstanceId, java.lang.String taskId )

  {

    //@@begin execute()

    IPublicNewCOTypeRTInterface.IContextElement ctxElement = wdContext.currentContextElement();

    String url = physicalCallableObject.getConfigProperty(NewCOTypeRT.PROPERTY_URL);

    ctxElement.setUrl(url);

...

  

    String attr = inputData.getAttributeAsString("parameter");

...

       4.      Implement a method for completing the execution of the callable object.

This method is called when you fire an event triggered from the user interface, and is handled in the component controller.

Example

Firing an Event for Completion in the Component Controller

public void complete()

  {

    //@@begin OnComplete(ServerEvent)

    wdThis.wdFireEventOnComplete();

    //@@end

  }

In the component controller, you handle the completion using the ExecutionComplete event. It requires the output structure of the callable object, the result state, as well as the process role instance that you get from the execute() method. You can construct the output data using the logical callable object from the execute() method. You can get the output parameters as an instance of IGPStructureInfo, and use the GPStructureFactory then create the output IGPStructureinstance.

Example

Handling the Completion Event in the Component Controller

public void OnComplete(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

  {

    //@@begin OnComplete(ServerEvent)

      ArrayList names = new ArrayList();

      names.add(NewCOTypeRT.RESULT_STATE_COMPLETE);

      wdThis.wdFireEventExecutionComplete(output, names, processRole);   

    //@@end

  }

       5.      Optionally, you can model the interaction with the framework using the following events:

¡        SetInProcess

Used for assigning the work item to the current user (this is an irreversible operation).

¡        ProcessException

Used for throwing a process exception that has been declared at design time.

¡        TechnicalException

Used for throwing a technical exception. You must use this event in cases when a severe error has occurred and further process execution must be cancelled.

3. Implement the User Interface

The runtime part of the callable object type implementation contains a single view. You must implement a UI element, such as a button, that enables users to complete the callable object execution. The implementation must trigger an event, which eventually is handled in the component controller by sending an ExecutionComplete event as shown above.

Example

Firing a Completion Event in the View

public void onActionComplete(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

  {

    //@@begin onActionComplete(ServerEvent)

    wdThis.wdGetNewCOTypeRTController().complete();

    //@@end

  }

Result

You have completed the implementation of your new callable object type.

Now you must register it in the GP framework.

More information: Registering a New Callable Object Type

End of Content Area