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!
Showing results for 
Search instead for 
Did you mean: 
0 Kudos

Based on a custom requirement to carry out performance analysis on a critical interface "on-demand", I was looking at options. Obviously going to the SXMB_MONI, opening each message to find out which payload was demanded for, then coming back with a message ID and using it in RWB performance monitoring was an option. However the number of messages we did for kept increasing. Searching on SCN lead me to a wonderful blog created by alessandro.guarneri/blog/2008/09/15/xipi-message-payload-from-java;IDSactivation=61FB273FC195A11BF03EC0CC7FB942F5A38BD7C8414A6C8306DD77228E6E7A12 in 2008. It provided me a good insight. However the API's have changed and so has the way of querying & parsing data. Based on Alessandro's blog and SAP JCo documentation and examples, here is the latest way of going about it:

Download JCo from Service marketplace:

SAP Java Connector (SAP JCo) -> Tools & Services -> Download SAP JCo Release 3.0

(I used 64bit x86 for my 64 bit Windows running 32 bit JRE and worked well for me)

Install JCo on your laptop

To install JCo for Windows unzip the appropriate distribution package into an arbitrary directory {sapjco3-install-path}.
Note: Do not copy the sapjco3.dll neither into the {windows-dir}\system32    nor into the {windows-dir}\SysWOW64 directory. This will break the operability of other JCo versions    that are already installed on the same system. Furthermore you would risk that the current installation also would    not work anymore, if the sapjco3.dll gets replaced in the respective Windows system directory in the    future.   
Then add {sapjco3-install-path} to the PATH environment variable.
Finally, add {sapjco3-install-path}\sapjco3.jar to your CLASSPATH environment variable.


import java.util.Properties;


public class PayloadExtractor {


//Set the connection parameters

static {
  Properties connectProperties = new Properties();
  connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "hostname");
  connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "sysnr");
  connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "clientnr");
  connectProperties.setProperty(DestinationDataProvider.JCO_USER, "usernm");
  connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "pwd");
  connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "en");


* Connects to the server and prints the connection parameter to the standard IO


public static void connectToServer() throws JCoException {
  JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME1);



* Gets the message payload


public static void getPayload() {

  String key = "0001ECC1B4AA4C75257AD9C410DB8E4";
  final String pipelineID = "CENTRAL";

try {
   JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME1);


   //Function used to the message payload 
   JCoFunction function = destination.getRepository().getFunction("SXMB_READ_MESSAGE_VERSION_RAW");

   if (function != null) {

         //Setting import parameters 
         JCoParameterList params = function.getImportParameterList();
         params.setValue("SELECTION", "2");


             JCoStructure struct = function.getImportParameterList().getStructure("MESSAGEKEY");
             struct.setValue("MSGID", key);
             struct.setValue("PID", pipelineID);
             params.setValue("MESSAGEKEY", struct);

             //Execute the program


             //Retriving the export parameters

             JCoTable returnTable = function.getExportParameterList().getTable("MESSAGEPAYLOAD");


             for (int i = 0; i < returnTable.getNumRows(); i++) {
  } catch (Exception ex) {
       System.out.println("Caught an exception: \n" + ex);



* The payload is returned as a Hexadecimal. Following function coverts it to String


   public static String convertHexToString(String hex) {
       StringBuilder sb = new StringBuilder();

       for (int i = 0; i < hex.length() - 1; i += 2) {
          String output = hex.substring(i, (i + 2));
          int decimal = Integer.parseInt(output, 16);
          sb.append((char) decimal);


     return sb.toString();


  public static void main(String[] args) throws JCoException {


Credits to Alessandro Guarneri for his original blog - XI/PI Message Payload from Java

I have removed exception handling and other complexities from the code to keep it simple for the purpose of this blog.

Labels in this area