Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Introduction

This is the third part of a mini-series blog about how to build a basic SAP-to-REST synchronous interface scenario. The blog's first part can be found here:  Consuming Your First Synchronous RESTful Service - Step-by-Step - Introduction. This part is to build all Enterprise Service Repository objects (design-time objects). The objects we will be building are shown in the PI dashed box in this diagram:

https://lh3.googleusercontent.com/-GTE805f5Ro4/VV9crsP8aqI/AAAAAAAAAtM/tDLiUhFAEOg/w2234-h840-no/00.50%2B-%2BESR%2BObjects.jpg

Let's get to work


Creating ESR Objects:

    • The objects will be created in the following order: Data Types, Message Types, Service Interfaces, Message Mappings, then Operation Mappings.
    • Start the "Enterprise Service Builder" by clicking the link on the NW Process Integration page shown above (transaction SXMB_IFR).
    • Once the tool starts, you need to import the SWCV we created above. This needs to be done only once.
      • Click the "Create Object" button or select it from menu option: Object -> Create. Note that this is how you start the creation of any object in ESR.

https://lh6.googleusercontent.com/-rNzJBzRM3R8/VV7I-AOU0EI/AAAAAAAAAqY/tGdrFM1VtCo/w668-h460-no/02.10%2B-%2BESR%2BImport%2BSWCV.jpg

    • In the "Create Object" pop-up screen, expand the "Work Areas" node and select object type Software Component Version. Then, in the details section, select the "Import from SLD" radiobutton then click the "Display" button.
    • Search for the SWCV created earlier, select it, and then click the "Import" button.
    • Once the SWCV is imported, verify the information and click the "Create" button.

https://lh6.googleusercontent.com/-Kr6b5E1P7mw/VV7JAKn8mNI/AAAAAAAAAss/XlwRqG9PmHc/w2184-h1338-no/02.20%2B-%2BESR%2BImport%2BSWCV%2BDetails.jpg

    • In the SWCV details screen, you need to do two things: select a language and create a namespace. The PI Best Practices Naming Conventions document talks in details about how many namespaces you should create and the reasoning behind that. For the purposes of this blog, we will create only one namespace that will be used for all ESR objects.

https://lh6.googleusercontent.com/-txX6_XoATfA/VV7JAJYQiFI/AAAAAAAAArE/cYAYe6BWQCU/w1316-h1132-no/02.30%2B-%2BESR%2BSWCV%2BDetails.jpghttps://lh5.googleusercontent.com/-TnZxPkz8ZOE/VV7JAHyndZI/AAAAAAAAAso/DQiisnX5cWw/w1504-h476-no/02.40%2B-%2BESR%2BNamespace.jpg

    • Now, you should see the SWCV in the Design Objects menu. From there, all other objects will be created.

https://lh3.googleusercontent.com/-0odEBLqusRw/VV7JApFgK1I/AAAAAAAAAsk/qGoZvEfyiBM/w1256-h546-no/02.50%2B-%2BESR%2BSWCV%2BDesign%2BObjects.jpg

    • Now, we need to create data types that will "describe" what the data looks like.
      • We need to know what types of data we will be sending from the SAP ECC system and what types of data we will be receiving back. Again, for our blog, the SAP ECC system will send a zip code and will want the response of the RESTful service sent back. Calling Google's map API rest service http://maps.googleapis.com/maps/api/geocode/json?address=10001 will return back a JSON message that looks like the below screenshot. You need to notice three things: the zip code in the rest service parameter list, the "results" tag, and the "status" tag. The first is the service request while the other two are the response we will be reading back. Usually, you create two data types for a request (DT1 and DT2 from the ESR Objects diagram above). The first one is for the data that goes from the sender to the PI system and the other is for the data that goes from the PI system to the receiver system. Similarly, you usually create two response data types (DT3 and DT4 from the ESR Objects diagram above). Optionally, you can create error data types (two of them as well) for transferring error details.

https://lh3.googleusercontent.com/-VQxEJY-PAdM/VV7JAr-dWsI/AAAAAAAAArY/38S78BU7f-4/w1176-h1856-no/03.10%2B-%2BData%2BTypes%2BAPI.jpg

    • To create a data element, you can click the "Create Object" button (just like you did when you imported the SWCV) or you can simply right-click the newly created name space then select the "New" option.

https://lh5.googleusercontent.com/-yvFRUq9aKN8/VV7JA4mZMUI/AAAAAAAAArQ/mEFiYNYowSw/w934-h632-no/03.20%2B-%2BData%2BTypes%2BCreate%2BButton.jpg

    • Create a data type for the zip code field by selecting the "Data Type" option in the "Interface Objects" node. Enter the data type name and namespace (namespace will be defaulted if you created the object by right-clicking the namespace). Then, click the "Create" button.

https://lh6.googleusercontent.com/-LqG3Teq6Vko/VV7JBa7ivqI/AAAAAAAAAsc/-LIZORkD4mw/w1836-h844-no/03.30%2B-%2BData%2BTypes%2BCreate%2BScreen.jpg

    • In the data type details screen, select the first line. Then, click the "Insert New Lines" button and select the "Insert Subelement" option.

https://lh4.googleusercontent.com/-2oQ-5MeBby0/VV7JBflNE1I/AAAAAAAAAsg/YrPJRPHhw8Y/w1044-h654-no/03.40%2B-%2BData%2BTypes%2BCreate%2BDetails.jpg

    • Type "zipcode" in the name field and type "xsd:string" in the type field. You can also select the XSD type from the field's value help list. Then, click the "Save" button.

https://lh5.googleusercontent.com/-Lk5Mo13PbYY/VV7JCB7EBfI/AAAAAAAAArs/Ah9_LJsVgA4/w1126-h676-no/03.50%2B-%2BData%2BTypes%2BCreate%2BDetails%2B2.jpg

    • Now, we need to create a data type for the response of the rest service.

https://lh5.googleusercontent.com/-FIq7XdWWvN8/VV7JCcNd4-I/AAAAAAAAAsY/wppZpNaPlog/w1452-h452-no/03.60%2B-%2BData%2BTypes%2BOutput%2BDetails%2B1.jpg

    • In the data type details screen, insert two new subelements: "results" & "status." Both are of type "xsd:string." Notice that you need to use the names of the JSON/XML tags that you want to read. Hint:if you want to completely use XML mapping in PI, you need to build the exact XML structure with the appropriate nesting in the data type that will be used for transferring data from the rest service to the PI system.

https://lh4.googleusercontent.com/-0DxARgwVeLw/VV7JCVfqJ8I/AAAAAAAAAsU/rOmfYiJt91E/w1796-h740-no/03.70%2B-%2BData%2BTypes%2BCompleted.jpg

    • Great! All the data types that we need are created now as you can see on the left side of the above screenshot.
    • The next step is to create message types that will carry the data described by the above data types.
      • Again, just like with data types, you usually create two request message types (from the sender to PI and from PI to the receiver: MT1 and MT2 from the ESR Objects diagram above) and two response message types (from the receiver to PI and from PI to the sender: MT3 and MT4 from the ESR Objects diagram above). However, for simplicity, we will use one message type for the request and one message type for the response.
      • Right-click the namespace to select the "New" option. Then, expand the "Interface Objects" node to select the "Message Type" object. Type a message type name for the request zip code then click the "Create" button.

https://lh4.googleusercontent.com/-gYJ43Gq6CQE/VV7JCm2sa0I/AAAAAAAAAsQ/F4PLE-BUC8s/w1392-h414-no/04.10%2BMessage%2BType%2BCreate.jpg

    • In the message type details screen, type the name of the zip code data type (or select it from the value help menu). You will notice the data type fields will be displayed automatically in the message type structure section.

https://lh5.googleusercontent.com/-UZCGCTaZuss/VV7JCzPfCXI/AAAAAAAAAsI/8FFZyL_x_W0/w1492-h788-no/04.20%2BMessage%2BType%2BDetails.jpg

    • Similarly, create a message type for the response location details.

https://lh4.googleusercontent.com/-T-zxT52ZqAE/VV7JDG02yHI/AAAAAAAAAsA/vzwKgvGBHGA/w1516-h430-no/04.30%2BMessage%2BType%2BResponse%2BCreate.jpghttps://lh5.googleusercontent.com/-DcTD6DEqauY/VV7JDKmVIYI/AAAAAAAAAsE/mgLGqS1e0QA/w1258-h832-no/04.40%2BMessage%2BType%2BResponse%2BDetails.jpg

    • Save the message type and verify the message types exist under the namespace.

https://lh5.googleusercontent.com/-UMvP0FMbymQ/VV7JDfkXVzI/AAAAAAAAAsM/HwFGo_QIeZI/w680-h496-no/04.50%2B-%2BMessage%2BTypes%2BCreated%2BSuccessfully.jpg

    • Now, we need to create the outbound (sender -> PI) and inbound (PI -> receiver) interfaces (OBI and IBI from the ESR Objects diagram above).
      • Click the "Create New Object" button or right-click the namespace then select the "New" option. In the pop-up screen, expand node "Interface Objects" and select the "Service Interface" object type. Type the outbound service interface name and click the "Create" button.

https://lh4.googleusercontent.com/-G2GARu7Oj3A/VV9lJrt4E0I/AAAAAAAAAt0/ahcU_NZJ5pA/w2062-h750-no/05.10%2B-%2BOB%2BService%2BInterface%2BCreate.jpg

    • In the details screen, make sure the interface category is "Outbound" and the mode is "Synchronous." Then, type the request and response message types (that we created earlier) in the appropriate fields. You can also select them from the field's value help menu. Then, click the "Save" button. You can enter a "fault" message type, but we will ignore that for this blog.

https://lh6.googleusercontent.com/-kRfLPErBGu0/VV98StiWIzI/AAAAAAAAAvc/9WEZjqytcVc/w1958-h1286-no/05.20%2B-%2BOB%2BService%2BInterface%2BDetails.jpg

    • Similarly, start the creation of the inbound service interface.

https://lh5.googleusercontent.com/-pFl-i4hrP5g/VV9lJksfixI/AAAAAAAAAto/JRZdRp10YEs/w1616-h616-no/05.30%2B-%2BIB%2BService%2BInterface%2BCreate.jpg

    • In the details screen, make sure the interface category is "Inbound" and the mode is "Synchronous." Then, type or select the request and response message types (just like in the outbound service interface). Then, click the "Save" button.

https://lh6.googleusercontent.com/-0Dj1irQgD54/VV9lKaOpOkI/AAAAAAAAAuA/3Y7N-sSqvfU/w2206-h1298-no/05.40%2B-%2BIB%2BService%2BInterface%2BDetails.jpg

    • Verify the service interfaces are now created in the namespace.

https://lh4.googleusercontent.com/-H5Og7X9fUhU/VV9lKUleXDI/AAAAAAAAAt4/T-OhCBaZZyQ/w644-h620-no/05.50%2B-%2BService%2BInterfaces%2BCreated.jpg

    • Now, it is type to create message mappings for the request and response (MM1 and MM2 from the ESR Objects diagram above).
      • Click the "Create New Object" button or right-click the namespace then select the "New" option. In the pop-up screen, expand node "Mapping Objects" and select "Message Mapping." Type in a message mapping name then click the "Create" button.

https://lh3.googleusercontent.com/-DtoX6E_yUaA/VV92bpF8HLI/AAAAAAAAAuk/g8CKvue2l94/w2142-h756-no/06.10%2B-%2BMsg%2BMapping%2BCreate.jpg

    • In the message mapping details, click the "Select Mapping" button in both the "source" and "target" sections. Select the same message type as shown in the screenshot.

https://lh3.googleusercontent.com/-aTs6KYbjN4A/VV92bngW5oI/AAAAAAAAAvA/y6m-cpclFOM/w2256-h882-no/06.20%2B-%2BMsg%2BMapping%2BDetails.jpg

    • Once both message types are visible in the grid area, you need to map the source field (zipcode) to the target field (zipcode). You can either drag-and-drop the source field onto the target field or add both fields to the mapping area (by double-clicking) then map the fields there. You should have something that looks like the screenshot below.

https://lh6.googleusercontent.com/-2YPqllY4UFA/VV92bRrOiyI/AAAAAAAAAvE/Ac6ai2gegL8/w2118-h992-no/06.30%2B-%2BMsg%2BMapping%2BFields.jpg

    • Similarly, create a message mapping for the response.

https://lh6.googleusercontent.com/-KGVWCmNPuks/VV92b4vmPcI/AAAAAAAAAu0/pT4PAvL7oS0/w1514-h478-no/06.40%2B-%2BMsg%2BMapping%2BResponse%2BCreate.jpg

    • Similarly, select the response message types.

https://lh4.googleusercontent.com/-JupKoDcpunY/VV92cCL2eMI/AAAAAAAAAuw/FNFW3QVlmMg/w2238-h708-no/06.50%2B-%2BMsg%2BMapping%2BDetails.jpg

    • Map the "results" and "status" fields to the "results" and "status" fields.

https://lh3.googleusercontent.com/-8kXt8TYdUIE/VV92cbx8xAI/AAAAAAAAAu8/27uO1u-4tIo/w2100-h1188-no/06.60%2B-%2BMsg%2BMapping%2BFields.jpg

    • Drag and drop the "results" field into the lower mapping area. Then, right-click the "results" icon and select the "Return as XML" option (which should show now as checked).

https://lh6.googleusercontent.com/-8LWoAJEDnSg/VWLHxTL4a7I/AAAAAAAAA5g/yfeX6-3XUrQ/w716-h536-no/06.63%2B-%2BMsg%2BMapping%2BXML.jpg

    • Then, in the lower toolbar, select "Text" from the function drop down list.

https://lh4.googleusercontent.com/-yzvQEwJGwUg/VWLHxU7aWpI/AAAAAAAAA5k/JQ87GiyD-dc/w2544-h678-no/06.65%2B-%2BMsg%2BMapping%2BTrim%2BFunction.jpg

    • Now, drag and drop the "trim" function to the mapping area. Map the source "results" to the "trim" function. Then, the output of the "trim" function should be mapped to the target "results" field.

https://lh6.googleusercontent.com/-udppPww5a2A/VWLHxSJ_n8I/AAAAAAAAA5o/0HQAjk30kV0/w746-h456-no/06.68%2B-%2BMsg%2BMapping%2BTrim.jpg

    • Finally, verify the message mapping objects are created in the namespace.

https://lh6.googleusercontent.com/-lwG81tf0wSA/VV92cQoBCkI/AAAAAAAAAu4/a9itAX8faqw/w686-h790-no/06.70%2B-%2BMsg%2BMapping%2BObjects%2BCreated.jpg

    • The last object to be created in the ESR is the Operation Mapping object (object OM from the ESR Objects diagram above).
      • Click the "Create New Object" button or right-click the namespace then select the "New" option.Expand the "Mapping Objects" node and select the "Operation Mapping" object type. Type an operation mapping name and click the "Create" button.

https://lh3.googleusercontent.com/-OJvgNKerglI/VV99NEqWz6I/AAAAAAAAAwE/lsxYrOENBP0/w2108-h842-no/07.10%2B-%2BOperation%2BCreate.jpg

    • Select the outbound service interface in the source operation section and the inbound service interface in the target operation section. Then, click the "Read Operations" button.

https://lh5.googleusercontent.com/-GsurJLg4hkY/VV99NIS8__I/AAAAAAAAAv8/hwnlyderr2Y/w2132-h834-no/07.20%2B-%2BOperation%2BAdd%2BOperations.jpg

    • In the "Request" tab, select the request message mapping.

https://lh5.googleusercontent.com/-I9t2WyGGvJw/VV99M2fGOHI/AAAAAAAAAwM/jkSaPBuRQL0/w2102-h402-no/07.30%2B-%2BOperation%2BRequest.jpg

    • In the "Response" tab, select the response message mapping.

https://lh5.googleusercontent.com/-3MkmHG4Sdqo/VV99NT1Kg7I/AAAAAAAAAwA/FE-mE9xpw4w/w2172-h380-no/07.40%2B-%2BOperation%2BResponse.jpg

    • Finally, verify that the operation is now created in the namespace.

https://lh3.googleusercontent.com/-Gdw7aA7lfa4/VV99NqBCzII/AAAAAAAAAwI/fjwzAxJNMNc/w636-h404-no/07.50%2B-%2BOperation%2BCreated.jpg

    • Now, all of our ESR objects are created, we need to activate them.
      • Go to the "Change List" tab and expand the tree all the way.

https://lh5.googleusercontent.com/-bJ81f1gGkyI/VV-G5Pr4YaI/AAAAAAAAAww/-QmvmfTRNUQ/w856-h752-no/08.10%2B-%2BESR%2BActivation.jpg

    • Right-click the "Standard Change List" and select the "Activate" option.

https://lh3.googleusercontent.com/-6TV6SJDMgCs/VV-G5A2OG-I/AAAAAAAAAw0/x226G4ZhGNk/w876-h284-no/08.20%2B-%2BESR%2BActivation%2BButton.jpg

    • In the confirmation pop-up screen, select all the objects we just created and then click the "Activate" button.

https://lh3.googleusercontent.com/-djFhRJBy8GE/VV-G5Ikyw4I/AAAAAAAAAw4/h0kFByPWXns/w998-h896-no/08.30%2B-%2BESR%2BActivation%2BConfirmation.jpg

    • Once the list is confirmed, your "Change List" should look empty now.

https://lh6.googleusercontent.com/-wI4l_JTjHlQ/VV-G5re8rdI/AAAAAAAAAxA/EGINUkJbP-A/w736-h288-no/08.40%2B-%2BESR%2BEmpty%2BChange%2BList.jpg

Now, it is time to build integration builder objects. See you in the fourth part.

Labels in this area