Completing Actions Using the GP API

Use

The Guided Procedures (GP) framework completes actions when the underlying callable objects indicate that their processing is finished. Using the GP API, you can implement your own logic for triggering action completion outside the GP framework. For example, you can use such functionality if an error prevents the action from completing normally and the process from advancing as it should.

Prerequisites

You must have configured your project. For more information, see Setting Up Your Project .

Procedure

  1. Instantiate a
    com.sap.caf.eu.gp.context.api.
    IGPUserContext object.

    You need the IGPUserContext instance to authenticate the user who is trying to complete the action. In Web Dynpro you can create the object for the logged-in user. Another option is to use the security API and retrieve the user by his or her logon ID.

  1. Create an action completion data object.

    It is a com.sap.caf.eu.gp.process.rt.api.IGPActionCompletionData interface instance. The completion data object is used as a placeholder for all data that needs to be passed to the process context after the action has been completed - output parameters and result states, for example.

    The completion data object constructor requires the process and the task IDs, as well as a user context as parameters.

  1. If the action that you are completing exposes output parameters, you must fill the output structure with values, so that the output can be used in the next process steps if required.

    To retrieve the root output structure, use the completion data object's getOutputParameters() method. Then you can set the individual attribute values.

  1. Set the action completion status.

    You can end an action using one of the following statuses:

    • RESULT_STATE_COMPLETED_DONE_ONLY - indicates that the action has been completed; a result state is not set
    • RESULT_STATE_COMPLETED_RESULTSTATE - indicates that the action has been completed with a particular result state; if you use this status, you must explicitly set one of the result states available for the action
    • RESULT_STATE_COMPLETED_PROCESS_EXCEPTION - indicates that the action has been completed with a process exception; you can set this status to manage the process flow using the configured exception handler at block level. For more information, see Configuring Exception Handling in the Power User's Guide.
    • RESULT_STATE_COMPLETED_TECHNICAL_EXCEPTION - indicates that the action has been completed with an error that requires the process execution to be terminated; when completing the action with a technical exception, the output parameters are not stored in the process context.
  1. Set the action type.

    An action is either executed in the background, or exposes a user interface. For example, actions encapsulating composite forms are handled in the background, while those created for Web Dynpro callable objects are visual.

    The GP framework handles the two action types differently so you must set the type explicitly.

  1. Finally, to complete the action, you call the GP runtime manager's completeAction() method, passing the action completion data as a parameter.

Result

The action is completed, and the process execution either continues, or the process state is set to erroneous if you have completed the action with a technical exception.