Skip to Content
Technical Articles
Author's profile photo Ramazan Sedat Göç

SAP PO Operation Mapping Test with Postman

Hello everyone,

I researched how to test an Operation Mapping with Postman after reading Fatin Pense‘s An Open-Source CPI Mapping Test Tool: Pizug Test. After some tracking with Wireshark, I found an API for mapping test service ?. In this post, I will share the API details and a Postman collection that helps you use this API.

Overview

The “Operation Mapping Test Postman collection” provides a way to test an Operation Mapping without ESR or NWDS. If you are a developer you can easily implement this logic of the Postman Collection to your project.

 

How to Use

Authorization : Basic

API URL : http(s)://localhost:port/rep/mappingtestservice/int?container=any

Method : POST

First I created a Postman environment for parameters.

  • SWCVId: This is the ID of Sofware Component
  • OperationMappingName: The name of the Operation Mapping you want to test
  • OperationMappingNamespace: This is the Namespace of Operation Mapping you want to test.
  • Direction: If you are testing Sync Operation Mapping, you must define direction. These values are available
    • REQUEST
    • RESPONSE
  • Input: This is your input.

 

postman-environment-settings

Postman Environment Settings

 

After the environment creates I pasted the Wireshark request body. Then I wanted to fill values dynamically. Therefore I changed the values of some fields with our Environment keys.

 

<?xml version="1.0" encoding="UTF-8" ?>
<instance typeid="com.sap.aii.util.hmi.core.msg.HmiRequest"><attribute isleave="true" leave_typeid="string" name="ClientId"><value index="0" isnull="false">4054f934fcd811eab42d54f36eecaf14</value></attribute><attribute isleave="true" leave_typeid="string" name="ClientLanguage"><value index="0" isnull="false">TR</value></attribute><attribute isleave="false" name="ClientLevel"><value index="0" isnull="false"><instance typeid="com.sap.aii.util.applcomp.ApplCompLevel"><attribute isleave="true" leave_typeid="string" name="Release"><value index="0" isnull="false">7.31</value></attribute><attribute isleave="true" leave_typeid="string" name="SupportPackage"><value index="0" isnull="false">*</value></attribute></instance></value></attribute><attribute isleave="true" leave_typeid="string" name="ClientPassword"><value index="0" isnull="false">dummy</value></attribute><attribute isleave="true" leave_typeid="string" name="ClientUser"><value index="0" isnull="false">dummy</value></attribute><attribute isleave="true" leave_typeid="string" name="ControlFlag"><value index="0" isnull="false">0</value></attribute><attribute isleave="true" leave_typeid="string" name="HmiSpecVersion"><value index="0" isnull="false">1.0</value></attribute><attribute isleave="true" leave_typeid="string" name="MethodId"><value index="0" isnull="false">executeoperationmappingmethod</value></attribute><attribute isleave="false" name="MethodInput"><value index="0" isnull="false"><instance typeid="com.sap.aii.util.hmi.api.HmiMethodInput"><attribute isleave="false" name="Parameters"><value index="0" isnull="false"><instance typeid="com.sap.aii.util.hmi.core.gdi2.EntryStringString"><attribute isleave="true" leave_typeid="string" name="Key"><value index="0" isnull="false">body</value></attribute><attribute isleave="true" leave_typeid="string" name="Value"><value index="0" isnull="false">&lt;testExecutionRequest&gt;
 &lt;ref&gt;
  &lt;vc swcGuid=&quot;{{SWCVId}}&quot; vcType=&quot;S&quot;/&gt;
  &lt;key typeID=&quot;MAPPING&quot;&gt;
   &lt;elem&gt;{{OperationMappingName}}&lt;/elem&gt;
   &lt;elem&gt;{{OperationMappingNamespace}}&lt;/elem&gt;
  &lt;/key&gt;
 &lt;/ref&gt;
 &lt;testData&gt;
  &lt;inputXml&gt;&lt;![CDATA[{{Input_temp}}]]&gt;&lt;/inputXml&gt;
  &lt;parameters&gt;
   &lt;testParameterInfo&gt;
    &lt;HeaderParameters&gt;
     &lt;properties&gt;
      &lt;property name=&quot;TimeSent&quot;/&gt;
      &lt;property name=&quot;SenderSystem&quot;&gt;&lt;![CDATA[Test_SenderSystem]]&gt;&lt;/property&gt;
      &lt;property name=&quot;SenderParty&quot;&gt;&lt;![CDATA[Test_SenderParty]]&gt;&lt;/property&gt;
      &lt;property name=&quot;InterfaceNamespace&quot;/&gt;
      &lt;property name=&quot;Interface&quot;/&gt;
      &lt;property name=&quot;SenderPartyScheme&quot;/&gt;
      &lt;property name=&quot;ReceiverPartyAgency&quot;/&gt;
      &lt;property name=&quot;RefToMessageId&quot;/&gt;
      &lt;property name=&quot;ReceiverPartyScheme&quot;/&gt;
      &lt;property name=&quot;SenderName&quot;/&gt;
      &lt;property name=&quot;Profiling&quot;&gt;&lt;![CDATA[off]]&gt;&lt;/property&gt;
      &lt;property name=&quot;MessageId&quot;/&gt;
      &lt;property name=&quot;VersionMajor&quot;/&gt;
      &lt;property name=&quot;ReceiverName&quot;/&gt;
      &lt;property name=&quot;ReceiverParty&quot;&gt;&lt;![CDATA[Test_ReceiverParty]]&gt;&lt;/property&gt;
      &lt;property name=&quot;ProcessingMode&quot;/&gt;
      &lt;property name=&quot;SenderService&quot;&gt;&lt;![CDATA[Test_SenderService]]&gt;&lt;/property&gt;
      &lt;property name=&quot;ReceiverNamespace&quot;/&gt;
      &lt;property name=&quot;ConversationId&quot;/&gt;
      &lt;property name=&quot;VersionMinor&quot;/&gt;
      &lt;property name=&quot;SenderNamespace&quot;/&gt;
      &lt;property name=&quot;ReceiverService&quot;&gt;&lt;![CDATA[Test_ReceiverService]]&gt;&lt;/property&gt;
      &lt;property name=&quot;ReceiverSystem&quot;&gt;&lt;![CDATA[Test_ReceiverSystem]]&gt;&lt;/property&gt;
      &lt;property name=&quot;SenderPartyAgency&quot;/&gt;
     &lt;/properties&gt;
    &lt;/HeaderParameters&gt;
    &lt;ImportingParameters&gt;
     &lt;properties/&gt;
    &lt;/ImportingParameters&gt;
   &lt;/testParameterInfo&gt;
  &lt;/parameters&gt;
  &lt;testParameters&gt;
   &lt;direction&gt;{{Direction}}&lt;/direction&gt;
   &lt;fromStep&gt;0&lt;/fromStep&gt;
   &lt;toStep&gt;0&lt;/toStep&gt;
  &lt;/testParameters&gt;
  &lt;traceLevel&gt;3&lt;/traceLevel&gt;
 &lt;/testData&gt;
&lt;/testExecutionRequest&gt;</value></attribute></instance></value></attribute></instance></value></attribute><attribute isleave="true" leave_typeid="string" name="RequestId"><value index="0" isnull="false">4054f935fcd811ea840654f36eecaf14</value></attribute><attribute isleave="true" leave_typeid="string" name="RequiresSession"><value index="0" isnull="false">false</value></attribute><attribute isleave="true" leave_typeid="string" name="ServerApplicationId"><value index="0" isnull="true"></value></attribute><attribute isleave="true" leave_typeid="string" name="ServerLogicalSystemName"><value index="0" isnull="true"></value></attribute><attribute isleave="true" leave_typeid="string" name="ServiceId"><value index="0" isnull="false">mappingtestservice</value></attribute></instance>

 

Now, we need to write Javascript because we cannot parse Input and Output data as are. This step was tiring ?.

 

Input (Pre-request Script Tab) :

var input = pm.environment.get("Input");
input = input.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");
console.log(input);
pm.environment.set("Input_temp", input);

 

Output (Tests Tab):

var responseJson = xml2Json(responseBody);
var masterString = responseJson["instance"]["attribute"][5]["value"]["instance"]["attribute"][1]["value"]["_"];
masterString = masterString.replace(/(\r\n|\n|\r)/gm, "");
resultString = masterString.match(/<!\[CDATA\[.*?\]\]>/g);
resultString = resultString[0].replace("<![CDATA[","").replace("]]","");
console.log(resultString);

tests["Output = " +resultString] = true;  

 

Now, we can run our Postman Collection ?.

 

Postman%20Test%20Result

Postman Test Result

 

Maybe you want to test multiple requests in Postman. I have created an example input file Runner.

 

input.json:

[
	{
		"name": "input1.xml",
		"value": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:MT_3RD_CALCULATOR_REQ xmlns:ns0=\"http://mdpgroup.com/development\"><values><int>24</int><int>30</int></values></ns0:MT_3RD_CALCULATOR_REQ>"
	
	},
	{
		"name": "input2.xml",
		"value": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:MT_3RD_CALCULATOR_REQ xmlns:ns0=\"http://mdpgroup.com/development\"><values><int>33</int><int>30</int></values></ns0:MT_3RD_CALCULATOR_REQ>"
	
	}

]

 

Now, we need to do some changes our scripts.

 

Pre-request Tab Script:

var input = pm.iterationData.get("value");
input = input.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");
console.log(input);
pm.environment.set("Input_temp", input);

 

Tests Tab Script :

 

var responseJson = xml2Json(responseBody);
var masterString = responseJson["instance"]["attribute"][5]["value"]["instance"]["attribute"][1]["value"]["_"];
masterString = masterString.replace(/(\r\n|\n|\r)/gm, "");
resultString = masterString.match(/<!\[CDATA\[.*?\]\]>/g);
resultString = resultString[0].replace("<![CDATA[","").replace("]]","");
console.log(resultString);

tests[resultString] = true;  

 

Now, open to the Postman Runner. The runner needs an input file and should include your test input. You can see below the Runner result.

 

Postman%20Runner%20Result

Postman Runner Result

Conclusion

Sometimes we need to test Operation Mapping with a lot of input cases. If you want to test all of your inputs maybe this situation can take your time. Maybe you want to make a Java application and this collection may help you for code implementation. Because Postman Collection can give you a code example.

Installation

You can download the Postman Collection in this Git repository page

Operation Mapping Postman Collection on GitHub

 

Thank you for reading.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Yusuf Baysal
      Yusuf Baysal

      Great blog Ramazan Sedat Göç !

      Thanks for sharing your insightful findings.

      Author's profile photo Diego Correia
      Diego Correia

      Hi Ramazan Sedat Göç,

      Do you or someone else have one example with ImportingParameters (like JDBC Channels) for Operation Mapping with Message Mappings that have JDBC lookups?

      Thanks for sharing this helpful information.