cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass selective fields based on multiple values in Header?

Former Member
0 Kudos

Hi Experts,

I have a scenario where the XML which SAP PI is receiving from source side is like as shown below.

<HEADER>

  <indicator>name,address,workCity,Party</indicator>

  <abc>....

  <def>....

</HEADER>

<Body>

  <name>John</name>

  <surname>Adams</surname>

  <address>

  <apartment>123</apartment>

  <street>Kennedy Rd>/street>

  </address>

  <workCountry>USA</workCountry>

  <workCity>FL<workCity>

  <PartyGroup>Boston PG</PartyGroup>

  <Party>Universal</Party>

<Body>

In header it contains a tag "indicator" which includes the names of fields in a record which have changed, separated by comma.

In body we have all possible fields for a record.

The requirement is for SAP PI to read this "indicator field" in header and pick only those fields from "body" which are listed in <indicator> tag.

I have two questions:

i) Is it possible to send comma separated fields like this in an XML? Or do they need to be double quoted?

  e.g. instead of <indicator>name,address,workCity,Party</indicator> should it be:

  <indicator>"name,address,workCity,Party"</indicator>

In any case..

ii) how to implement this requirement of segregating multiple comma separated values within same tag and picking ony selective fields as mentioned earlier?

Please help, this is urgent.

Warm Regards

Saurabh

Accepted Solutions (1)

Accepted Solutions (1)

praveen_sutra
Active Contributor
0 Kudos

Hi Saurabh,

In my opinion it can be handled using Java mapping.

i) Is it possible to send comma separated fields like this in an XML? Or do they need to be double quoted?

  e.g. instead of <indicator>name,address,workCity,Party</indicator> should it be:

  <indicator>"name,address,workCity,Party"</indicator>

Answer: In java mapping you can use split function for splitting the values of indicator field.

In any case..

ii) how to implement this requirement of segregating multiple comma separated values within same tag and picking ony selective fields as mentioned earlier?

Answer: I can think of two ways to resolve this issue.

one way is you can use java mapping and in side java code you can handle the selective values using tags getting from the indicator field.

second approach could be you can break the mapping in two parts.

a) keep source and target structure same and just populate the target fields using indicator values with some dummy value.

eg: suppose if indicator contains name, address, work city  then populate these three fields with the values comming from source and rest all fields with dummy values something like XXXX.

b) and then in second mapping just check if the value in the field is "XXXX" dont create the target element.

Please let me know if you have more query's.

thanks and regards,

Praveen T

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Saurabh,


Question:1


how to implement this requirement of segregating multiple comma separated values within same tag and picking ony selective fields as mentioned earlier?

Answer:


In my opinion it can be handled using XSLT mapping. For segregating multiple comma separated values within same tag  XSLT mapping will help you to separate the data as you want.


EXample: <xsl:for-each select="POExtract/row[not(PONumber = preceding-sibling::row/PONumber)]">


Question: 2


Is it possible to send comma separated fields like this in an XML? Or do they need to be double quoted?

  e.g. instead of <indicator>name,address,workCity,Party</indicator> should it be:

  <indicator>"name,address,workCity,Party"</indicator>

Answer:

By using XSLT mapping we can change the structure as you want wasily when compared to Java Mapping. You can try this one once.

If you want any help let us know.

Regards,

Srikanth Mavuri.



Former Member
0 Kudos

Hi Saurabh ,

I have done a simple test. With both

<indicator>"name,address,workCity,Party"</indicator> AND


<indicator>name,address,workCity,Party</indicator>


The XML Syntax is coming as correct if i open on IE.


Thanks

Former Member
0 Kudos

So that leaves with second question now? That how to segregrate mulitple values within same tag. I think I may have to opt of UDF or Java mapping for this.