on 12-01-2014 12:27 PM
Dear Experts,
We have a scenario IDOC-PI-JDBC where we are creating Sales invoice through IDOC from ECC to PI ,We have multiple quantity from IDOC and the remaining fields are common.
For ex: We have same BELNR- material number and other fields are constant,except the two quantity fields are dynamic and we need to sum of the below two quantity fields and to send as in a single target value for both quantity fields in a one row and need to insert in DB table.
SHIPDT_GROSS_QTY,
SHIPDT_SHIP_QTY
For Ex:
Source Target
IDOC JDBC(DB table)
SHIPDT_GROSS_QTY 20
SHIPDT_SHIP_QTY 40
SHIPDT_GROSS_QTY 50
SHIPDT_SHIP_QTY 60 SHIPDT_GROSS_QTY 140
SHIPDT_SHIP_QTY 180
SHIPDT_GROSS_QTY 70
SHIPDT_SHIP_QTY 80
Best Regards,
Monikandan.
Hi Monikandan,
Now since you need to add the fields from your target structure you should use XSLT mapping over your message mapping to for the two fields SHIPDT_GROSS_QTY and SHIPDT_SHIP_QTY to get the summed amount.
Like for example the logic being:
<xsl:value-of select="sum(row/access/SHIPDT_GROSS_QTY)"/>
Similarly for second one.
Just complete the code with proper tagging it would work.
Regadrs,
Sachi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Monikandan,
You can change the occurrence of the access field to 1:1 so that only one node will come. If you are not able to change the target structure, use the copy value function to create only one access node in target.
You can also use the below mapping for adding the quality to one field in target. This Sum function is available under statistic functions.
Result
Regards,
Deepak Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Monikandan,
In your example you are trying to add all SHIPDT_GROSS_QTY and SHIPDT_SHIP_QTY to one field in target.
you can achive this using simple context UDF.
input : SHIPDT_GROSS_QTY
int result = 0;
for(int i=0,i<input.length;i++)
{
result = result + input[i];
}
result.addValue("result");
please check the syntax.
regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Harish,
For adding the quantity using the above udf fine.
But for every IDOC line items with different quantity value creates multiple access nodes.But we need single target access node contains the sum off the quantity values in DB table.
(i,e) Single row in a target side to insert in a table.
Kindly let me know how to handle in PI mapping .
Best Regards,
Monikandan.
Hi Monikandan,
Inorder to Sum the required Quantities from Source Structure you can use the Add Function in Graphical mapping (under Arithmetic) to achieve this..
Add
>>This function simply sums up the input values and produces the summation value as output
Regards,
Azhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Azhar,
This add function we already tried but for every IDOC line items with different quantity value creates multiple access nodes.But we need single target access node contains the sum off the quantity values in DB table.
Kindly let me know how to handle in PI mapping .
Best Regards,
Monikandan
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
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.