Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

1.0 Overview


1.1 Scenario


The example used in this step-by-step guide of building a web service through SAP XI
exposes the function module SAP_WAPI_START_WORKFLOW as a web service, which when executed
starts the WS20000391 (Schedule Manager) workflow to start a job.


1.2 Steps Overview


  • Identify the import/export parameters of the workflow and the function module

  • Design interface in SAP XI

  • Configure interface in SAP XI

  • Create web service in SAP XI

  • Test the web service using Microsoft Office InfoPath 2003

  • Verify the test results


1.3 Prerequisites



    1. Basic understanding of SAP R/3 and SAP XI

    2. Working SAP R/3 or ECC system, and Exchange Infrastructure 3.0 and up


2.0 Identifying Required Parameters


2.1 Parameters for the Workflow


Display the template for workflow WS20000391 and view the container through transaction PFTC. Identify the required import parameters for this workflow which are marked with exclamation marks. JobName, StepsReports and StepsReportVariants are the required parameters for this workflow.


2.2 Parameters for the Function Module


Display the function module SAP_WAPI_START_WORKFLOW in function builder through transaction SE37.  View its import information under the Import tab.  Identify TASK, LANGUAGE, DO_COMMIT as the necessary import parameters for this scenario.


Display the Tables tab for the function module to identify the necessary table parameter INPUT_CONTAINER for this scenario.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img4.JPG|height=151|alt=image|width=563|src=htt...!


Display the table properties for the SWR_CONT type associated with INPUT_CONTAINER and note its components ELEMENT and VALUE.
 


3.0 Designing the Interface in XI


3.1 Integration Repository


Start up the homepage for the menu for XI tools using transaction SXMB_IFR.  This can also be started with a manually entered URL in the browser.  Click on Integration Repository under Integration Builder: Design to start designing the interface.  A list of objects is displayed on th left when the integration repository window starts up. Expand the object that the interface will be created under, and then expand Imported Objects.  Right click on RFC under Imported Objects to import the function module.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img6.JPG|height=364|alt=image|width=264|src=htt...!



From the list of available objects displayed, select the desired function module, in this case SAP_WAPI_START_WORKFLOW, and click Continue to finish importing the object.


3.2 Activating Changes


Save and activate changes now and then to prevent from losing the work.  Click on the Change Lists tab next to the Objects tab in the repository, and the change list for the user will be displayed.  Navigate to the Standard Change List that contains the recent changes to be activated.  Right click on Standard Change List and click Activate.  Repeat this process throughout the design and configuration process within XI.





3.3 Deifning Request and Response Data Types


In the Objects tab, expand the namespace being worked with. Navigate to Data Types under Interface Objects. Right click on Data Types and click New to create a new data type. Name the data type correspondingly and save it.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img11.JPG|height=383|alt=image|width=283|src=ht...!


Define a new data type each for request and response. The request data type for this interface is named StartWorkflowSchJob_REQ_DT. Name the response data type correspondingly as well.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img12.JPG|height=119|alt=image|width=421|src=ht...!


Using the Type Definition tools, add necessary elements to the request and response data type structures.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img13.JPG|height=291|alt=image|width=522|src=ht...!


3.4 Creating Request and Response Message Types


Navigate to Message Types under Interface Objects under the same namespace. Right click on Message Types and click New to create a new message type. Name the message types correspondingly for request and response; StartWorkflowSchJob_REQ_MT and StartWorkflowSchJob_RESP_MT.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img17.JPG|height=239|alt=image|width=600|src=ht...!


In the Edit Message Type window after creating the message type, specify the corresponding data type that will be used for the specific message type by clicking on the Display Input Help button. The structure of the request data type is displayed in the request message type, and the structure of the response data type is displayed in the response message type.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img19.JPG|height=400|alt=image|width=547|src=ht...!


3.5 Defining a Fault Message Type


Navigate to Fault Message Types under the same namespace and right click on it to create a new fault message type for the interface. The fault message type for this scenario is named StartWorkflowSchJob_FAULT_MT. Save and activate changes.


3.6 Defining the Message Interface


Navigate to Message Interfaces under Interface Objects under the same namespace in the integration repository. Right click on it to create a new message interface. Name the message interface correspondingly, in this case it is named StartWorkflowSchJob_MI.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img23.JPG|height=119|alt=image|width=486|src=ht...!


Specify the interface to be outbound and synchronous in the Attributes section under the message interface Definition. Specify the request message type for the output message, the response message type for the input message and the fault message type for the fault message type by clicking on each Input Help button to the right of the input fields.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img24.JPG|height=400|alt=image|width=600|src=ht...!


This conclude the creation of interface objects for this interface in the integration repository.  Next mapping objects will be defined in the integration repository for the messages.


3.7 Creating a Message Mapping for the Inbound Request


Navigate to Message Mappings under Mapping Objects in the same namespace in integration repository.  Right click on Message Mappings and click on New to create a new message mapping.  Name the message mapping correspondingly. The request message mapping for this scenario is named StartWorkflowSchJob_REQ_MM. Specify the source and target messages for the message mapping and perform desired mapping using the graphical mapping tool. Click on Select Message in the Enter a source message section to display the list of options to choose from.  Do the same in the Enter a target message section when selecting a target message.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img26.JPG|height=400|alt=image|width=600|src=ht...!


Choose StartWorkflowSchJob_REQ_MT as the source message type for the request message mapping, and choose the imported function module SAP_WAPI_START_WORKFLOW as the target message.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img27.JPG|height=400|alt=image|width=396|src=ht...!

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img28.JPG|height=335|alt=image|width=396|src=ht...!



The structures of the source and target messages specified are displayed in the left and right sections in the Design tab of the message mapping. Save the message mapping that has been defined so far to prevent from losing the progress. The RFC message structure for SAP_WAPI_START_WORKFLOW is displayed on the right hand side of the Design tab in the request message mapping as the target message.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img29.JPG|height=370|alt=image|width=384|src=ht...!


Map the source elements to the target elements based on desired conditions and values. Recall the required import parameters that were identified for the function module in section 2.2. Those are the parameters that correspond to the elements in the target message that should be mapped for the request message mapping.

Map the constant "WS20000391" that specifies the workflow to the element TASK in the target message.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img30.JPG|height=315|alt=image|width=429|src=ht...!


Map the constant "X" to the DO_COMMIT element in the target
message.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img31.JPG|height=316|alt=image|width=429|src=ht...!


Map the contant "EN" for English to the LANGUAGE element in the target message.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img32.JPG|height=318|alt=image|width=388|src=ht...!


The INPUT_CONTAINER table parameter for the SAP_WAPI_START_WORKFLOW function module has three container elements. Therefore, the subtree of the INPUT_CONTAINER node in the target message must be duplicated twice to represent the three rows of the table. Right click on the item subtree under INPUT_CONTAINER in the target message and click on Duplicate Subtree. Repeat this step one other time so that INPUT_CONTAINER has three of the same Item subtrees.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img33.JPG|height=400|alt=image|width=388|src=ht...!



Map the names of the required import parameters of the workflow Schedule Job identified in step 2.1 to each ELEMENT under each item subtree. The third ELEMENT would be mapped with the constant "StepsReportVariants".

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img34.JPG|height=314|alt=image|width=289|src=ht...!



Map the node StartWorkflowSchJob_REQ_MT from the source message to the INPUT_CONTAINER node and each of the item subnodes. Each VALUE under each item subtree is mapped with each element in the source message. The second VALUE is mapped with ProgramName.


3.8 Creating a Message mapping for the Outbound Response


Navigate to Message Mappings under Mapping Objects in the same namespace in integration repository.  Right click on Message Mappings and click on New to create a new message mapping.  Name the message mapping correspondingly.  Specify the source and target messages for the message mapping and perform desired mapping using the graphical mapping tool. The source message is the function module and the target message is the response message StartWorkflowSchJob_RESP_MT.
Map the source elements with the same names as the target elements to the target elements.


!https://weblogs.sdn.sap.com/weblogs/images/251698435/img37.JPG|height=399|alt=image|width=600|src=ht...!


3.9 Defining the Interface Mapping


Navigate to Interface Mappings under Mapping Objects in the same namespace in integration repository.  Right click on Interface Mappings and click New to create a new interface mapping for the interface.  Name the mapping accordingly.  Specify the source and target interfaces, and select the correct request and response message mappings. The interface mapping for the SOAP interface that is being defined in XI is named StartWorkflowSchJob_IM.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img38.JPG|height=143|alt=image|width=471|src=ht...!



Select StartWorkflowSchJob_MI for the source interface of the interface mapping.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img39.JPG|height=400|alt=image|width=600|src=ht...!



Select the imported function module SAP_WAPI_START_WORKFLOW as the target interface for the interface mapping.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img40.JPG|height=377|alt=image|width=598|src=ht...!



Specify the request message mapping StartWorkflowSchJob_REQ_MM as the request mapping program.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img41.JPG|height=361|alt=image|width=599|src=ht...!


Specify the response message mapping StartWorkflowSchJob_RESP_MM for the response mapping program. Save and activate all changes.  The design of the interface in XI Integration Repository is done.


4.0 Configuring the Interface in XI


4.1 Configuration Wizard


Start up the homepage for the menu for XI tools.  This can also be started with a manually entered URL in the browser.  Click on Integration Directory under Integration Builder: Configuration to start designing the interface.  A list of scenarios is displayed on the left when the integration directory window starts up. Click on the Configuration Wizard icon to start the configuration wizard.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img43.JPG|height=387|alt=image|width=474|src=ht...!



Choose Internal Communication for message exchange within the same system landscape.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img44.JPG|height=328|alt=image|width=581|src=ht...!



Specify the appropriate service and interface for the sender.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img45.JPG|height=399|alt=image|width=593|src=ht...!



Specify the appropriate service and interface for the receiver.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img46.JPG|height=400|alt=image|width=592|src=ht...!



Name the communication channel accordingly to define how the SOAP adapter will process the inbound message.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img47.JPG|height=400|alt=image|width=592|src=ht...!



Use the default receiver determination configuration.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img48.JPG|height=215|alt=image|width=576|src=ht...!



Use the default interface determination configuration.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img49.JPG|height=400|alt=image|width=589|src=ht...!



Name the communication channel for the receiver accordingly.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img50.JPG|height=400|alt=image|width=595|src=ht...!



The scenario in this case is named StartWorkflowSchJob. Click Finish to generate the defined objects for the interface configuration.


4.2 Defining Communication Channel Details


After generating the scenario in the integration directory, define details for the sender and receiver communication channels specified by navigating to the objects from the Scenarios list and under the scenario that has been created. In the sender communication channel, specify the default interface namespace and name.  The Quality of Service parameter can be specified for specific message delivery options.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img52.JPG|height=273|alt=image|width=522|src=ht...!



In the receiver communication channel for the outbound message, make certain the RFC parameters are set and that valid logon information is provided.


5.0 Web Service Creation


5.1 Generating the WSDL File


In Integration Directory, from Tools in the main menu, select Define Web Service.  Specify the parameters for the web service and save the generated wsdl file to desired path.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img54.JPG|height=338|alt=image|width=518|src=ht...!



Specify the URL for the web service. The format should be
http://[server]:[port]/XISOAPAdapter/MessageServlet?channel=:[sender communication channel service]:[sender communication channel name]

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img55.JPG|height=168|alt=image|width=549|src=ht...!



Use the default interface information.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img56.JPG|height=168|alt=image|width=600|src=ht...!



Specify the sender as done in interface configuration.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img57.JPG|height=181|alt=image|width=594|src=ht...!



Review the information specified and click Finish to generate the wsdl file of the web service.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img58.JPG|height=249|alt=image|width=600|src=ht...!



Click on Save to save the generated web service document to an accessible path.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img59.JPG|height=389|alt=image|width=600|src=ht...!


6.0 Testing the Web Service


6.1 Designing and Testing the Form


Using Microsoft Office 2003 InfoPath, the web service that has been generated can be easily tested.  To begin testing the web service, first design the form in InfoPath.  Various other tools are also available for web service testing, including licensed and free tools.

Click on Design a Form after starting up InfoPath 2003.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img60.JPG|height=398|alt=image|width=598|src=ht...!



Click on New from Data Connection in Design a Form window.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img61.JPG|height=228|alt=image|width=585|src=ht...!



The Data Connection wizard starts up, choose Web service.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img62.JPG|height=399|alt=image|width=599|src=ht...!



Choose Receive and submit data since the web service involves request and response.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img63.JPG|height=399|alt=image|width=600|src=ht...!



Enter the path to the web service document that had been saved from XI.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img64.JPG|height=400|alt=image|width=600|src=ht...!



Highlight the message interface.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img65.JPG|height=399|alt=image|width=599|src=ht...!



Enter the name for the data connection for receiving data accordingly.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img66.JPG|height=400|alt=image|width=600|src=ht...!



Click Next and follow the same steps for the data connection for sending data as done for the data connection for receiving data. Enter a name for the sending data connection correspondingly.


After configuring the data connections for both send and receive, specify the parameters that will be submitted through the web service to start the workflow. Choose one parameter at a time.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img67.JPG|height=400|alt=image|width=596|src=ht...!

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img68.JPG|height=342|alt=image|width=299|src=ht...!



Finish the data connection creation.

Design the actual form of the web service.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img70.JPG|height=400|alt=image|width=599|src=ht...!



Drag and drop field elements from the Data Source window into the submit and return sections of the form accordingly. When done with designing the form, click on Preview Form from the top menu to test.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img71.JPG|height=400|alt=image|width=600|src=ht...!



Input valid test parameters into the boxes for the submit parameters and click the Submit Request button.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img72.JPG|height=373|alt=image|width=488|src=ht...!



Enter valid logon information to connect to the web service.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img73.JPG|height=356|alt=image|width=480|src=ht...!



If everything was configured correctly, valid results should
be visible in the return parameters fields.


7.0 Verifying the Test Results


7.1 Verification in XI


Go to the XI Integration Engine to make sure that the request and response messages have been successfully processed. In transaction SXMB_MONI, check the corresponding message ID for the processed request and response messages.  Notice in the SOAP header of the request message, the


7.2 Verification in R/3


Verify in the target system that the workflow and the job have been started successfully. In transaction SWI1, verify that the Schedule Manager: Schedule Job job instance has been started correctly by the workflow instance.

!https://weblogs.sdn.sap.com/weblogs/images/251698435/img76.JPG|height=398|alt=image|width=600|src=ht...!


In transaction SM37, verify the status of the job that had been started by the workflow instance.

12 Comments