cancel
Showing results for 
Search instead for 
Did you mean: 

Can we sort one field based on other field in messsage mapping !!

Former Member
0 Kudos

Hi Folks,

I have got source xml with couple of Vendors, Vendors has got promotions on different products with different dates. If I sort date field, product quantity is not sorting. How Can I sort both fields at the same time, if I sort Promotion date field in ascending order, the product quanitity has to sort respectively?

Any one can help in this please , any links are examples etc..

Kind Regards

Thanks in advance.

San

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi. ASandhya

You can se standar function SortByKey

Promotion date.............

product quanitity..........SortByKey.....Target.

/people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-xi-30-sp13

http://help.sap.com/saphelp_nw04/helpdata/en/2c/2d8c4024d26e1de10000000a1550b0/frameset.htm

Former Member
0 Kudos

Hi Folks,

I have tried with this function SortbyKey, it always throuing exception. That's the reason I came to you guys. Please have a look following mapping

ZY2K_DATE    ----> Remove Context -->
                                       Sortbykey  -----> Condition etc.,
ZA02_QTY   -----> Remove Context -->

if I try to see display queue on Sortbykey I am getting ' Exception'

Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Queues have different lengths in function sortByKey] in class com.sap.aii.mappingtool.flib7.NodeFunctions method sortByKey[[Ljava.lang.String;@5be18f1d, [Ljava.lang.String;@357ae80b, SortComparator.CASE_SENSITIVE, SortOrder.ASCENDING, com.sap.aii.mappingtool.tf7.rt.ResultListImpl@1818459b,

Source

<ROOT>
...<OUTPUT>          - - - -       0..unbound
.......<Group_LIN>    - - -        0..unbound
..........<Group_ZA>  - - -       0..unbound       
..............<D02_ZA>  - - -        0..unbound
..................<ZA01>QD</ZA01>
..................<ZA02>35.0</ZA02>
..................<ZA03>CT</ZA03>
..................<Z_Y2K_DATE>20100723</Z_Y2K_DATE>
..............</D02_ZA>
...........</Group_ZA>
........</Group_Lin>
....</OUTPUT>

Target

ProductDemandInfluencingEventNotification  0..unbound
...ProductDemandInfluencingEvent                 1..1
.......Item                                                           1..unbound
..........OrderForecastTimeSeries                     0..1
..............Item                                                    1..unbound
.................ValidityPeriod                                  1..1
......................StartDateTime                             0..1
......................EndDateTime                               0..1
.................Quantity                                           1..1

the above D02_ZA tag sometimes comes more than one QD with different dates. Same dates has to go under one tag with respective quantities!! This is the situation, can any solve this please?

The target tag "ProductDemandInfluencingEventNotification" will generate based on number of promotions on particular date. Ex: if one vendor has 'n' number products promotions on 3 different dates, 3 "ProductDemandinfluenceevennotifications" has to generate, that three promotion dates and quantities has to respectively.

That ZA02 (Qty) value has to go Quantity target field.

Kind Regards

San

Former Member
0 Kudos

Sandhya, this is happening because the number of inputs to SortByKey are not same. Try to look the queues and check which input field has less/more fields..

Provide the input data and your expected results with proper example.. then it will be easy for anyone on SDN to resolve your issue..

Former Member
0 Kudos

HI Sarvesh,

I don't mind to give my xml's. But these are very big. Can you please tell me how to upload xml or your email id, i will send you xmls, if you don't mind.

Regards

San

Answers (4)

Answers (4)

Former Member
0 Kudos

Problem resolved

Former Member
0 Kudos

Hi Sandhya,

Assuming quantity field is repeating with every node DO2_ZA, mapping can be applied as follows:

ZY2K_DATE -


>

DO2_ZA(Context to next higher level) --> useOneAsMany -


> sortByKey -


> Target

DO2_ZA -


> ZY2K_QTY----


>

-Supriya.

Former Member
0 Kudos

Hi Sandhya,

If the queue lengths are different, then you have to use useOneAsMany function first before using sortByKey.

Using useOneAsMany, make both the queue lengths equal and then apply output of this to sortByKey as input.

-Supriya.

Former Member
0 Kudos

Hi Supriya,

But one thing here, both fields are belongs to the same node, still do you think the queue lengths are different?

Thanks for response

Regards

San

Former Member
0 Kudos

Supriya Sawant,

You are rite. Even though both fields belong to the same node, ZA_Y2K_Date has got for only few <D02_ZA> tag. Could you please explain to me how to apply UseoneasMany function to this particular instance.

I will appreciate for your observsation.

Regards

San

Former Member
0 Kudos

You have to use SortByKey function.. just search on SDN becaus I guess there is some blog which explain how to use this..

Former Member
0 Kudos

Sorry I am removing my solution coz Luis has alredy given the same solution.. so just follow that..

Edited by: Sarvesh Singh on Aug 23, 2010 11:25 PM