cancel
Showing results for 
Search instead for 
Did you mean: 

create dulicate nodes in mapping

Former Member
0 Kudos

Hi Experts,

My requirement is :

For each customer, there are 8 attributes and for each attribute there is some value. If any one of attribute is missing, PI will create that record with blank value.

If for one customer one attribute will come, PI will create another 7 records with all blank values with rest 7 attributes.

EX.

Input:

<Transaction>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>A</ATTRIBUTE>

<VALUE>10</VALUE>

</DETAIL>

</Transaction>

Output:

<Transaction>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>A</ATTRIBUTE>

<VALUE>10</VALUE>

</DETAIL>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>B</ATTRIBUTE>

<VALUE></VALUE>

</DETAIL>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>C</ATTRIBUTE>

<VALUE></VALUE>

</DETAIL>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>D</ATTRIBUTE>

<VALUE></VALUE>

</DETAIL>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>E</ATTRIBUTE>

<VALUE></VALUE>

</DETAIL>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>F</ATTRIBUTE>

<VALUE></VALUE>

</DETAIL>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>G</ATTRIBUTE>

<VALUE></VALUE>

</DETAIL>

<DETAIL>

<KUNNR>0001000007</KUNNR>

<ATTRIBUTE>H</ATTRIBUTE>

<VALUE></VALUE>

</DETAIL>

</Transaction>

Please help. Waiting for your early response.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Where exacty u are stuck?

Just duplicate target "detail" node using duplicate subtree option and map constant values(a,b,c etc.) in the "attribute" target field.

Edited - I have deleted the mapping explained above, seems it will not create correct o/p. BTW, you will always have one source "Detail" node or you can have multiple source "Detail"

Thanks

Amit Srivastava

Former Member
0 Kudos

it will have multiple Customers also

Former Member
0 Kudos

My requirement is if for one customer, one attribute is coming with value PI will create another 7 records having other attributes with space. If 3 attributes are coming , 5 additional records will be created. It is not fixed how many attribute will come.

Former Member
0 Kudos

Hello,

Ur mapping is little bit tricky...so just to avoid lot of standard functions u can use 3 UDFs.. Count, Alphabets and Value

Do remember to change the context of each soure field and set it to +1 parent node.

1) Count - Input var1 and execution type all values of a context

int j = var1.length * 8;

int count = 0;

for(int i=0;i<j;i++)

{

result.addValue("");

count = count +1;

if(count==8 && i!=j-1)

{

count = 0;

result.addContextChange();

}

}

2) Aplhabets - input var1 and execution type all values of a context

for(int i=65;i<=72;i++) {

result.addValue((char)i);

}

3) Value - input var1 and execution type all values of a context

for(int k=0;k<var1.length;k++)

{

result.addValue(var1[k]);

}

if(8 - var1.length >0)

{

for( int i =0;i<8 - var1.length;i++)

{

result.addValue("");

}

}

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Amit,

For the alphabets I had given you example , but actually there are some values associated with those like, Attributes are Copyright, CSR, CustomerGroup etc.

The target csv file structure is:

customer attribute value

1000     CSR 10

1001     Copyright 11    

There are 8 attributes with different names.  But my requirement is to repeat based on customer. For each customer I will have to create 8 records , if any value is missing for any attribute, it will send space as value. in above example it should create 16 records and other than 10 and 11, it will send blank for all other attributes.

If structure is:

1000 CSR 10
1000

Copyright 11

PI should create rest 6 records with blank values .

I had already used duplicate sub tree but issue is that it is repeating for all source nodes. I used UseOneAsMany in target node detail but it did not worked. I will try your above mentioned logic and let you know.

Former Member
0 Kudos

Hello,

>>For the alphabets I had given you example , but actually there are some values associated with those like, Attributes are Copyright, CSR, CustomerGroup etc

In that case, just pass 8 constant values for each attribute in alphabets UDF.

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Amit,

I used the above but values are not populating. I used count for target detail and able to create 8 nodes correctly.

But the none of  field values are populating. Please help.

Former Member
0 Kudos

Hello,

I have tested this mapping, so i am sure it will work.

Paste ur mapping screenshot...

Thanks

Amit Srivastava

Former Member
0 Kudos

for(int k=0;k<var1.length;k++)

{

result.addValue(var1[k]);

}

if(8 - var1.length >0)

{

for( int i =0;i<8 - var1.length;i++)

{

result.addValue("");

}

}

Former Member
0 Kudos

You are not reading reply properly. You have to change the context of KUNNR, ATTRIBUTE and ATTRIBUTE_VALUE source fields and set it to "Transaction"

Comment from my reply -

Do remember to change the context of each soure field and set it to +1 parent node.

Former Member
0 Kudos

Hi Amit,

Transaction node is for sending constant fields (Header) to the csv file. Its occurrence is 1..1.

I had used count for Detail to create 8 nodes.

Can you please tell where I will use the context change.

Former Member
0 Kudos

>>Can you please tell where I will use the context change.

I am asking you to change the context of source fields in ur mapping like this...

In the mapping editor (screeshot which u have shown above), right click on "KUNNR" Source field -> context -> and select Transaction.

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Amit,

I changed it but still values not coming

Former Member
0 Kudos

>>I changed it but still values not coming

If you are following answers properly then mapping should work.

I can only help if u can provide me mapping screenshots with ur test result

Thanks

Amit Sriavstava

Former Member
0 Kudos

Hi Amit,

Please find the screen shoten shots.

When changing context of Kunnr to Transaction getting error as:

Former Member
0 Kudos

Hello,

Mapping exception is coming for "DistinguishedName" target field becoz number of arguments in the first and second input of useoneasmany function is not matching...

Paste the mapping screenshot along with "display queue"  (right click on the input functions i.e. "split by value" and "Count" UDF used just before "useoneasmany" and select display queue) for "Distinguished Name" target field.

Thanks

Amit Srivastava

Former Member
0 Kudos

Hi Amit,

Again I followed all the steps exactly mentioned above exactly. Now I am not getting that error but records are not coming as 8 or multiple of 8 .Please find all screen shots. My requirement is to get 8 records for each customer. I am pasting all 3 screen shots and test results. For test result , I am getting 8 entries but when executing only getting 1 record.

I have done the cache refresh but when testing the message mapping not getting 8 records. Please help.

Former Member
0 Kudos

Hello,

Paste ur detail node mapping along with display queue output?

Thanks

Amit Srivastava

Answers (0)