|
Home > Archive > BizTalk Server General > July 2005 > Grouping in Maps
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| M.Saishankar@gmail.com 2005-07-01, 5:54 pm |
| I have an XML Source document that looks like this
<Acct>
<type> 1 </type>
<cost>20.00</cost>
</Acct>
<Acct>
<type> 1 </type>
<cost>30.00</cost>
</Acct>
<Acct>
<type> 2 </type>
<cost>10.00</cost>
</Acct>
<Acct>
<type> 3 </type>
<cost>40.00</cost>
</Acct>
My Destination Document is
<GL>
<ACCT></ACCT>
<DEBIT></DEBIT>
</GL>
What I want to do is , create unique nodes based on the Type and Sum
the cost grouped by Similar types. For (eg) I want to create
3 GL Nodes , since we have 3 unique types in the input(1,2,3). I want
the sum of the costs in the Debit field grouped by type. For (eg)
<GL>
<ACCT>1</ACCT>
<DEBIT>20+30</DEBIT>
</GL>
<GL>
<ACCT>2</ACCT>
<DEBIT>10</DEBIT>
</GL>
<GL>
<ACCT>3</ACCT>
<DEBIT>40</DEBIT>
</GL>
My Destination Schema has the GL nodes as min occurs 0 and max occurs
unbounded. I am not sure how to do this conditional node creation in
the destination. I have watched the webcasts and browsed through a lot
of blogs and am stuck. Can someone offer me some insight on how to do
this in the BizTalk mapper?
Thanks for your help in advance!!
| |
| Neal Walters 2005-07-01, 5:54 pm |
| Try the logical-if functoid in conjunction with the value-mapping functoid.
The value-mapping is confusing at first. It's first parm is a boolean which
is the output of the logical-if. The second parm could be your cost field.
Take the output of that into a cumulative-sum functoid.
Neal Walters
http://Biztalk-Training.com
| |
| Jeff Wessling 2005-07-01, 5:54 pm |
| I had this problem and found the best way to solve it was using the XPATH
sum() function with an XPATH selection string in a Call XSLT Template
scripting functoid.
Looks like Mike Watson in this newsgroup is doing it with stardard functoids
(below)
------------------
Using
<Order xmlns="www.someNS.com">
<Detail>
<SO_DTL_STATS>RE</SO_DTL_STATS>
<SO_DTL_LBS>46500</SO_DTL_LBS>
</Detail>
<Detail>
<SO_DTL_STATS>OP</SO_DTL_STATS>
<SO_DTL_LBS>22000</SO_DTL_LBS>
</Detail>
<Detail>
<SO_DTL_STATS>CN</SO_DTL_STATS>
<SO_DTL_LBS>46500</SO_DTL_LBS>
</Detail>
</Order>
This is possible without any custom XSLT etc.
What you can do is the following:
1.Add 1 [NOT LOGICAL] (<> ) : Logical Tab : functoid to your map.
2.Add 1 [VALUE MAPPING] (-> ) : Advanced Tab : functoid to your map.
3.Add 1 [CUMALATIVE SUM] (?) : Cumlative Tab : functiod to your map.
Map the SO_DTL_STATS to the [NOT LOGICAL]. For the second functoid parameter
add CN.
Map the output to the input of your [VALUE MAPPING] with the second
parameter being the SO_DTL_LBS..
The output of this can then go into the destination xsd.
This will do a filter on you input; only summing up the values that have CN
in the SO_DTL_STATS.
If you need an example, let me know.
Cheers,
Mike Watson
-------------------
Hope either of these helps
- Jeff
<M.Saishankar@gmail.com> wrote in message
news:1120242235.146246.52020@g44g2000cwa.googlegroups.com...
>I have an XML Source document that looks like this
>
> <Acct>
> <type> 1 </type>
> <cost>20.00</cost>
> </Acct>
> <Acct>
> <type> 1 </type>
> <cost>30.00</cost>
> </Acct>
> <Acct>
> <type> 2 </type>
> <cost>10.00</cost>
> </Acct>
> <Acct>
> <type> 3 </type>
> <cost>40.00</cost>
> </Acct>
>
> My Destination Document is
> <GL>
> <ACCT></ACCT>
> <DEBIT></DEBIT>
> </GL>
>
>
> What I want to do is , create unique nodes based on the Type and Sum
> the cost grouped by Similar types. For (eg) I want to create
> 3 GL Nodes , since we have 3 unique types in the input(1,2,3). I want
> the sum of the costs in the Debit field grouped by type. For (eg)
>
> <GL>
> <ACCT>1</ACCT>
> <DEBIT>20+30</DEBIT>
> </GL>
> <GL>
> <ACCT>2</ACCT>
> <DEBIT>10</DEBIT>
> </GL>
> <GL>
> <ACCT>3</ACCT>
> <DEBIT>40</DEBIT>
> </GL>
>
> My Destination Schema has the GL nodes as min occurs 0 and max occurs
> unbounded. I am not sure how to do this conditional node creation in
> the destination. I have watched the webcasts and browsed through a lot
> of blogs and am stuck. Can someone offer me some insight on how to do
> this in the BizTalk mapper?
>
> Thanks for your help in advance!!
>
| |
| M.Saishankar@gmail.com 2005-07-01, 8:47 pm |
| Thanks guys!! Will try the Logical Functoids and post the solution
here!!
| |
| M.Saishankar@gmail.com 2005-07-22, 5:50 pm |
| Sorry!! I could not wrap my mind around it and hence used an external
assembly. Thanks for the tips though!!
|
|
|
|
|