Skip to Content
Author's profile photo Vikas Singh

Extracting data for ESR Objects in a SAP PI System

This wiki link already covers how to extract information from ESR / ID objects . This works fine for checking a single object. However, sometimes we may need to extract metadata of all PI objects ( for instance, to find all objects modified after a certain date ) or even analyse the source code ( to find all objects using a certian Java function / Value map ).

Through this blog, I’ll show how we can automate reading SimpleQuery.

Looking at the SimpleQuery structure in terms of HTML pages in the below image, the information we need is in the step highlighted in the Green box below.


How to automate filling this information ?

Here we’ll use HtmlUnit. From it’s homepage link description : HtmlUnit is a “GUI-Less browser for Java programs”. It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc… just like you do in your “normal” browser.

For our example, we’re interested in filling up the below page.



We will need to run some tests to see what the default values are for each of the fields.

The general sequence of steps is:

– Create an instance of WebClient

WebClient webClient = new WebClient();

– Encode {username:password} using base 64 encoding and update the header


It can be implemented as

private static void setCredentials(WebClient _webClient) {

  String base64encodedUsernameAndPassword = base64Encode(combinePasswd);

  _webClient.addRequestHeader(“Authorization”, “Basic “

  + base64encodedUsernameAndPassword);


– Create an instance of HtmlPage and get the form by checking the body

HtmlPage currentPage = webClient.getPage(url);

HtmlForm form = (HtmlForm) currentPage.getByXPath(“/html/body/form”).get(0);

– Once we have the form, select different objects, set/ unset values

// Get SWC

  HtmlRadioButtonInput choseSWC = form

  .getInputByValue(“All software components”);;

//Unclick changeList User

HtmlCheckBoxInput changeListUser = form.getInputByName(“changeL”);;

– Click the Start Query button to get the result page.

HtmlSubmitInput submit = form.getInputByValue(“Start query”);

HtmlPage resultPage =;

This page will have all the links and we can convert it nicely to a String.

String resultPageText = resultPage.asXml().toString();

I wanted to keep this blog brief to focus on automating getting the result page.

This github link has the source code. Please make sure you have HtmlUnit library added to your project. You can run the source code – just adapt the static variables in the beginning of the file – SimpleQuery url , user and password.

We can now build up this knowledge to get more information. I’ll take two use cases:

–  Compare map versions between two PI systems.

Extract graphical maps using value mappings.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Great article. This is also possible to do directly in java with module. Something like:

      QueryService queryService = new QueryService(repConnectionSettings);

      QueryResult queryResult = queryService.generalQuery(queryDefinition);

      Sadly I have not found a way to create / edit objects in ESR. Don't you by chance know how to do it?