Example: Writing, Configuring, and Executing a Service API ExtensionYou have working knowledge about SAP ME API and SAP MII Workbench.
You have downloaded the examples that are attached to SAP Note 1908404
and imported SAPMEServiceExt/PreCreateStart_CreateSFC
to SAP MII Workbench. You can copy and use this extension as a template. After copying, the SAP ME public API actions in this example must be configured with the correct site.
You write service API extensions in SAP MII Workbench
(see SAP MII Workbench).
In SAP MII Workbench
, create a new transaction.
Add a transaction property with the name input_xml
and data type xml
.
Set the value of the input_xml
property.
The value is set as follows based on the incoming request DTO of the service method being extended. For more information, see SAP ME Javadoc
at .
Example
Module: com.sap.me.production
Service: SfcStartService
Method: createAndStart
DTO: CreateAndStartSfcRequest
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<createAndStartSfcRequest xmlns="http://www.sap.com/me/com.sap.me.production">
<sfc>SFC1</sfc>
<operationRef>OperationBO:SITE,O1,A</operationRef>
<resourceRef>ResourceBO:SITE,DEFAULT</resourseRef>
<confirmed>false</confirmed>
<checkWorkCenterAssignment>true</checkWorkCenterAssignment>
<workStationRef>WorkstationBO:SITE,O,OPERATION_DEF</workStationRef>
</createAndStartSfcRequest>
Add a transaction property with the name output_xml
and data type XML
and select the Output Parameter
checkbox.
Set the value of the output_xml
property to the same value that was set in step 3 for the input_xml
property.
Create actions in the SAP MII transaction that are needed to carry out the custom logic. You can reference incoming values as needed in the input_xml
property.
If the SAP MII transaction needs to pass modifications to the incoming request back to the service, then create an action that modifies the output_xml
property.
Configure the security for the transaction by assigning the appropriate Reader Roles
. The SAP ME user that will trigger the transaction must have a role (for example, SAP_XMII_USER
) that is authorized to read the SAP MII transaction.
You configure service API extensions in Service Extension Maintenance
(see Service Extension Maintenance).
In SAP ME, in Service Extension Maintenance
, search for the target service method to be extended.
Select the method in the search results.
Choose New Extension
.
Select the execution point.
Enter a name for the extension.
Enter MII_TRANS_EXT
as the extension activity (see SAP MII Transaction Extension).
On the Options
tab page, enter the parent translation folder and the name of the transaction created above in the TRANSACTION_NAME
field.
Enter any parameters to be passed to the SAP MII transaction in the PARAMETERS
field as follows: material_name=M1;material_version=A
Each parameter assignment must be separated by a semicolon.
Save your entries.
To execute the extension, start an activity or plug-in in SAP ME that triggers the service extension method.
For example, adding an NC record calls createNC()
.
In addition, the public API web services can be used to invoke the service methods directly.
The SAP ME user that is executing the transaction must have a role (for example, SAP_XMII_USER
) that is authorized to read the SAP MII transaction.