cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert fields in source data type to XML format in a field in target data type in PI?

Former Member
0 Kudos

Hi,

I'm just a beginner in PI. And I really need help from the experts with my problem.

Scenario:

An RFC will send data to PI and will be send to 3rd party program.

What i did was:

1. Create Data type to handle mapping from RFC (DTObj1)

2. Create Data type to handle first convert fields from DTObj1 to a field in DTObj2 to an XML format. the 3rd party required this format:

<?xml version="1.0" encoding="UTF-8"?>

<ns1:MT_ExecuteProcess xmlns:ns1="http://abc.com/poc">

   <name1>/SAPTest/LoopBack</name1>

   <action1>Start</action1>

   <auth>

      <user1>xxx</user1>

      <password1>xxx</password1>

   </auth>

   <params>

                <param1 name1="Message"><![CDATA[<Message>

  <MessageHeader Originator="SAPPrototype" OriginatorRef="12345678" OriginatorVer="1" Consumer="SAPPrototype" ConsumerRef="12345678" Provider="TfSPrototype" ProviderRef="A123456" Notify="0" MsgType="ACK" />

  <AckDetail Qualifier="000">

    <Fields>

      <Field Name="T_MESSAGE_TIME                                                  " ValueType="8" Id="58">

        <Value>300412154607</Value>

      </Field>

    </Fields>

  </AckDetail>

</Message>]]></param1>

   </params>

   <options/>     

</ns1:MT_ExecuteProcess>

Fields in Blue are fields in my DTObj1.  Fields in RED are fields i have in my DTObj2. I need to transform fields from DTObj1 to name1 in XML format before i can send. Can any body help me with this? it will be a big help.

Thanks!

Jun

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi to All,

Here's the details of my requirement.

an RFC (Solution Manager) will send an alert (in fields format as design in PI using  data type). and the i need to add additional step before i can send to another 3rd party destination, and the step is to join all the fields and come up with a field tag in CDATA format... sample XML below:

<?xml version="1.0" encoding="UTF-8"?>

<ns1:MT_ExecuteProcess xmlns:ns1="http://abc.com/poc">

   <name1>/SAPTest/LoopBack</name1>

   <action1>Start</action1>

   <auth>

      <user1>xxx</user1>

      <password1>xxx</password1>

   </auth>

   <params>

                <param1 name1="Message"><![CDATA[<Message>

  <MessageHeader Originator="SAPPrototype" OriginatorRef="12345678" OriginatorVer="1" Consumer="SAPPrototype" ConsumerRef="12345678" Provider="TfSPrototype" ProviderRef="A123456" Notify="0" MsgType="ACK" />

  <AckDetail Qualifier="000">

    <Fields>

      <Field Name="T_MESSAGE_TIME                                                  " ValueType="8" Id="58">

        <Value>300412154607</Value>

      </Field>

    </Fields>

  </AckDetail>

</Message>]]></param1>

   </params>

   <options/>    

</ns1:MT_ExecuteProcess>

items in blue are fields from one of the data type i have in PI (7.1). I need help how to transform fields to this  CDATA format.

Thanks!

Former Member
Former Member
0 Kudos

Hi Amit,

Thank you for the response. upon reading the blog, it will still require a JAVA code. Is there any way is i can do this using the full feature and functionality of PI? or is this one of the requirement that limits PI's capability?

thanks!

Former Member
0 Kudos

Hi Jun,

I am sorry to say, I doubt you can achieve this requirement without using any (JAVA) custom development.

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Amit,

No worries on that i'm just hoping there's an API that i can use available in PI so i can create a user defined function in PI..that would utilize the capability of PI..any how THANK YOU for the help.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Jun,

           Its very difficult if not impossible to extract the data using UDF. I would still suggest go with java mapping. Please let us know if you need java coding help on this or not.

All the best.

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

yeah i guess i have no choice but to go with java mapping direction. now if i go java mapping, i need the following info:

1. i am using 7.1 PI, do i need java api or jar file? if yes where can i download the file?

2. is it possible (if not much ) to ask for sample java code i can use as reference to do the java  mapping?

3. sample procedure (simple) on how to do the mapping when java code is imported to PI?

thanks a lot

anupam_ghosh2
Active Contributor
0 Kudos

Hi Jun,

            There are lot of blogs in java mapping which you  can search in SCN. Now here I am answering your questions

1.

. i am using 7.1 PI, do i need java api or jar file? if yes where can i download the file?

ans) The jar file is present in your PI server . the name of the jar file is com.sap.xpi.ib.mapping.lib.jar.

The directory is shown in this article http://wiki.sdn.sap.com/wiki/display/XI/Where+to+get+the+libraries+for+XI+development

2.) to provide the sample  java code forum would require exact input xml to the mapping . From yours posts can I assume

input to mapping is

<?xml version="1.0" encoding="UTF-8"?>

<ns1:MT_ExecuteProcess xmlns:ns1="http://abc.com/poc">

   <name1>/SAPTest/LoopBack</name1>

   <action1>Start</action1>

   <auth>

      <user1>xxx</user1>

      <password1>xxx</password1>

   </auth>

   <params>

                <param1 name1="Message"><![CDATA[<Message>

  <MessageHeader Originator="SAPPrototype" OriginatorRef="12345678" OriginatorVer="1" Consumer="SAPPrototype" ConsumerRef="12345678" Provider="TfSPrototype" ProviderRef="A123456" Notify="0" MsgType="ACK" />

  <AckDetail Qualifier="000">

    <Fields>

      <Field Name="T_MESSAGE_TIME                                                  " ValueType="8" Id="58">

        <Value>300412154607</Value>

      </Field>

    </Fields>

  </AckDetail>

</Message>]]></param1>

   </params>

   <options/>    

</ns1:MT_ExecuteProcess>

The output is an xml

<Message> 

  <MessageHeader Originator="SAPPrototype" OriginatorRef="12345678" OriginatorVer="1" Consumer="SAPPrototype" ConsumerRef="12345678" Provider="TfSPrototype" ProviderRef="A123456" Notify="0" MsgType="ACK" />

  <AckDetail Qualifier="000">

    <Fields>

      <Field Name="T_MESSAGE_TIME                                                  " ValueType="8" Id="58">

        <Value>300412154607</Value>

      </Field>

    </Fields>

  </AckDetail>

</Message>

I hope you want to send this output to target.

So you need to confirm this.

3.) You have to first import the code under operation mapping. Uisng test tab test it with input xml to check whether you are getting correct output. Exact steps for importing java mapping code is shown here http://wiki.sdn.sap.com/wiki/x/BQj2D for PI 7.0, steps are same for PI 7.1 also.

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

question.. I was able to parse a CDATA (from RFC) using my own UDF... upon testing it on the PI-ESR and PI-ID i was able to parse the correct value. but when i generated the ABAP proxy for the inbound, now i'm getting an error. 

<SAP:Code area="ABAP">DYNAMIC_CALL_ILLEGAL_METHOD</SAP:Code>

is this means i need to activate something on the PI? note i just use a simple java code in UDF...hope you ca help me on this..

thanks!

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Yes doing UDF for this case is not so easy task. Please go ahead with java or xslt mapping. I would recommend to use java mapping. If you need to know more about java mapping, Please go through these links to understand how to be handled. Plus also provide us more details.

http://help.sap.com/javadocs/pi/pi711/index.html

http://wiki.sdn.sap.com/wiki/display/XI/Using+PI+7.1+API+for+Java+mapping

http://scn.sap.com/people/community.user/blog/2008/05/05/implementing-a-java-mapping-in-sap-pi-to-re...

Former Member
0 Kudos

HI to ALL,

Do you have any source materials or sample using XSLT Mapping?

iaki_vila
Active Contributor
0 Kudos

Hi Jun,

To create a CDATA, check daniel graversen's blog http://scn.sap.com/people/daniel.graversen/blog/2011/09/22/create-cdata-elements-with-xsl-in-sap-pi

(Also, don't forget to "like" or rate (or both) the blog in case you find it useful.)

To extract CDATA:

http://stackoverflow.com/questions/3708055/extract-cdata-using-xslt

Regards.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Jun,

             The XML you posted is the input xml i guess. We need exact input XML and the exact output you need. I beleive you need a java or XSLT mapping to resolve this issue. 

regards

Anupam

Former Member
0 Kudos

Hi,

the input will be when an RFC sends an alert, my object DTObj1 will capture those alerts and before i can send that to another 3rd party i send to transform to XML and mapped to another datatype DTObj2. i guess java code will solve this. But does PI have it's own XML format?

anupam_ghosh2
Active Contributor
0 Kudos

Hi Jun,

    Java mapping has capabilies to extract data from CDATA section and convert it into XML.

You need to provide following things for java mapping

1. version of PI you are working in.

2. Complete XML input to the mapping.

3. Exact output XML you need to send.

             XML format you have to provide PI cannot create its own format.

Regards

Anupam

former_member184681
Active Contributor
0 Kudos

Hi Jun,

I think writing a simple User-Defined Function that will get the required values from param1 CDATA section is the simplest solution to your problem. Then you just map:

param1 -> UDF -> target

Regards,

Greg

Former Member
0 Kudos

Hi,

Yeah i think that is my last option for now. to create a UDF..i will give it a try

anupam_ghosh2
Active Contributor
0 Kudos

Hi Jun,

            Writing an UDF to extract data from CDATA will be very difficult (if not impossible).

I would rather suggest java mapping for the same.

All the best.

Regards

Anupam

former_member200386
Active Participant
0 Kudos

use file adapter that can convert data in XML format. or use Soap Adapter it will also convert data into xml format

Former Member
0 Kudos

Thanks i will give it a try