Show TOC Start of Content Area

Procedure documentation Consuming a TU&C/C Web Service  Locate the document in its SAP Library structure

Use

The interface patterns stateless (XI 3.0 compatible), stateless, stateful, and TU&C/C assign the type of communication to be performed to each service interface.

A TU&C/C scenario (Tentative Update and Compensate or Confirm) could look like this:

The consumer sends requests to the server. He or she then performs preliminary changes in his/her system. Only when an order, for example, has definitely been made on the client side will the changes be retained in the database. If there is any error, the changes will be rolled back. This type of communication requires special procedures in the application.

In a TUCC scenario, several operations are required: At least one operation that undertakes the changes in the target system, an operation that confirms the changes if – for example – an order has definitely been placed, and an operation that triggers a rollback if a change has not been confirmed. Beforehand, an operation can be executed that does not make any changes in the target system, but merely reads the values, for example.

For more information, refer to Tentative Update & Confirm / Compensate (TU&C/C) in the section called Interface Pattern in the ES Repository documentation. 

Prerequisites

      You have generated a proxy (refer also to Generating a Consumer Proxy).

      You have configured the consumer proxy.

For more information, refer to Managing the UDDI Client in the NetWeaver Administrator and Configuring a Consumer Proxy in the SOA Manager.

      The role SAP_BC_WEBSERVICE_CONSUMER has been assigned to your user master record (refer to the section Authorizations).

Procedure

...

Create a program to call a service with the interface pattern TU&C/C.

 

Example Example

 

DATA: l_proxy       TYPE REF TO my_proxy_class,
      l_seq_prot    TYPE REF TO if_wsprotocol_sequence,
      l_seq_comp    TYPE REF TO if_ws_client_sequence,
      l_seq_conf    TYPE REF TO if_ws_client_sequence,
      l_lp_name     TYPE prx_logical_port_name,
      l_tucc_id     TYPE sysuuid_x16,
      l_output_comp TYPE my_comp_req_struct,
      l_output_m1   TYPE my_m1_req_struct,
      l_output_m2   TYPE my_m2_req_struct,
      l_output_conf TYPE my_conf_req_struct,
      l_input_m1    TYPE my_m1_resp_struct,
      l_input_m2    TYPE my_m2_resp_struct.

TRY.


* determine logical port:

    l_lp_name = ...

* create proxy object:
    CREATE OBJECT l_proxy
      EXPORTING
        logical_port_name = l_lp_name.


* get sequence protocol:
    l_seq_prot ?= l_proxy->get_protocol( if_wsprotocol=>sequence ).

* create TU&C/C ID:
    l_tucc_id = cl_system_uuid=>if_system_uuid_static~create_uuid_x16( ).

* register compensate method for reliable execution

* if the LUW fails (rollback, dump, shutdown). This needs to be done
* before sending any other messages of the LUW, as a shutdown
* could happen at any time:


    l_seq_comp = l_seq_prot->create_transient_sequence( on_failure = 'X' ).
    l_seq_comp->begin( ).
    l_seq_prot->set_client_sequence( l_seq_comp ).

    l_output_comp-my_comp_req_struct-id = l_tucc_id.
    l_proxy->compensate( output = l_output_comp ).

    l_seq_comp->end( ).


* call synchronous methods:

    l_output_m1-my_m1_req_struct-id = l_tucc_id.
    l_output_m1-...
= ...
    l_proxy->method1( EXPORTING output = l_output_m1
                      IMPORTING input  = l_input_m1 ).

    ...

    l_output_m2-my_m2_req_struct-id = l_tucc_id.
    l_output_m2-...
= ...
    l_proxy->method2( EXPORTING output = l_output_m2
                      IMPORTING input  = l_input_m2 ).

    ...

* register confirm method for reliable execution if the
* LUW succeeds (commit):


    l_seq_conf = l_seq_prot->create_transient_sequence( ).
    l_seq_conf->begin( ).
    l_seq_prot->set_client_sequence( l_seq_conf ).

    l_output_conf-my_conf_req_struct-id = l_tucc_id.
    l_proxy->confirm( output = l_output_conf ).

    l_seq_conf->end( ).


* success, commit the LUW:
    COMMIT WORK.

  CATCH cx_root.

* failure, rollback of LUW:
    ROLLBACK WORK.

ENDTRY.


For more information, refer to the section Programming With Sequences.

 

 

 

End of Content Area