• No results found

Creating a Purchase Order and Sales Order

In document Bit430 en Col74 (Page 173-185)

Transactions for Administration of Processes in the Business Process Engine

Exercise 8: Creating a Purchase Order and Sales Order

Exercise Objectives

After completing this exercise, you will be able to:

• Use the switch step

• Use the fork step

• Send a message to your alert inbox

Business Example

You want to create a purchase order in the MM system and a sales order in the SD system. You want to do this in parallel, using an asynchronous call. The used message is list. In this case, use a direct routing and enter the send context 'PurchaseOrder' for the message to MM and 'SalesOrder' for the message to SD.

You request a transport acknowledgment for the message to MM and an application acknowledgment for the message to SD. Both systems send you a response in the messages po_resp and so_resp. If creation was not successful, the status field will contain the value ERROR. Save this field in your process (element status_so or status_po).

If creation could not be completed successfully in one of the two systems, send an asynchronous request to both to delete the objects. Use the send contexts CancelPO and CancelSO for the receiver determination for systems MM and SD. The message for the message to MM is po_resp (references interface crea_po_abstract). The message for the message to SD is so_resp (references interface crea_so_abstract).

In both cases, request an application acknowledgment. After cancelation, trigger an alert that the objects could not be created and that the process will be canceled.

Cancel the process.

To create an error situation in the purchase order, CustomerNo must contain a “Y”. To create an error in the sales order, CustomerNo must contain a “Z.”

Task:

Define a new block to create the sales order and purchase order. Send the sales order to Airline_group_one and the purchase order to Airline_group_two. Only if both orders are created successfully will the process be processed further. Otherwise an alert is thrown, the process instance is canceled, and the orders in both systems are canceled.

1. The scenario takes place in a new block. Add block step

CreateSalesAndPurchaseOrdersBlock to your integration process.

2. You want to create a sales order and a purchase order in two systems in parallel.

You need a fork step.

Insert a step createparallel with step type Fork with two branches into your block step CreateSalesAndPurchaseOrdersBlock.

3. The MM and SD systems send back messages when the orders are created.

These messages must be correlated with the corresponding send steps, so you have to define a correlation. The customer number is used for the correlation.

Create the correlation CorrOrder. Add correlation container Cust with type xsd:string. The involved messages are list_abstract, crea_po_abstract, and crea_so_abstract. In the Properties area, assign CustNo to the correlation container element Cust.

4. Now you can create the send step for the purchase order that activates the correlation. The receiver (business system Airline_group_two) is determined using a condition defined in the receiver determination on the Integration Server.

The condition is determined using the context property PurchaseOrder.

Create asynchronous send step SendPO in the first branch. Enter

PurchaseOrder for the Send Context property. The later routing depends on this send context. Message is list, Acknowledgment is Transport and the correlation CorrOrder must be activated.

5. The MM system sends back a message when the purchase order is defined, so you have to define a container element for the response message.

Create a container element po_resp in the CreateSalesAndPurchase-OrdersBlockcontainer. This is an abstract interface of type crea_po_abstract.

6. Define a receive step for the message that is sent by the MM system once it has created the purchase order.

7. You want to extract one single field of the asynchronous response message: the Status field. This field tells you whether the purchase order can be created or not, so you need a container element for this status field.

Create a container element status_po for container CreateSalesAndPurchase-OrdersBlock. Category is Simple Type and Type is xsd:string.

8. Use a container operation to extract the Status field from the message.

Insert container operation step getPOstatus after the receive step. Assign container element status_po. Expression is Interface Variable (po_resp)XPath→ SparePartLineItemList → Status.

9. Now you can create the send step for the sales order that activates the correlation.

The receiver (business system Airline_group_one) is determined using a condition defined in the receiver determination in the Integration Directory. The condition is determined using the context property SalesOrder.

Create an asynchronous send step SendSO in the second branch. Enter

SalesOrder for the Send Context property. This is important because the routing depends on this Send Context. Message is list, Acknowledgment is Application, and CorrOrder must be activated.

10. The SD system sends back a message when the sales order is defined. You have to define a container element for the response message.

Create a container element so_resp in the CreateSalesAndPurchase-OrdersBlockcontainer. It is an abstract interface of type crea_so_abstract.

11. Define a receive step for the message that is sent by the SD system once it has created the sales order.

Insert a receive step ReceiveSO after the send step. Message is so_resp, use correlation CorrOrder.

12. You want to extract one single field of the asynchronous response message: the Status field. This field tells you whether the sales order can be created or not.

You need a container element for this field.

Create a container element status_so for container CreateSalesAndPurchase-OrdersBlock. Category is Simple Type and Type is xsd:string.

13. Use a container operation to extract the Status field from the message.

Insert container operation step getSOstatus after the receive step. Assign container element status_so. Expression is Interface Variable (so_resp)XPath→ SparePartLineItemList → Status.

Continued on next page

14. In a new block, you want to check whether the purchase order and sales order have been created.

Add a second block step, AutomaticCompensation, in block CreateSalesAndPurchaseOrdersBlock.

15. If one of the orders could not be created, the Status field shows an ERROR.

In this case, delete the purchase order, the sales order, and cancel the process instance in branch 1 of the switch step.

Insert switch step CancelOrders into your block step AutomaticCompensation.

Branch 1 is executed if one of the container elements status_po or status_so contains the value ERROR.

16. To delete the orders, you need two send steps using the message po_resp with acknowledgment application (MM system) and the message so_resp with acknowledgment application (SD system).

Create the asynchronous send step Cancel_PO in branch 1. Enter CancelPO for the Send Context property. Message is po_resp, Acknowledgment is Application.

17. To delete the orders, you need two send steps using the message po_resp with acknowledgment application (MM system) and the message so_resp with acknowledgment application (SD system).

Create the asynchronous send step Cancel_SO in branch 1. Enter CancelSO for the Send Context property. Message is so_resp, Acknowledgment is Application.

18. Insert control step AlertCancelOrders into branch 1 to throw an alert. The Alert Category is PROCESS_## and Alert Message could be Group ##: PO and SO canceled, process canceled, where ## stands for your group number.

19. The process itself is canceled using a control step.

Insert control step OrdersCanceled into branch 1 to cancel the process.

20. Check, save, and activate the integration process.

21. Send three messages to your integration process. For a positive outcome with no alerts, use customer number 1000 and materials 2000, 3000, and 4000.

If you use a customer number containing a Y, like 1000Y, the response message correlated to the CreatePurchaseOrderMessage from Airline_Group_Two

If you use a customer number containing a Z, like 1000Z, the response message for a sales order message indicates that an error occurred. Check the workflow log to make sure that in both cases the process is canceled and an alert has been thrown.

22. Check your alert inbox.

Solution 8: Creating a Purchase Order and Sales Order

Task:

Define a new block to create the sales order and purchase order. Send the sales order to Airline_group_one and the purchase order to Airline_group_two. Only if both orders are created successfully will the process be processed further. Otherwise an alert is thrown, the process instance is canceled, and the orders in both systems are canceled.

1. The scenario takes place in a new block. Add block step

CreateSalesAndPurchaseOrdersBlock to your integration process.

a) Drag a block step into your integration process.

b) Enter Name: CreateSalesAndPurchaseOrdersBlock.

2. You want to create a sales order and a purchase order in two systems in parallel.

You need a fork step.

Insert a step createparallel with step type Fork with two branches into your block step CreateSalesAndPurchaseOrdersBlock.

a) Drag a fork step into the CreateSalesAndPurchaseOrdersBlock.

b) Enter Name: createparallel.

c) Enter value2in the Necessary Branches field.

3. The MM and SD systems send back messages when the orders are created.

These messages must be correlated with the corresponding send steps, so you have to define a correlation. The customer number is used for the correlation.

Create the correlation CorrOrder. Add correlation container Cust with type xsd:string. The involved messages are list_abstract, crea_po_abstract, and crea_so_abstract. In the Properties area, assign CustNo to the correlation container element Cust.

a) Add correlation CorrOrder in the Correlation List window.

b) Switch to the correlation editor.

c) Add correlation containerCustwith typexsd:string.

d) Add involved messageslist_abstract,crea_po_abstract, andcrea_so_abstract.

e) In the Properties area, assign Interface Variable→ XPath →

SparePartLineItemList→ CustNo to the correlation container element Cust.

4. Now you can create the send step for the purchase order that activates the correlation. The receiver (business system Airline_group_two) is determined using a condition defined in the receiver determination on the Integration Server.

The condition is determined using the context property PurchaseOrder.

Create asynchronous send step SendPO in the first branch. Enter

PurchaseOrder for the Send Context property. The later routing depends on this send context. Message is list, Acknowledgment is Transport and the correlation CorrOrder must be activated.

a) Drag a send step into the first branch.

b) Name: SendPO.

c) Mode: Asynchronous, Message islist, Acknowledgement : Transport.

d) Enter Send ContextPurchaseOrder.

e) Activate Correlation isCorrOrder. Assign the following to Cust:

Interface Variable (list)→ XPath → SparePartLineItemList → CustNo.

5. The MM system sends back a message when the purchase order is defined, so you have to define a container element for the response message.

Continued on next page

Create a container element po_resp in the CreateSalesAndPurchase-OrdersBlockcontainer. This is an abstract interface of type crea_po_abstract.

a) Add container element po_resp to the container list.

b) Category isAbstract Interfaceand Type iscrea_po_abstract.

c) Container: CreateSalesAndPurchaseOrdersBlock

6. Define a receive step for the message that is sent by the MM system once it has created the purchase order.

Insert a receive step ReceivePO after the send step. Message is po_resp, use correlation CorrOrder.

a) Insert the ReceivePO receive step after the SendPO send step.

b) Message ispo_resp, use correlationCorrOrder.

7. You want to extract one single field of the asynchronous response message: the Status field. This field tells you whether the purchase order can be created or not, so you need a container element for this status field.

Create a container element status_po for container CreateSalesAndPurchase-OrdersBlock. Category is Simple Type and Type is xsd:string.

a) Add container element status_po to the Container list.

b) Category isSimple Typeand Type isxsd:string. c) Choose container CreateSalesAndPurchaseOrdersBlock.

8. Use a container operation to extract the Status field from the message.

Insert container operation step getPOstatus after the receive step. Assign container element status_po. Expression is Interface Variable (po_resp)XPath→ SparePartLineItemList → Status.

a) Insert container operation step getPOstatus after the receive step.

b) Operation isAssignand Container Element isstatus_po. c) Expression is Interface Variable (po_resp) → XPath →

SparePartLineItemList→ Status.

9. Now you can create the send step for the sales order that activates the correlation.

The receiver (business system Airline_group_one) is determined using a

Create an asynchronous send step SendSO in the second branch. Enter

SalesOrder for the Send Context property. This is important because the routing depends on this Send Context. Message is list, Acknowledgment is Application, and CorrOrder must be activated.

a) Drag a send step into the second branch.

b) Step Name: SendSO.

c) Mode: Asynchronous, Message islist, Acknowledgement:

Application.

d) Enter send contextSalesOrder.

e) Activate Correlation isCorrOrder. Assign the following to Cust:

Interface Variable (list)→ XPath → SparePartLineItemList → CustNo.

10. The SD system sends back a message when the sales order is defined. You have to define a container element for the response message.

Create a container element so_resp in the CreateSalesAndPurchase-OrdersBlockcontainer. It is an abstract interface of type crea_so_abstract.

a) Add container element so_resp to the container list.

b) Category isAbstract Interfaceand Type iscrea_so_abstract.

c) Container: CreateSalesAndPurchaseOrdersBlock

11. Define a receive step for the message that is sent by the SD system once it has created the sales order.

Insert a receive step ReceiveSO after the send step. Message is so_resp, use correlation CorrOrder.

a) Insert receive step ReceiveSO after the send step SendSO.

b) Message isso_resp, use correlationCorrOrder.

12. You want to extract one single field of the asynchronous response message: the Status field. This field tells you whether the sales order can be created or not.

You need a container element for this field.

Create a container element status_so for container CreateSalesAndPurchase-OrdersBlock. Category is Simple Type and Type is xsd:string.

a) Add container element status_so to the container list.

b) Category isSimple Typeand Type isxsd:string.

c) Choose container CreateSalesAndPurchaseOrdersBlock.

Continued on next page

13. Use a container operation to extract the Status field from the message.

Insert container operation step getSOstatus after the receive step. Assign container element status_so. Expression is Interface Variable (so_resp)XPath→ SparePartLineItemList → Status.

a) Insert container operation step getSOstatus after the receive step.

b) Operation isAssignand Container Element isstatus_so.

c) Expression is Interface Variable (so_resp) → XPath → SparePartLineItemList→ Status.

14. In a new block, you want to check whether the purchase order and sales order have been created.

Add a second block step, AutomaticCompensation, in block CreateSalesAndPurchaseOrdersBlock.

a) Drag a block step into your integration process.

b) Enter Step NameAutomaticCompensation.

15. If one of the orders could not be created, the Status field shows an ERROR.

In this case, delete the purchase order, the sales order, and cancel the process instance in branch 1 of the switch step.

Insert switch step CancelOrders into your block step AutomaticCompensation.

Branch 1 is executed if one of the container elements status_po or status_so contains the value ERROR.

a) Drag a switch step into the block AutomaticCompensation.

b) Enter Step NameCancelOrders.

c) Open the condition editor. Select the simple variables status_po and status_so and compare these with the string ERROR. Both simple variables are connected by an OR.

16. To delete the orders, you need two send steps using the message po_resp with acknowledgment application (MM system) and the message so_resp with acknowledgment application (SD system).

Create the asynchronous send step Cancel_PO in branch 1. Enter CancelPO for the Send Context property. Message is po_resp, Acknowledgment is Application.

a) Drag a send step into branch 1.

Name it Cancel_PO.

b) Mode isAsynchronous, Message ispo_resp, and Acknowledgment isApplication.

c) Enter Send Context CancelPO.

17. To delete the orders, you need two send steps using the message po_resp with acknowledgment application (MM system) and the message so_resp with acknowledgment application (SD system).

Create the asynchronous send step Cancel_SO in branch 1. Enter CancelSO for the Send Context property. Message is so_resp, Acknowledgment is Application.

a) Drag a send step into branch 1.

Name it Cancel_SO.

b) Mode isAsynchronous, Message isso_resp, and Acknowledgment isApplication.

c) Enter Send Context CancelSO.

18. Insert control step AlertCancelOrders into branch 1 to throw an alert. The Alert Category is PROCESS_## and Alert Message could be Group ##: PO and SO canceled, process canceled, where ## stands for your group number.

a) Drag a control step into branch 1.

Name itAlertCancelOrders.

b) The Alert Category isPROCESS_##(## is your group number).

c) Alert Message could bePO and SO order canceled, process canceled.

19. The process itself is canceled using a control step.

Insert control step OrdersCanceled into branch 1 to cancel the process.

a) Drag a control step into branch 1.

Name itOrdersCanceled.

b) Action isCancel Process.

Continued on next page

20. Check, save, and activate the integration process.

a) To check the integration process, choose Integration Process→ Check. The results are displayed in the Processing Log section of the process editor.

b) Save the integration process by choosing Save and go to the Change List.

There you have to activate your integration process.

21. Send three messages to your integration process. For a positive outcome with no alerts, use customer number 1000 and materials 2000, 3000, and 4000.

If you use a customer number containing a Y, like 1000Y, the response message correlated to the CreatePurchaseOrderMessage from Airline_Group_Two indicates that an error occurred.

If you use a customer number containing a Z, like 1000Z, the response message for a sales order message indicates that an error occurred. Check the workflow log to make sure that in both cases the process is canceled and an alert has been thrown.

a) Send three messages using your HTTP client.

b) Use transaction SXMB_MONI. To select your message and call the workflow log, click entry PE.

22. Check your alert inbox.

a) Call the Runtime Workbench.

b) Choose Alert Inbox.

Caution: Your user must be assigned to the Alert Category (transaction ALRTCATDEF) to receive an alert in the alert inbox.

Exercise 9: Creating a Purchase Order and

In document Bit430 en Col74 (Page 173-185)