Blogs

Write Java code to generate PI interfaces
Shen Peng Active Contributor Gold: 1,500-2,499 points
Business Card
Company: iSoftstone
Posted on Dec. 16, 2009 06:33 AM in SAP Process Integration (PI), Java Programming

Subscribe.Subscribe
Print. Print
Permalink Permalink
Share

Hello, everybody. This is my first blog, finally. I wanna to get some points, and make some friends. You can also visit my msn space: http://shenpng.spaces.live.com.  I'm a fun of  NetWeaver. As a PI Consultant, I'm also interested in EP,MDM,BI.

Recently, we have hunderds of scenarios like jdbc to proxy, proxy to jdbc. on the project. I'm tired to create so many data types.I hate routine works. Then I found that, I could write a program to generate XSD, and import it for data type definition. first, I collect all  fields in one txt file for each table. collect fields of tables

My program will read all txt files in the folder, and generate XSD files like this:

XSD file

Now import the XSD one by one for data types. You can get what you want.

data type result 

Here I can generate data types for jdbc receiver and sender, and proxy, and file adapters.

Finally, I put my code pieces here(with JDK5 runtime). If you have any question please contact me.

 

Note: 1, how to use this tool, for example, Txt file sd002, got sd002_snd.xsd. Then you should define data type sd002_snd, and namespace, which should be you are working on, or you can't import the XSD.

2,Regarding occurrence. My code only handles a general situation, you can edit it as you like.

3,Regarding data type, I use 'string' for  string, date,integer. If your data is in right format ,then 'string' will work fine. You can change it to 'date' or any other type later.

4,Regarding data structure, My code will only work for a general purpose, You can use 'copy','paste','insert' button in IR. Not one-step-for-all, but save lots of effort. 

5, field name uppercase or lowercase. It depends on your database. Use Java method, toUpperCase()  or toLowerCase().

Shen Peng  Active Contributor Gold: 1,500-2,499 points is a SAP Netweaver consultant.


Comment on this article
Comment on this weblog
Showing messages 1 through 9 of 9.

Titles Only Main Topics Oldest First

  • Good one, but...
    2010-05-31 03:37:06 Saravana Kumar Kuppusamy Business Card [Reply]

    I beleive SAP should provide options to download metadata from RDBMS systems during design time. Middleware like TIBCO allow you to connect to db tables at design time, select table names, select fields and click download, and you have your XSD in the repository. Why can we have something like this from SAP for PI ? It will save this drudgery.


    Good effort thoe to automate metadata creation.

    • Good one, but...
      2010-05-31 03:40:15 Saravana Kumar Kuppusamy Business Card [Reply]

      Just an addition, i beleive tools like xmlspy allow you to download metadata from RDBMS systems and create an XSD
  • Template engines
    2009-12-24 08:26:36 Dimitris Lyberopoulos Business Card [Reply]

    I suppose you are not familiar with Velocity (velocity.apache.org) ...
    • Template engines
      2009-12-24 18:08:15 Peng Shen Business Card [Reply]

      Thank you. I know about some open source XML frameworks. But too complex to start. Sorry for my stupid coding.
      • Template engines
        2009-12-29 00:35:56 Dimitris Lyberopoulos Business Card [Reply]

        Oh, please excuse my comment! Your concept and reasoning is really concrete and useful. The Velocity template engine could simply eliminate the part of the code that creates XSD output manually. But in any case, this is a really nice, problem-solving idea.
  • Very useful
    2009-12-20 13:34:54 Daniel Graversen Business Card [Reply]

    Thanks for sharing a greate tool.
    It will make development much easier and mean less tedius work.


    /Daniel Graversen
    http://figaf.com

  • Enhancing?
    2009-12-16 14:59:06 Prateek Srivastava Business Card [Reply]

    Hello Shen,
    Have you thought about enhancing your work to create a generic code in order to include deeply nested structures too? Single level node have very limited applications usually. This topic can actually have many points involved. A few are:
    1. When you talk about JDBC receiver structure, you may add some code for making the "key" node if required.
    2. When creating any node, you also need to think about the occurrence. (Pass it in source or..?)
    3. Type of field (string, integer) could be required to pass.


    Regards,
    Prateek


Showing messages 1 through 9 of 9.