Skip to Content

This blog post was created in association with Mateusz Nowak.

 

Those who are acquainted with SAP PI/PO probably know that different message versions can be stored at runtime in both the Adapter Engine (AAE) and the Integration Engine (IE). Explicit explanation on message versions and on how to configure staging, logging and version saving
can be found  under this SAP help link

During the creation process of our int4 Automated SAP Application Interface Testing Suite
we were looking for some way to get specific versions of messages from PI (Java stack – AdapterEngine): before, and after mapping. This can be done by calling the web service AdapterMessageMonitoringVi which is provided by SAP and available with all releases of standard PI installations.

We have decided to use two following web services methods: getMessageList to retrieve the list of messages and the getMessageBytesJavaLangStringIntBoolean to obtain the  entire message content
( message header and body containing payload with business data ) of this particular message version. If you would like to learn more about all the other methods of this particular web service or how to get messages from ABAP Stack visit Andreas’s blog.

 If you are interested in quick take-aways only, scroll down to the summary.

However, while testing our product we found out that when calling the getMessageBytesJavaLangStringIntBoolean  method, a correct version of the message was fetched only if:

  • we pointed to the staged version of the message and
  • the staging was turned on in the ICO’s Advanced Settings

On the other hand, no message version was retrieved when:

  • the staging was switched off and
  • the logging switched on.

Fig. 1 shows the mentioned Advance Settings tab in an Integrated Configuration object in Integration Directory where you can manipulate the staging and logging settings.

Fig.1 ICO’s Advanced Settings – staging and logging settings – PI Integration Directory.

 

It occurred that getMessageBytesJavaLangStringIntBoolean works only for staged messages, and does not allow to download content of those messages that have been logged.

Fortunately SAP managed to resolve this issue providing the solution in the released note: 2437778. The patch introduces a new method getLoggedMessageBytes to the AdapterMessageMonitoringVi
web service, which allows to obtain a specific version of logged messages.

Below you can find some examples that explain which message versions can be retrieved from Java stack by calling each of the methods. We have tested them using WS Navigator – a standard SAP tool for testing Web Services –each time passing a different version parameter:

 

getMessageBytesJavaLangStringIntBoolean

If we pass ‘0’ as the version parameter (Fig. 2) calling getMessageBytesJavaLangStringIntBoolean it will retrieve the staging – 0 version from PI (Fig. 3):


Fig. 2: Calling method getMessageBytesJavaLangStringIntBoolean using WS Navigator (SAP PI). Version parameter value set to ‘0’.

Fig. 3: Message details in Message Monitor (SAP PI). Highlighted version:  0, MS version – staged.

 

Fig. 3 shows a detailed view of a message, and its versions stored in PI persistence, available through SAP PI Message Monitor. Message Monitor can be reached directly from Monitoring Home: http://<host>:5<sys#>00/pimon => Adapter Engine => Message Monitor. In order to get to the Message version details follow steps depicted in Fig. 4a and Fig 4b. In PI message versions saved at different processing steps are distinguished by two parameters visible in the first two columns
(Fig. 3): version – an integer value, and a caption – apart from custom cases it is a 2-letter parameter. If you would like to learn which processing step does each of the captions represent please check out help.sap.com: https://help.sap.com/viewer/5cf7d2de571a45cc81f91261668b7361/7.5.8/en-US/6c6b34b0297a4d2a95e7b1d9443d0fbb.html


Fig. 4a: Click on a number of messages in the Overview tab to access detailed message list.

 


Fig. 4b: Select a single message and click ‘Open Message’ button to gain insight on message versions stored in the PI persistence.

 

If we pass ‘1’ as the version parameter value while calling getMessageBytesJavaLangString IntBoolean it will retrieve the staging – 1 version from PI (Fig. 5):

Fig. 5: Message details in Message Monitor (SAP PI). Highlighted version:  1, AM version – staged.

 

While calling getMessageBytesJavaLangStringIntBoolean, when we pass ‘2’ as the version parameter value (which in this particular case is the integer version number for the After Mapping version of a logged message) the method cannot find this specific version number within staged messages so it takes the latest version from staging (Fig. 6).

Fig. 6: Message details in Message Monitor (SAP PI). Highlighted version: 1,MS version – staged. Latest version.

 

getLoggedMessageBytes

If while calling getLoggedMessageBytes method we will pass a caption ‘BI’ (fig.7) which refers
to a message that has been staged only and does not have a logged version (fig. 8), the method will return no result (fig.9).

Fig. 8: Message details in Message Monitor (SAP PI). Highlighted version: 0, BI version – staged. There is no logged version of the  BI message stored in PI persistance.


Fig. 9: BI value passed as version parameter while calling getLoggedMessageBytes method in WS Navigator (SAP PI)


Fig. 10: getLoggedMessageBytes method returns no results after we passed ‘BI’ caption parameter value as the version. This is due to the fact that there is no logged version of the BI message in PI persistence.

 

If while calling getLoggedMessageBytes method as the version parameter we will pass the caption ‘edi’  (Fig. 12) which refers to a message that has been logged (Fig. 11), the method will return its payload successfully (Fig13).


Fig. 11: Message details in Message Monitor (SAP PI). Highlighted version: 0, edi version – logged.


Fig. 12: edi value passed as version parameter calling getLoggedMessageBytes method in WS Navigator (SAP PI)


Fig. 13: getLoggedMessageBytes method returns message payload  after we passed ‘edi’ caption, as the value of the version parameter. getLoggedMessageBytes recognizes the caption as the proper version parameter and it obtains the logged version of the message that is identified by the caption.

 

Passing an invalid value to the parameter

getMessageBytesJavaLangStringIntBoolean

If we call getMessageBytesJavaLangStringIntBoolean method with the caption value as the version parameter (Fig. 14), an error message will appear (Fig. 15) urging us to enter an integer value
instead of the caption. This shows a fundamental difference to the getLoggedMessageBytes method where version parameter refers to the caption value in PI Message Monitors detailed message view.


Fig. 14: WS Navigator – calling getMessageBytesJavaLangStringIntBoolean method with version parameter set to: BI.

 


Fig. 15: WS Navigator – a message received after trying to call getMessageBytesJavaLangStringIntBoolean method with version parameter set to: BI

 

getLoggedMessageBytes

Calling getLoggedMessageBytes method when we pass ‘0’ as the version parameter (Fig. 16), we are hoping to retrieve the logged version of the message (Fig.17).


Fig. 16: WS Navigator – calling getLoggedMessageBytes with version parameter set to: 0.

 

Fig 17: Message details in Message Monitor (SAP PI). Highlighted version: 0, edi version – logged. By passing ‘0’ value to the getLoggedMessageBytes

 

When we process the input parameters calling web service we receive a confirmation that the message was executed successfully.


Fig. 18 Misleading message suggesting that the execution of the method was successful.

 

But we get no result.  Despite the “executed successfully” message suggesting that we have used a proper value for the parameter the message cannot be retrieved (Fig. 19). This is because
the getLoggedMessageBytes method supports only caption as a version parameter value. It checked available message versions for their caption value but none of them equaled ‘0’. In order to obtain a correct version of the message we should have used ‘edi’ caption as the version parameter value.  


Fig. 19 Empty response.

 

We hope that this blog sheds some light on the AdapterMessageMonitoringVi web service and its methods for payload retrieval services currently available in SAP PI.

For those of you who prefer to concentrate on the essentials quick summary:

 

  • getMessageBytesJavaLangStringIntBoolean method of AdapterMessageMonitoringVi web service can retrieve only staged versions of messages
  • If staging is turned off in the ICO Advanced Settings no message will be returned by calling the method.
  • to obtain a specific version of logged messages using AdapterMessageMonitoringVi web service a SAP note has to be installed: 2437778
  • getLoggedMessageBytes – a new method available with the SAP note can retrieve only logged versions of messages. If logging is turned off in the ICO Advanced Settings will be returned by calling the method
  • getMessageBytesJavaLangStringIntBoolean recognizes only integer values as the version parameter used to retrieve messages from PI persistence
  • getLoggedMessageBytes recognizes only caption values as the version parameter used to retrieve messages from PI persistence

 

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply