!--a11y-->
Interaction Using the Service Order
Instance 
You can support an interaction with the corresponding service order data in real time for the Web request creation by using the function modules of function group SAPLCRM_WEBREQ_ONLINE_PRICING. The modules of the function group can carry out the following functions when a request is being created:
· Make changes to the product assignment
· Select the product amount with the price calculation/price display
· Create request items
· Assign business partners
· Set an activity reason
· Set the system status

More functions are possible when using function module CRM_ORDER_MAINTAIN.
The data of a service order is available as temporary data in the form of a service order instance whilst the request is being made and is not just created in the CRM system after the request data has been sent. The request data is read with each round trip in which the service order instance is updated and transferred to the request form again. The data in the service order instance (for example, the GUID, assigned business partner, and so on) are copied when the corresponding service order is created.

Note that service order instances are only intended for placing the Web request, but cannot be used with service order processing.
You implement the function modules of function group SAPLCRM_WEBREQ_ONLINE_PRICING in the method calls of BAdI CRM_SERVICE_WEBREQ (BAdI for processing the form of the Web requests).
The following graphic is an example of a stateful BSP application: the price calculation/price display of a product during the request processing through to generating the service order when saving/sending the Web request:
...
...
1. The service order instance is generated with all corresponding fields and a GUID is created when the Web request is called in BAdI method FORM_ON_CREATION with module CRM_WR_INIT_ORDER. The GUID of the service order instance is read and transferred to the XML envelope.
2. The requester specifies the desired number (for example, three units) in the request for the product and transfers the data using Enter.
3. You use module CRM_WR_CHANGE_QUANTITY to change quantities and module CRM_WR_ORDER_MAINTAIN to update the price calculation based on the product defined in the service order instance in the BAdI BAdI FORM_ON_EVENT.
4. The accumulated price in the service order instance is read using module CRM_WR_GET_PRICE and is then transferred to the XML request data and displayed in the request form.
5. The existing data of the service order instance is read when the request form is saved and is then transferred to the service order.

Graphic: Price calculation when placing a request using the service order instance

Note that temporary data of a service order instance gets lost in stateless BSP applications. Because of this, you must create a new service order instance with each new round trip in stateless BSP applications using function module CRM_WR_CREATE_ORDER. For more information, see Setting as a Stateless or Stateful Web Request.
The following gives an overview of the function modules delivered. For more information, see the documentation on function group CRM_WEBREQ_ONLINE_PRICING and the corresponding function module documentation.
Function group CRM_WEBREQ_ONLINE_PRICING
|
Function module |
Use |
CRM_WR_INIT_ORDER |
Initialize service order for Web request |
CRM_WR_CREATE_ORDER |
Create service order instance |
CRM_WR_CREATE_ITEM |
Create standard Web request item |
CRM_WR_ADD_PARTNER |
Add partner to service order |
CRM_WR_ACT_REASON |
Set activity reason |
CRM_WR_CHANGE_PRODUCT |
Change product of first item |
CRM_WR_CHANGE_QUANTITY |
Change quantity of first item |
CRM_WR_ORDER_MAINTAIN |
Change process (update) |
CRM_WR_GET_PRICE |
Read accumulated price from service order |
CRM_WR_ADD_ITEM |
Create item with product and quantity |
CRM_WR_CHANGE_STATUS |
Change system status |
How a service order instance is used and implement the corresponding function modules is demontstrated in SAP_DEMO05 (Request with Price Determination).