on 05-08-2009 1:30 PM
Hi,
I have a requirement where I need to sort a field based on some other field in the same parent segment.
I am using SortByKey function but my problem is,this field is not a mandatory field while the other one is always there.
But if this field is there ,it has to be sorted by the mandatory field.
Hence,if I use SortByKey and this field is absent,my mapping fails.Using exists function to check if field exists before passing it to SortByKey doesnt help.
I am trying to create my own SortByKey which takes care of such fields but I am just lost in coding for hashmaps,can anybody help me in this?
Or do we have a better approach to handle this?
Please let me know.
Thanks.
Best Regards,
Shweta
HI,
Try map with default function.
Source fieldmapwithdefaultremovecontext--sortbykey.
Regards,
Prakasu.M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am not understanding why with "exists" function you not able to sort the issue. Is your optional field going to appear in your input file in case value is not coming? If thats the scenario then check field with "equals" function with constant [](blank) and then go for a "if" function. Hope it helps you out.
Regards,
Vineetha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this way:
If => field exists => sortby
=> else => ... (mapwithdefault, ....)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shweta,
Can you try using the mapWithDefault function for the field that is not mandatory and pass the output of the mapWithDefault function to the SortWithKey
Regards,
Ravi Kanth Talagana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.