cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping from repeating header to unique headers.

Former Member
0 Kudos

Dear experts,

I would like to map a repeating segment of an Idoc structure to 5 segments with each different names of the target structure. The underlying fieldnames are identical. Ofcourse the number of segments in the source structure is 1, with cardinality 0...9999. Can you please advice on how to do this. (The other way around I could just use "duplicate subtree" to match the number of segments.)

Example:

<headerA>

<item>.....</item>

<item2>.....</item2>

</headerA>

<headerA>

<item>.....</item>

<item2>.....</item2>

</headerA>

<headerA>

<item>.....</item>

<item2>.....</item2>

</headerA>

.....

Target structure:

<headerA>

<item>.....</item>

<item2>.....</item2>

</headerA>

<headerB>

<item>.....</item>

<item2>.....</item2>

</headerB>

<headerC>

<item>.....</item>

<item2>.....</item2>

</headerC>

.....

Thanks in advance!

Will reward points!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can achieve the mapping just using one standard function:

copyValue()

<headerA> --> CopyValue("0") --> <headerA>

<headerA> --> CopyValue("1") --> <headerB>

<headerA> --> CopyValue("2") --> <headerC>

you can also use same way to map item level.

Regards !

Liang

Edited by: Liang Ji on Mar 17, 2008 8:10 PM

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

You can modify the above udf like below:

First you take a global variable i.

public void getValue(String[] a,ResultList result,Container container){

i=i+1;

String str[]=new String\[a.length];

for(int j=0;j<a.length;j++)

str[j]=ResultList.SUPPRESS;

str\[i-1]=a\[i-1];

for(int j=0;j<a.length;j++)

result.addValue(str[j]);

}

This udf can repeat any number of source headers to any number of different target heraders.

Regards,

Sankar Choudhury

Former Member
0 Kudos

Hi

you can use following context level UDF

Header -> getValue>Header

Item1-Item1

Item2-Item2

//write your code here

public void getValue(String[] a,ResultList result,Container container){

i=i+1;

String str[]=new String\[a.length\];

for(int j=0;j<a.length;j++)

str[j]=ResultList.SUPPRESS;

if(i==1) str[0]=a[0];

if(i==2) str[1]=a[1];

if(i==3) str[2]=a[2];

for(int j=0;j<a.length;j++)

result.addValue(str[j]); }

Edited by: Ajay Kumar on Mar 18, 2008 7:20 PM

Former Member
0 Kudos

Hi,

You may use Java mapping with SAX or DOM parser to achive this kind of scenario.

Please reply me if you need any help for the coding.

Regards

Sankar

Former Member
0 Kudos

Hi,

You can map a repeating segment of an Idoc structure to 5 segments with each different names of the target structure. You can use createIf function with some checking condition just like below.

If item equals to "PEN" then create headerA,

If item equals to "PENCIL" then create headerB and so on.For this you can check any field of source structure and create corresponding target header.

Another way is using CopyValue.

regards,

Arijit

p.s:please reward points if useful.

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi

as i can understand you, you can do your mapping one to one, because, you can assign one target value to much receiver with out any problem.

if im wromg, could you explain it a little more.

thanks

Rod

Former Member
0 Kudos

Hi,

You can do this only with JAVA or ABAP-mapping.

Regards Mario

Sample with dom4j:

results = document.selectNodes("//header");

int i = 0;

for (Iterator iter = results.iterator(); iter.hasNext();) {

Node node = (Node) iter.next();

node.setName("header"+i);

i++;

System.out.println(node.getName());

}

Former Member
0 Kudos

Do I need to import this functionality to the XI server?

Is standard JAVA sufficient?