We cannot use splitting when we use aggregation function's in data mapping. There is an alternate way by the help of which splitting can be done we have taken an example of sum function below that would help in understanding this. Below are the steps that needs to be followed:
1. Create a Pre-process flow that will be triggered by the file that you have used to trigger the B2Bi flow. The process flow should be similar to attached screenshot.
2. Create a table in any database that will consist the columns Store, UPC, VoidFlag, ReturnFlag, SalesQty and Vendor.
3. This Pre-process flow will insert the source data in the database and this data will be deleted when the Parent flow(B2B Flow) will be triggered.
4. The mapping used in the Pre-ProcessFlow should be similar to attached.
5. Change the event that is used to trigger the Parent flow and specify the File target location i.e. used in Pre-ProcessFlow in this event and set it to "On File Created".
6. Modifications that need to be done in mapping:
• Place the attached mapperutilityclass.class on location AdeptiaSuiteInstalledFolder\AdeptiaSuite-5.3\AdeptiaServer\ServerKernel\customClasses after taking backup of the previous class file.(Rename the class file to mapperutilityclass.class before pasting )
• Restart the Adeptia Services i.e. Kernel and webrunner.
• Apply following for each on Root: $Input_Schema/Root/record
• Move all the Local variables to root node.
• Create a DBconnection in data mapper as shown in
• Create local variable's :
• vendor: $Input_Schema/Root/record/vendor (Similarly, create local variables for other elements i.e. store, UPC, VoidFlag etc.)
• dbVar: DBQuery {select * from table where Store='$store' and UPC='$upc' and VoidFlag='$void' and ReturnFlag='$return' and Vendor='$vendor', $MySQL, true}
• VarSum: sum($dbvar/Record/SalesQty )
• VarDeleteQuery: concat('delete from table where Store=',$apos,$store,$apos, ' and UPC=',$apos,$upc,$apos,' and VoidFlag=',$apos,$void,$apos,' and ReturnFlag=',$apos,$return,$apos,' and Vendor=',$apos,$vendor,$apos)
• VarDelete: java:MapperUtilityClass.executeDbDeleteQuery($MySQL , $varDeleteQuery )
• Apply For Each condition on record: $dbvar/Record[1]
• Apply splitting in data mapping.
• Map the following values to the target elements in textual rule as shown below:
Element Value
Store Store
UPC UPC
VoidFlag VoidFlag
ReturnFlag ReturnFlag
SalesQty $VarSum
Vendor Vendor[list]
This will provide the sum of quantities in the element "SalesQty" having other elements same.
Comments
0 comments
Article is closed for comments.