Skip to Content

Reverse engineering (RE) is the process of discovering the

technological principles of a device or object or system through analysis of

its structure, function and operation. – Wikipedia

Based on the reverse engineering research on XI, a set of
APIs in Java were formulated to directly interact with the XI server, instead of Integration
Builders for XI objects. This results in create / modify XI objects without the
help of Integration Builder using simple APIs in Java. In other words, create
your own Integration Builder!!

Software Components

Source Code

XiDbUtils.java

+(Contains common utilities for DB related operations on
XI server)+

package xidb;

import java.io.ByteArrayInputStream;

import java.io.InputStream;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.sql.Timestamp;

import java.util.Calendar;

import java.util.Vector;

/**

  • @author Felix Jeyareuben

*/

public class XiDbUtils {

     public XiDbUtils() {

          try {

               Class.forName(“oracle.jdbc.driver.OracleDriver”).newInstance();

          } catch (InstantiationException e) {

               // TODO Auto-generated catch block

               e.printStackTrace();

          } catch (IllegalAccessException e) {

               // TODO Auto-generated catch block

               e.printStackTrace();

          } catch (ClassNotFoundException e) {

               // TODO Auto-generated catch block

               e.printStackTrace();

          }

     }

     public Connection getConnection() {

          Connection con = null;

          try {

               con = DriverManager.getConnection(

                         “dbc:oracle:thin:@

Xi_SWComponent.java

(Class for SWC)

package xidb;

import java.sql.Connection;

import java.sql.SQLException;

import java.util.Vector;

/**

  • @author Felix Jeyareuben

*/

public class Xi_SWComponent {

     XiDbUtils utils;

     Connection con;

     String ownerrepid;

     String relationid;

     String objectid;

     String versionid;

     String versionsetid;

     String versionsetid_2_dev;

     String versionsetid_1_cons;

     String swcguid;

     Vector params = new Vector();

     String owner;

     String swc_name;

     String vendor;

     public void printString() {          

        System.out.println(“objectid:”+objectid);

        System.out.println(“relationid:”+relationid);

        System.out.println(“versionid:”+versionid);

        System.out.println(“versionsetid:”+versionsetid);

        System.out.println(“versionsetid_2_dev:”+versionsetid_2_dev);

        System.out.println(“versionsetid_1_cons:”+versionsetid_1_cons);

        System.out.println(“swc_guid:”+swcguid);

     }

     

     public Xi_SWComponent(String _owner, String swcname, String _vendor) {

          swc_name = swcname;

          owner = _owner;

          vendor = _vendor;

          utils = new XiDbUtils();

          con = utils.getConnection();

          ownerrepid = XiDbUtils.generateID(32);

          relationid = XiDbUtils.generateID(32);

          objectid = XiDbUtils.generateID(32);

          versionid = XiDbUtils.generateID(32);

          versionsetid = XiDbUtils.generateID(32);

          versionsetid_2_dev = XiDbUtils.generateID(32);

          versionsetid_1_cons = XiDbUtils.generateID(32);

          swcguid = objectid;

     }

     public void closeConnection()

     {

          try {

               con.close();

          } catch (SQLException e) {

               e.printStackTrace();

          }

     }

     

     public void xi_dircacheevent() {

          //System.out.println(“-> xi_dircacheevent”);

          String sql = XiDbUtils.getSqlQuery(“xi_dircacheevent”, 9);

          params.clear();

          params.add(“_INTEGRATION_SERVER_”);

          params.add(objectid);

          params.add(“RS”);

          params.add(“”);

          params.add(swc_name);

          params.add(XiDbUtils.getNow());

          params.add(“C”);

          params.add(“X”);

          params.add(XiDbUtils.getNow());

          utils.insertRecord(con, sql, params, new String[] { “VARCHAR2”, “RAW”,

                    “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “TIMESTAMP”, “VARCHAR2”,

                    “VARCHAR2”, “TIMESTAMP” });

     }

     public void xi_dircacherclview() {

          String table_name = “xi_dircacherclview”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 5);

          params.clear();

          params.add(objectid);

          params.add(“swc”);

          params.add(objectid);

          params.add(swcguid);

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “VARCHAR2”,

                    “RAW”, “RAW”, “NUMBER” });

     }

     public void xi_pchangelist() {

          String table_name = “xi_pchangelist”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 4);

          params.clear();

          params.add(versionsetid);

          params.add(“”);

          params.add(“4”);

          params.add(owner);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “VARCHAR2”,

                    “NUMBER”, “VARCHAR2” });

     }

     public void xi_pdevline() {

          String table_name = “xi_pdevline”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 4);

          params.clear();

          params.add(versionsetid_1_cons);

          params.add(“1”);

          params.add(ownerrepid);

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “NUMBER”,

                    “RAW”, “NUMBER” });

          params.clear();

          params.add(versionsetid_2_dev);

          params.add(“1”);

          params.add(ownerrepid);

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “NUMBER”,

                    “RAW”, “NUMBER” });

     }

     public void xi_pverrelation() {

          String table_name = “xi_pverrelation”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 14);

          params.clear();

          params.add(relationid);

          params.add(versionsetid);

          params.add(versionsetid_2_dev);

          params.add(objectid);

          params.add(XiDbUtils.generateZeros(32));

          params.add(XiDbUtils.generateZeros(32));

          params.add(“0”);

          params.add(versionid);

          params.add(relationid);

          params.add(“1”);

          params.add(“1”);

          params.add(“2”);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “RAW”, “RAW”, “RAW”, “RAW”, “NUMBER”, “RAW”, “RAW”, “NUMBER”,

                    “NUMBER”, “NUMBER”, “VARCHAR2”, “TIMESTAMP” });

     }

     public void xi_pversion() {

          String table_name= “xi_pversion”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 12);

          params.clear();

          params.add(versionid);

          params.add(objectid);

          params.add(relationid);

          params.add(“1”);

          params.add(“2”);

          params.add(“0”);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          params.add(“2”);

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “RAW”, “NUMBER”, “NUMBER”, “NUMBER”, “VARCHAR2”, “TIMESTAMP”,

                    “TIMESTAMP”, “NUMBER”, “NUMBER”, “NUMBER” });

     }

     public void xi_pversionedobj() {

          String table_name = “xi_pversionedobj”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 5);

          params.clear();

          params.add(objectid);

          params.add(“1”);

          params.add(“XI_Model_1.0”);

          params.add(“1”);

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “NUMBER”,

                    “VARCHAR2”, “NUMBER”, “NUMBER” });

     }

     public void xi_pversionset() {

          String table_name = “xi_pversionset”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 20);

          params.clear();

          params.add(versionsetid_1_cons);

          params.add(“”);

          params.add(“CONS:” + swc_name + “, 1.0 of ” + vendor);

          params.add(“Consolidation devline for ” + swc_name + “, 1.0 of “

                    + vendor);

          params.add(“3”);

          params.add(“1”);

          params.add(“2”);

          params.add(“2”);

          params.add(“1”);

          params.add(“1”);

          params.add(“0”);

          params.add(“1”);

          params.add(“0”);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          params.add(“0”);

          params.add(“”);

          params.add(“1”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “VARCHAR2”, “VARCHAR2”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”,

                    “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “VARCHAR2”,

                    “TIMESTAMP”, “TIMESTAMP”, “NUMBER”, “NUMBER”, “VARCHAR2”,

                    “NUMBER” });

          params.clear();

          params.add(versionsetid_2_dev);

          params.add(“”);

          params.add(“DEV:” + swc_name + “, 1.0 of ” + vendor);

          params

                    .add(“Development devline for ” + swc_name + “, 1.0 of “

                              + vendor);

          params.add(“3”);

          params.add(“1”);

          params.add(“2”);

          params.add(“2”);

          params.add(“1”);

          params.add(“1”);

          params.add(“0”);

          params.add(“1”);

          params.add(“0”);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          params.add(“0”);

          params.add(“”);

          params.add(“1”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “VARCHAR2”, “VARCHAR2”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”,

                    “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “VARCHAR2”,

                    “TIMESTAMP”, “TIMESTAMP”, “NUMBER”, “NUMBER”, “VARCHAR2”,

                    “NUMBER” });

          params.clear();

          params.add(versionsetid);

          params.add(versionsetid_2_dev);

          params.add(“_INITIAL_SWCV_CREATION”);

          params.add(“INITIAL_SWCV_CREATION”);

          params.add(“3”);

          params.add(“2”);

          params.add(“1”);

          params.add(“2”);

          params.add(“1”);

          params.add(“2”);

          params.add(“0”);

          params.add(“2”);

          params.add(“0”);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          params.add(“0”);

          params.add(“”);

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “VARCHAR2”, “VARCHAR2”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”,

                    “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “VARCHAR2”,

                    “TIMESTAMP”, “TIMESTAMP”, “NUMBER”, “NUMBER”, “VARCHAR2”,

                    “NUMBER” });

     }

     public void xi_pvsetelement() {

          String table_name = “xi_pvsetelement”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 12);

          params.clear();

          params.add(versionsetid);

          params.add(objectid);

          params.add(versionid);

          params.add(“0”);

          params.add(“3”);

          params.add(“0”);

          params.add(“0”);

          params.add(XiDbUtils.getNow());

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          params.add(“0”);

          params.add(“”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “RAW”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “TIMESTAMP”,

                    “TIMESTAMP”, “NUMBER”, “NUMBER”, “RAW” });

          params.clear();

          params.add(versionsetid_2_dev);

          params.add(objectid);

          params.add(versionid);

          params.add(“0”);

          params.add(“3”);

          params.add(“0”);

          params.add(“0”);

          params.add(XiDbUtils.getNow());

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          params.add(“0”);

          params.add(“”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “RAW”, “NUMBER”, “NUMBER”, “NUMBER”, “NUMBER”, “TIMESTAMP”,

                    “TIMESTAMP”, “NUMBER”, “NUMBER”, “RAW” });

     }

     public void xi_pvsetelemhist() {

          String table_name = “xi_pvsetelemhist”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 9);

          params.clear();

          params.add(versionsetid_2_dev);

          params.add(“1”);

          params.add(objectid);

          params.add(versionid);

          params.add(“1”);

          params.add(“0”);

          params.add(XiDbUtils.getNow());

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “NUMBER”,

                    “RAW”, “RAW”, “NUMBER”, “NUMBER”, “TIMESTAMP”, “TIMESTAMP”,

                    “NUMBER” });

     }

     public void xi_pvsintegration(String seqno) {

          String table_name = “xi_pvsintegration”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 6);

          params.clear();

          params.add(seqno);

          params.add(versionsetid_2_dev);

          params.add(versionsetid);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “NUMBER”, “RAW”,

                    “RAW”, “VARCHAR2”, “TIMESTAMP”, “NUMBER” });

     }

     public void xi_repcacheevent() {

          String table_name = “xi_repcacheevent”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 7);

          params.clear();

          params.add(objectid);

          params.add(“RS”);

          params.add(XiDbUtils.generateZeros(32));

          params.add(owner);

          params.add(swc_name);

          params.add(“X”);

          params.add(XiDbUtils.getNow());

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “VARCHAR2”,

                    “RAW”, “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “TIMESTAMP” });

     }

     public void xi_repchangelist() {

          String table_name = “xi_repchangelist”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 3);

          params.clear();

          params.add(versionsetid);

          params.add(objectid);

          params.add(XiDbUtils.generateZeros(32));

          utils.insertRecord(con, sql, params,

                    new String[] { “RAW”, “RAW”, “RAW” });

     }

     public void xi_repdataadmin() {

          String table_name = “xi_repdataadmin”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 7);

          params.clear();

          params.add(versionid);

          params.add(objectid);

          params.add(“swc”);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          params.add(owner);

          params.add(versionid);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “RAW”,

                    “VARCHAR2”, “VARCHAR2”, “TIMESTAMP”, “VARCHAR2”, “RAW” });

     }

     public void xi_repdataswcibrep() {

          String table_name = “xi_repdataswcibrep”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 8);

          params.clear();

          params.add(versionid);

          params.add(” “);

          params.add(” “);

          params.add(” “);

          params.add(” “);

          params.add(” “);

          params.add(“X”);

          params.add(“X”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “VARCHAR2”,

                    “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “VARCHAR2”,

                    “VARCHAR2” });

     }

     public void xi_repkeyswc() {

          String table_name = “xi_repkeyswc”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 6);

          params.clear();

          params.add(objectid);

          params.add(“swc”);

          params.add(“0”);

          params.add(vendor);

          params.add(swc_name);

          params.add(“1.0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “VARCHAR2”,

                    “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “VARCHAR2” });

     }

     public void xi_repswc_fixeddef() {

          String table_name = “xi_repswc_fixeddef”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 9);

          params.clear();

          params.add(swcguid);

          params.add(swc_name + “, 1.0 of ” + vendor);

          params.add(versionsetid_2_dev);

          params.add(versionsetid_1_cons);

          params.add(vendor);

          params.add(swc_name);

          params.add(XiDbUtils.generateZeros(32));

          params.add(owner);

          params.add(XiDbUtils.getNow());

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “VARCHAR2”,

                    “RAW”, “RAW”, “VARCHAR2”, “VARCHAR2”, “RAW”, “VARCHAR2”,

                    “TIMESTAMP” });

     }

     public void xi_repswc_line() {

          String table_name = “xi_repswc_line”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 5);

          params.clear();

          params.add(swc_name);

          params.add(vendor);

          params.add(swc_name + ” of ” + vendor);

          params.add(owner);

          params.add(XiDbUtils.getNow());

          utils.insertRecord(con, sql, params, new String[] { “VARCHAR2”,

                    “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “TIMESTAMP” });

     }

     public void xi_repswc_sp() {

          String table_name = “xi_repswc_sp”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 8);

          params.clear();

          params.add(swcguid);

          params.add(“0”);

          params.add(vendor);

          params.add(swc_name);

          params.add(“0”);

          params.add(“0”);

          params.add(swc_name + “, 1.0 of ” + vendor);

          params.add(XiDbUtils.generateZeros(32));

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “NUMBER”,

                    “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “VARCHAR2”, “VARCHAR2”,

                    “RAW” });

     }

     public void xi_reptexthead() {

          String table_name = “xi_reptexthead”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 4);

          params.clear();

          params.add(versionid);

          params.add(“0”);

          params.add(“EN”);

          params.add(“0”);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “NUMBER”,

                    “VARCHAR2”, “NUMBER” });

     }

     public void xi_reptextshort() {

          String table_name = “xi_reptextshort”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 2);

          params.clear();

          params.add(versionid);

          params.add(” “);

          utils

                    .insertRecord(con, sql, params, new String[] { “RAW”,

                              “VARCHAR2” });

     }

     public void xi_reptextshort_tx() {

          String table_name = “xi_reptextshort_tx”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 4);

          params.clear();

          params.add(versionid);

          params.add(” “);

          params.add(“EN”);

          params.add(” “);

          utils.insertRecord(con, sql, params, new String[] { “RAW”, “VARCHAR2”,

                    “VARCHAR2”, “VARCHAR2” });

     }

     

     public String doCreate(String seqno)

     {

          xi_dircacheevent();

          xi_dircacherclview();

          xi_pchangelist();

          xi_pdevline();

          xi_pverrelation();

          xi_pversion();

          xi_pversionedobj();     

          xi_pversionset();

          xi_pvsetelement();

          xi_pvsetelemhist();

          xi_pvsintegration(seqno);

          xi_repcacheevent();

          xi_repchangelist();

          xi_repdataadmin();

          xi_repdataswcibrep();

          xi_repkeyswc();

          xi_repswc_fixeddef();

          xi_repswc_line();

          xi_repswc_sp();

          xi_reptexthead();

          xi_reptextshort();

          xi_reptextshort_tx();          

          return versionid;

     }

     

     public void addNamespace(String ns,String order) {

          String table_name = “xi_repdataswc2ns”;

          //System.out.println(“-> ” + table_name);

          String sql = XiDbUtils.getSqlQuery(table_name, 3);

          params.clear();

          params.add(versionid);

          params.add(order);

          params.add(ns);

          utils

                    .insertRecord(con, sql, params, new String[] { “RAW”,

                              “NUMBER”,”VARCHAR2″ });

     }

}

Using these two above classes, creating a SWC using Java API
looks like…

(Note: The sequence number starting from ‘0’ just increments
for every object created in that SWC).

Screenshots are not provided because there will not be any
visible difference between a SWC created from this Java method when compared to
Integration Builder. The method provided here can be used to build Integration
Builder in any language connecting directly to SAP database externally – Try
for yourself (of course at your risk)!  

The next blog would be adding a namespace in SWC. So keep
watching…

Disclaimer:

This is just for an understanding of how XI
objects creation works from Integration builder (+to build an alternative for
Integration Builder ;-)+). Tested and works on XI 3.0 SR1 but using these Java
classes will purely be at your own risk.

To report this post you need to login first.

2 Comments

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

    1. Former Member Post author
      Hi Dmytro,

      I found that a few tablenames got changed in 7.0 (esp XI prefix changes as PI) but I haven’t did this reverse engineering process on this new version. I will give a try on 7.0 and blog on it.

      Best regards,
      Felix Jeyareuben

      (0) 

Leave a Reply