Skip to Content

Dears,

I will share a complete solution with the objective to achive the logic that will alow you to make corrective decisions for your solutions implemented or to monitor for preventive symptoms for current interfaces… After we can agree that a lot of companies suffer in their integration processes and don’t know the main reason, but this article will not cover that point here; because i just will share a “logical tool” to let you implement your own technology to monitor and decision making reports.

First it is important to share a great reference that talk about this logic via Michal’s with great tips!!: michals-pi-tips-how-to-get-rwb-message-overview-data-to-an-external-system

Understanding Michal’s proposal, we can now implement our new tool:

About Metada:

  1. Getting metadata:

http://<host>:<port>/mdt/monitor/MessageOverviewQuery.xsd

2. Example of execution without values:

http://<host>:<port>/mdt/messageoverviewqueryservlet

3. Now your xsd can be uploaded in an external definition via PI Enterprise Service Repository:

 

After you understand the logic about metadata, now we can test with different tools in order to get the Runtime workbech information:

1. Excecute your own url: http://<host>:<port>/mdt/messageoverviewqueryservlet?component=af.<AF.PARAMETER><PITECHNAME>&view=SR_ENTRY_VIEW_XPI&begin=2016-12-31%2018:00:00.0&end=2017-12-31%2018:00:00.0&detailedStatus=true

 

2. Test via POSTMAN:

This technique is important because you will confirm 2 data information for security cookie:

http://<host>:<port>/mdt/messageoverviewqueryservlet?component=af.<AF.PARAMETER><PITECHNAME>&view=SR_ENTRY_VIEW_XPI&begin=2016-12-31%2018:00:00.0&end=2017-12-31%2018:00:00.0&detailedStatus=true

Authorization: Basic CONFIDENCIA_BASIC_SECURITY_ID

 

3. Now you can test it via SOAPUI:

 

After you understand how to get the metadata and how to testing, you can implement different solutions since using only java and excel, or using automatic interfaces, or technologies for analytics via hana, lumira, or another in your robust infraestructure for your decision making…

 

1. Implement Java Call:

 

 

package test;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

//import org.apache.commons.codec.binary.Base64;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

public class ConnectToUrlUsingBasicAuthentication {

	public static void main(String[] args) {

		try {
			String webPage = "http://hostname:port/mdt/messageoverviewqueryservlet?component=af.<AF.PI.PARAMETERS>&view=SR_ENTRY_VIEW_XPI&begin=2016-12-31%2018:00:00.0&end=2017-12-31%2018:00:00.0&detailedStatus=true";
			String name = "admin";
			String password = "admin";

//			String authString = name + ":" + password;
//			System.out.println("auth string: " + authString);
//			byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
//			String authStringEnc = new String(authEncBytes);
//			System.out.println("Base64 encoded auth string: " + authStringEnc);

			URL url = new URL(webPage);
			URLConnection urlConnection = url.openConnection();
			urlConnection.setRequestProperty("Authorization", "Basic " + "SPACEAuthentification ID");
			InputStream is = urlConnection.getInputStream();
			InputStreamReader isr = new InputStreamReader(is);

			int numCharsRead;
			char[] charArray = new char[1024];
			StringBuffer sb = new StringBuffer();
			while ((numCharsRead = isr.read(charArray)) > 0) {
				sb.append(charArray, 0, numCharsRead);
			}
			String result = sb.toString();

			System.out.println("*** BEGIN ***");
			System.out.println(result);
			System.out.println("*** END ***");
                        
                         /*
                 * To write contents of StringBuffer to a file, use
                 * BufferedWriter class.
                 */
               
                BufferedWriter bwr = new BufferedWriter(new FileWriter(new File("C:\\Path/demo.xml")));
                //write contents of StringBuffer to a file
                bwr.write(sb.toString());
               
                //flush the stream
                bwr.flush();
               
                //close the stream
                bwr.close();
               
                System.out.println("Content of StringBuffer written to File.");
                        
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

 

Test your java solution:

In this case you can get data via REST or via HTTP Request, even modify your way to test: https://blogs.sap.com/2015/04/22/thread-mechanism-effective-way-of-using-soap-ui-tool-for-stress-testing-in-sap-pipo/

In this case, how to call an http and dont forget just use basic authentification, without user an password: http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html

In this case, how to save it via file: http://www.java-examples.com/stringbuffer-file-java-example

 

2. Implement PI call insted manual solution:

 

Data Source:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MessageStatisticsQueryResults xmlns:ns0="http://com.sap.aii/mdt/MessageOverviewQuery">
   <ns0:Results>
      <ns0:Code>OK</ns0:Code>
      <ns0:Details>Nice</ns0:Details>
      <ns0:Text>Test</ns0:Text>
   </ns0:Results>
   <ns0:Data>
      <ns0:ColumnNames>
         <ns0:Column>Sender Component </ns0:Column>
      </ns0:ColumnNames>
      <ns0:DataRows>
         <ns0:Row>
            <ns0:Entry>NA</ns0:Entry>
            <ns0:Entry>SENDER_COMPONENT </ns0:Entry>
            <ns0:Entry>NA</ns0:Entry>
            <ns0:Entry>RECEIVER_COMPONENT </ns0:Entry>
            <ns0:Entry>SERVICE_INTERFACE </ns0:Entry>
            <ns0:Entry>NAMESPACE </ns0:Entry>
            <ns0:Entry>A </ns0:Entry>
            <ns0:Entry>0 </ns0:Entry>
            <ns0:Entry>0 </ns0:Entry>
            <ns0:Entry>0 </ns0:Entry>
            <ns0:Entry>0 </ns0:Entry>
            <ns0:Entry>0 </ns0:Entry>
            <ns0:Entry>0 </ns0:Entry>
            <ns0:Entry>22 </ns0:Entry>
         </ns0:Row>
      </ns0:DataRows>
   </ns0:Data>
</ns0:MessageStatisticsQueryResults>

 

Target Metadata:
MT_ MessageType Element DT_DataType null
row Element 0..unbounded false
SenderPartner Element xsd:string 1 false

Implement transformation (with one logic proposed but you can change it):

Mapping: in simple idea is a direct mapping node and childnode(here you add UDF)
/ns1:MT_MessageType=/ns0:MessageStatisticsQueryResults
/ns1:MT_MessageType/row=/ns0:MessageStatisticsQueryResults/ns0:Data/ns0:DataRows/ns0:Row
/ns1:MT_Test/row/SenderPartner=ConcatSubnodes(/ns0:MessageStatisticsQueryResults/ns0:Data/ns0:DataRows/ns0:Row)

 

UDF: ConcatSubnodes

public String ConcatSubnodes(String srcTreeFragment, Container container) throws StreamTransformationException{
Document doc = null;
String resStr = "";
try {
 InputStream in = new ByteArrayInputStream(srcTreeFragment.getBytes("UTF-8"));;
 doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
}
 catch (Exception e){
 throw new RuntimeException(e.getMessage());
}
NodeList items = doc.getDocumentElement().getChildNodes();
if(items.getLength()>0){
 for(int i=0;i<items.getLength();i++){
  if(items.item(i).getNodeType()==Node.ELEMENT_NODE)
   resStr = resStr + " | " + items.item(i).getTextContent().trim();
 }
}

return resStr;
}

 

Reference: https://archive.sap.com/discussions/thread/3955709

Result to import to Excel (you can modify the logic):

<?xml version="1.0" encoding="UTF-8"?>
<ns1:MT_MessageType xmlns:ns1="http://example">
   <row>
      <SenderPartner> | NA | SENDER_COMPONENT | NA | RECEIVER_COMPONENT | SERVICE_INTERFACE | NAMESPACE | A | 0 | 0 | 0 | 0 | 0 | 0 | 22</SenderPartner>
   </row>
</ns1:MT_MessageType>

 

3. Implement Analytics in a simple way via Excel:

 

 

Thank you and success for your own solution!!

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Ariel M. Bravo Ayala

    Thanks Azael for your blog entry. Keep going.

    Although I get your idea, I think is cleaner and simpler to use the Adapter Message Monitoring WS. It is a WS that is already prepared for this duties and provides extra valuable information. You can access this WS at:

    http://<host&gt;:<port>/AdapterMessageMonitoring/basic?wsdl&mode=ws_policy&style=document

    Best,

     

    Ariel

    (0) 

Leave a Reply