Scenario 2: Order create and query application processing with two flows

You must set the Transaction mode property appropriately on an SAPRequest node when you are processing by using separate message flows.

This scenario is one of two examples that illustrate the concepts that are described in SAP BAPI transaction commit; see also Scenario 1: Business partner and relationship processing in a single flow.

In this scenario, two message flows are used to issue a sales order create and a subsequent sales order check by using two BAPI calls:

BAPI_SALESORDER_CREATEFROMDAT2
BAPI_SALESORDER_GETSTATUS
For example, a user queries an order after a purchase has been made by using a Web-based application. The result of the query is closely linked to the asynchronous or synchronous behavior of the order creation steps carried out by the external SAP server.
In the following asynchronous example (the default behavior), the query might fail and the user receives a negative acknowledgment for the order that has been created.
Diagram showing how the SAPRequest nodes in a message flow interact with the SAP server. The diagram is described in the following steps.
BAPI Create Order message flow
A1. An application triggers the transactional message flow that creates a sales order.
A2. The SAPRequest node submits an order creation and returns the order registration number. The commit happens when the message flow completes because the node participates in a message flow level transaction.
A3. The MQReply node puts an MQ message on the output queue pending transactional commit.
A4. The message flow completes and the integration node begins to commit all the resources involved in that flow, including SAP and the MQReply node call. The order number is available to the user application.

The following two processes occur simultaneously, and effectively race each other to complete.
SAP Commits processing asynchronously BAPI Get Order Status message flow
B1. The SAP commit begins. C1. A request for an order status query is made.  
B2. The SAP commit completes. C2. The SAPRequest node requests the order.  

Because of the asynchronous commit, two outcomes are possible when the order is queried:
  • The order is not found because SAP has not completed the order commit.
  • The order is found but only if SAP has committed the order before the query is made.
You can avoid this uncertainty by configuring the adapter to perform the commit synchronously; set the Use wait parameter before calling BAPI commit parameter on the adapter connection wizard to True, and set the Transaction mode property on the SAPRequest node to Yes.
In the following synchronous example, the query is successful and the user receives a positive acknowledgment for the order that has been created.
Diagram showing how the SAPRequest nodes in a message flow interact with the SAP server. The diagram is described in the following steps.
BAPI Create Order message flow
1. An application triggers the transactional message flow that creates the sales order.
2. The SAPRequest node submits an order creation and returns the order registration number. The commit happens when the message flow completes because the node participates in a message flow level transaction.
3. The MQReply node puts an MQ message on the output queue pending transactional commit.
4. The message flow completes and the integration node begins to commit all the resources involved in that flow, including SAP.
SAP Commits processing synchronously
5. The SAP commit begins.
6. The SAP commit completes.
7. The adapter hands control back to the integration node.
8. The MQReply node call is committed, therefore the order number is available to the user application.
BAPI Get Order Status message flow
9. A request for an order status query is made.
10. The SAPRequest node requests the order.

SAP has completed the order commit; therefore, the order query is successful.