2022
Info | ||
---|---|---|
| ||
This feature is available from version 2.9 |
There are many cases when At times, we have to group records to construct a single message to send to an application adapter and this . This is often seen while the case when processing records which has that have multiple sub-records attached to it.
One area where we see this the most is while processing Invoices. Some applications - like QuickBooks, MS Dynamics (GP) or Intacct needs the - need Invoice request requests as a single request. However, while you a user might have this as a set of records in a single database table or view.
Lets look at an example -
Database queries, or CSV File CSV readers, often have records that are grouped together as flat responses that . The responses are not easy to convert or map, into an XML structure.
For example:-
invoice_num | date |
---|
PO | id | product_code | prod_qty | prod_amt | total | ||
---|---|---|---|---|---|---|---|
1 | 1/1/2011 | 123 | 1 | ABC | 10 | 100 | 200 |
1 | 1/1/2011 | 123 | 1 | DEF | 20 | 200 | 200 |
1 | 1/1/2011 | 123 | 1 | GHI | 30 | 300 | 200 |
2 | 2/1/2011 | 123 | 2 | ABC | 10 | 100 | 300 |
2 | 2/1/2011 | 123 | 2 | DEF | 10 | 100 | 300 |
or in a CSV file as:
Panel |
---|
invoice_num,date,poPO,idproduct_code,prod_qty,prod_amt,total |
In the above example, we have a set of records which that represents two invoices. The first (invoice_num=1) has 3 line items and . And, the second (invoice_num=2) has 2 line items. When we send a request is sent to the target application, it expects to see 2 record records request instead of 5 as described above.
To get the right grouping we will , make use of our xmlformatter XML-Formatter property capability. XMLFormatter property takes the response from the Reader and, groups it to form the right XML structure. To do so, the Reader will have a property "xmlformatter" and will be set like -as follows:
Code Block |
---|
invoice_num,date,po,id,[product_code,prod_qty,prod_amt],total
|
Any value within "[" and "]" will be treated like a sub-item where the . The column before "[" will be the driving column , - i.e. and a change in that item will create a new XML. In this example "id" becomes the grouping column.
The split create creates a node on the element just before "[" with "list". So, in the above example, the XML will be look like -the following:
Code Block |
---|
<row>
<invoice_num>value</invoice_num>
<date>value</date>
<po>value</po>
<id id="">
<list>
<product_code>value</product_code>
<prod_qty>value</prod_qty>
<prod_amt>value</prod_amt>
</list>
<list>
<product_code>value</product_code>
<prod_qty>value</prod_qty>
<prod_amt>value</prod_amt>
</list>
</id>
<total>value</total>
</row>
|
Now to map, all you have to do is map , Map the target loop structure to "id/list" along with the field maps.
Info | ||
---|---|---|
| ||
|