on 04-06-2011 1:47 PM
Hi there,
i have to make a change in a PI Mapping...
Until now the mapping was looking that:
SOURCE:
<ITEM>
<KSCHL>100</KSCHL>
<VKORG>1000</VKORG>
<CNO>123456</CNO>
<DISCPRODHIER>12345</DISCPRODHIER>
<DISCAMOUNT_T>15</DISCAMOUNT_T>
<KONWA>ZRSM</KONWA>
<DISCVALIDON_T>010101</DISCVALIDON_T>
<DISCVALIDTO_T>010101</DISCVALIDTO_T>
</ITEM>
TARGET:
<ITEM>
<ZEN_CON_001>
<KSCHL>100</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>12345</PRODH1>
<KBETR>15</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
</ITEM>
Every target item was unique of a source item.
But now in the field PRODH1 the PI will get multiply values....
"12345,12346,12347,12348,12349"
e.g: <PRODHIER>12345,12346,12347,12348,12349</PRODHIER>
The mapping should create for every one of the separated values one target item ("</ZEN_CON_001>").
Then we should have 5 target Items as result of the source item with these 5 Values in PRODH1 from the example.
Should look like this:
Source:
<ITEM>
<KSCHL>100</KSCHL>
<VKORG>1000</VKORG>
<CNO>123456</CNO>
<DISCPRODHIER>12345,12346,12346</DISCPRODHIER>
<DISCAMOUNT_T>15</DISCAMOUNT_T>
<KONWA>ZRSM</KONWA>
<DISCVALIDON_T>010101</DISCVALIDON_T>
<DISCVALIDTO_T>010101</DISCVALIDTO_T>
</ITEM>
mapping target:
<ITEM>
<ZEN_CON_001>
<KSCHL>100</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>12345</PRODH1>
<KBETR>15</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
<ZEN_CON_001>
<KSCHL>100</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>12346</PRODH1>
<KBETR>15</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
<ZEN_CON_001>
<KSCHL>100</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>12347</PRODH1>
<KBETR>15</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
</ITEM>
Please can you help me at this?
I have tried to create a UDF for that, but i hadn't any success.
Thank you very much!
hi
yourmapping is simple and no UDF is needed just do this
1) map <ZEN_CON_001> with <PRODHIER> to create as meny segment as <PRODHIER> items comes.
2) map
<KSCHL> --> copyValue<targetField>
<VKORG>--> copyValue<targetField>
<CNO>--> copyValue<targetField>
<PRODHIER>--><targetField>
<KONWA>--> copyValue<targetField>
<DISCAMOUNT_T>--> copyValue<targetField>
<DISCVALIDON_T>--> copyValue<targetField>
this mapping should solve your issue
i dont remenber but maybe you will need to change the context of <PRODHIER>to ITEM when you map it with <ZEN_CON_001>
to modify the context press rigth button over <PRODHIER>>Context>ITEM
Edited by: Rodrigo Alejandro Pertierra on Apr 6, 2011 12:11 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Solved by the help of you all!
Mapped all "normal" attributes >> "CopyValue" >> target
Mapped DiscProdhier >> UDF + SplitbyValue >> PRODH1
Mapped DiscProdhier >> ITEM with UDF
Thanks for your help!!!
<ITEM>
<ZEN_CON_001>
<KSCHL>222</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>1232</PRODH1>
<KBETR>11</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
</ITEM>
<ITEM>
<ZEN_CON_001>
<KSCHL>222</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>123</PRODH1>
<KBETR>11</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
</ITEM>
<ITEM>
<ZEN_CON_001>
<KSCHL>222</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>23323</PRODH1>
<KBETR>11</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
</ITEM>
<ITEM>
<ZEN_CON_001>
<KSCHL>222</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>231</PRODH1>
<KBETR>11</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
</ITEM>
Edited by: fengel on Apr 6, 2011 5:27 PM
Initially it looked a simple case of "SplitbyValue" but this actually very speicific requirement.
Consider writing a UDF for the occurence of <ZEN_CON_001>. Bring a context change with every ","
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this logic in ur UDF:
UDF name: createList (Queue type)
Input Parameter: String list : takes the source fields to be split as input
String delim: delimiter string to separate values in the string (here "," or ", ") as required
import java.util.StringTokenizer
......... createList (String[] list, String[] delim, ResultList result, Container container)
{
StringTokenizer token = StringTokenizer(list[0], delim[0]);
while(token.hasMoreTokens())
{
result.addValue(token.nextToken());
if(token.hasMoreTokens)
result.addValue(ResultList.CC);
}
}
This UDF will return all the values in the source field in a queue as a list of values with context changes after each value. Use this UDF and its output for generating the target parent node and mapping value to the target field with proper context handling.
Hope this will suffice your requirement.
Do not forget to import java.util.StringTokenizer at the top of your udf and remember the udf should be of type Queue
Regards,
Suddhasatta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hey...
i always got the error with following inputs:
http://s7.directupload.net/images/110406/zld8xjao.png
look on screenshot above.
Edit:
Problem found...
StringTokenizer token = new StringTokenizer(list[0], delim[0]);
Now I get a first result:
Source:
<ITEM>
<KSCHL>111</KSCHL>
<VKORG>1000</VKORG>
<CNO>123456</CNO>
<DISCPRODHIER>aaa,bbb,ccc,ddd,eee</DISCPRODHIER>
<DISCAMOUNT_T>22</DISCAMOUNT_T>
<KONWA>ZRSM</KONWA>
<DISCVALIDON_T>010101</DISCVALIDON_T>
<DISCVALIDTO_T>010101</DISCVALIDTO_T>
</ITEM>
RESULT:
<ITEM>
<ZEN_CON_001>
<KSCHL>111</KSCHL>
<VKORG>1000</VKORG>
<KUNNR>123456</KUNNR>
<PRODH1>aaa</PRODH1>
<KBETR>22</KBETR>
<KONWA>ZRSM</KONWA>
<DATAB>010101</DATAB>
<DATBI>010101</DATBI>
</ZEN_CON_001>
</ITEM>
<ITEM>
<ZEN_CON_001/>
</ITEM>
<ITEM>
<ZEN_CON_001/>
</ITEM>
<ITEM>
<ZEN_CON_001/>
</ITEM>
<ITEM>
<ZEN_CON_001/>
</ITEM>
hm...
I have put in the UDF in the node ITEM and linked it with DISCPRODHIER from the Source node...
Edited by: fengel on Apr 6, 2011 5:10 PM
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.