Select distinct records in Mapping with no Key field (all fields can vary)

Hi Experts,
Let me take an example (not the actual requirement but same scenario) to explain the problem where I need your help to get best possible way to resolve. This has to be achieved in mapping, don't have other options as its part of complex end 2 end scenario.
I have following input XML:
<Employee>
   <Details>
      <Id>123</Id>
      <Name>ABC</Name>
     <Role>Manager</Role>
      <Area>Bangalore</Area>
    </Details>
    <Details>
       <Id>123</Id>
       <Name>ABC</Name>
        <Role>Manager</Role>
         <Area>Pune</Area>
     </Details>
      <Details>
       <Id>123</Id>
       <Name>ABC</Name>
        <Role>Advisor</Role>
         <Area>Bangalore</Area>
     </Details>
      <Details>
       <Id>123</Id>
       <Name>ABC</Name>
        <Role>Manager</Role>
         <Area>Bangalore</Area>
       <Details>
       <Id>143</Id>
       <Name>ABC</Name>
        <Role>Manager</Role>
         <Area>Bangalore</Area>
     </Details>
</Employee>
The output XML is:
<Employee>
   <MainRec>
       <Id>123</Id>
        <Name>ABC</Name>
         <table name = 'Roles'>
               <record>
                      <Id>123</Id>
                       <Role>Manager</Role>
                        <Area>Bangalore</Area>
                  </record>
                  <record>
                      <Id>123</Id>
                       <Role>Manager</Role>
                        <Area>Pune</Area>
                  </record>
                  <record>
                      <Id>123</Id>
                       <Role>Advisor</Role>
                        <Area>Bangalore</Area>
                  </record>
              </table>
      </MainRec>
      <MainRec>
        <Id>123</Id>
        <Name>ABC</Name>
         <table name = 'Roles'>
               <record>
                      <Id>143</Id>
                       <Role>Manager</Role>
                        <Area>Bangalore</Area>
                  </record>
            </table>
        </MainRec>
</Employee>
As you can see from the example above, here I want to populate only distinct records under table, but there is no key fiield to ditunguish. Any of the 3 fields (Id, Role,Area) can vary and between 2 records if all of these fields are same then its duplicate else select it. So in above XML just discard the 4th record from the source XML and populate all others. Each record has to be checked against all other records all 3 values (ID, Role, Area). Only when none of the records have exactly the same values, populate it.
Also records with different ID come under different table node. Hope my requirement is clear, if not please let me know, i will try to explain better.
I thought of creating a UDF to achieve this but not able to decide how to match it to the output message here.
Best Regards,
Pratik

Hi,
For the main record, I think you only need to check for each unique ID, e.g
Id --> removeContext --> sort:ascending --> splitByValue:valueChanged --> collapseContext --> MainRec
For the record, however, you need to create a UDF that will filter out the duplicate values. For this, the UDF sample mentioned here contained multipleResult lists
Id --> removeContext --> concat: : --> concat: : --> UDF --> splitByValue:ValueChanged --> record
role --> removeContext --> /          /                \ --> Id
area --> removContext -------------> /                  \ --> role
                                                         \ --> area
Context type UDF
Arguments: input
Result: IdResult
Result: roleResult
Result: areaResult
Vector temp = new Vector();
for(int a=0;a<input.length;a++){
   if(!temp.contains(input[a])
         temp.add(input[a]);
for(int a=0;a<temp.size();a++){
   String tmp = (String) temp.get(a);
   /*split according to field */
   IdResult.addValue(tmp.substring(0,tmp.indexOf(":")));
   roleResult.addValue(tmp.substring(tmp.indexOf(":")+1,tmp.lastIndexOf(":")));
   areaResult.addValue(tmp.substring(tmp.lastIndexOf(":")+1,tmp.length()));
note: Id and record will both be using the IdResult list.
Hope this helps,
Mark

Similar Messages

  • How to select multiple records in ALV with out pressing ctrl

    Hi Experts,
    Is there a way to select multiple records in ALV with out pressing ctrl button on the key board?
    Selection and deselection should allow multiple records.
    any clue is highly appreciated.
    regards,
    Ajay

    The keyboard always plays a role, although with the Shift key you can select blocks of records.
    ○       CTRLclick, CTRLspacebar
    Toggles a selection.
    ○       SHIFTclick, CTRLshift
    Selects the area from the lead selection to the row selected. If no lead selection is set, the selection starts from the first row. In the multiNoLead mode, the selection starts from the row last selected

  • JSF/ADF - Referencing a Map with Integer keys

    I'm generating several ADF input text boxes from a HashMap using Java code in my managed bean. The Map contains Integer keys and String values. Each input text corresponds to a key/value pair.
    I'm trying to build a string to bind the text box to the String object, but I'm struggling with the EL syntax for Maps. I know a Map with String keys would look like this:
    #{bean.object.map['stringKey']}
    But is it possible to specify a non-String key?
    Thank you.

    Hi,
    why don't you try it ? My assumption is that yes, it
    will work because Integer objects have a toString()
    method
    FrankI'm building the binding string in my bean, so Integer's value is inserted, resulting in:
    #{bean.object.map[1]}
    I don't believe the EL supports this for Maps. At least I wasn't able to get it to work. I also tried:
    #{bean.object.map['1']}
    This suggest a string '1' which isn't right either. My guess is that it isn't possible, but I'm hoping someone can prove me wrong.
    From searching the forum I've read that calling processUpdates() might eliminate the need for the ValueBinding step, but I'm not sure. If I called:
    component.setValue(myString);
    Then processUpdates() on each component after the form submit, would this get the its text back to the bean object? If so, could the code go in the form's save action method?
    Thanks.

  • "Select Distinct Records" Option Not Available

    Hello Experts.
    I am working on a new report in CR XI, and noticed that I had many duplicate records.  I went to the File; Report Options; and expected to click on "Select Distinct Records", but that choice was grayed-out.  What would have caused me to lose this option, and how do I fix it?
    Thanks in advance for your help.

    Not sure if this covers it or not, but....
    The Select Distinct Records command is only available for ODBC, OLE DB, and SQL native drivers; it is not available for Stored Procedures. Note also that your server may automatically sort returned values if no sort is specified in Crystal Reports.

  • Unique data record means you can't  update a record from ECC with same key.

    Unique data record means you can't  update a record from ECC with same key fileds right?
    Details: For example i have two requests Req1 and Req2 in DSO with unique data record setting checked. on day one Req1 has a filed quantity with value 10 in Active data table. On day two Req1 can not be overwitten from ECC with Req2 with the same key fields but different value 20 in the filed quantity because of the Unique data record settings. finally the delta load fails from ECC going to DSO because of this setting. is it right?
    I think we can only use unique record setting going from DSO to cube right?
    Please give me a simple scenario in which we can use this setting.
    I already search the threads and will assign points only to valuable information.
    Thanks in advance.
    York

    Hi Les,
    Unique Data Records:
    With the Unique Data Records indicator, you determine whether only unique data records are to be updated to the ODS object. This means that you cannot load a data record into the ODS object the key combination for which already exists in the system – otherwise a termination occurs. Only use this setting when you are sure that only unique data records are to be loaded into the ODS object (for example, single documents). A typical application of this is in the loading of mass data. It improves the load performance.
    Hope it Helps
    Srini

  • TS1297 My numbers / symbols 1-9 / !-(  do not work on my wireless key pad.  I have tried the resolution information but, still no response with those keys only.  I can only type these keys with the keyboard viewer.  Any suggestions?

    My numbers & symbols 1-9 / !-(  do not work on my wireless key pad.  I have tried the resolution information but, still no response with those keys only.  I can type these keys with the keyboard viewer, thankfully.  Any suggestions?

    Unable to type while Mouse Keys is enabled in OS X

  • I'm new to GB and I'm trying to record solo vocal with a backing track. I can get the track running OK but I can't seem to record. I think when I press record the backing track mutes and I need it running.. Thanks in advance!

    I'm new to GB and I'm trying to record solo vocal with a backing track. I can get the track running OK but I can't seem to record. I think when I press record the backing track mutes and I need it running.. Thanks in advance!

    guess what it says java file. So yes i'm sure. Sarcasm. Not the best way to encourage a total stranger to help you. Then there's
    Sorry if i wasn't more clear but was that response needed?No it wasn't needed, but I'm not the one asking for help so I have the luxury of not worrying too much about it. It's extremely frustrating trying to drag relevant information out of someone, and makes one less inclined to bother.
    Anyways, there's still nothing in this thread that actually explicitly says "there is a file called VolcanoApp.java in the directory where I'm running javac from" and I really can't be bothered banging my head against the wall any longer. You've made a silly mistake, or a false assumption. We all do it from time to time. My advice is, take a break, go for a walk and re-visit this in a while. You'll probably spot the mistake right away.

  • Ipad screen is white. Restored it on iTunes. Press home and on switch goes black then back to white with no logo at all. Can't get past the white screen. This happened after running app updates. 16GB OS 7.1.1

    The ipad screen is white. Holding buttons didn't work so I restored it on iTunes. When I press home and on switch, the screen is white,  goes black then back to white with no logo at all. Can't get past the white screen. This happened after running app updates. Is there any fix besides going to Apple store? In iTunes on computer can see what is on there. 16GB OS 7.1.1

    FORCE IPAD INTO RECOVERY MODE
    1. Turn off iPad
    2. Turn on computer and launch iTunes (make sure you have the latest version of iTune)
    3. Plug USB cable into computer's USB port
    4. Hold Home button down and plug the other end of cable into docking port.
    DO NOT RELEASE BUTTON until you see picture of iTunes and plug
    5. Release Home button.
    ON COMPUTER
    6. iTunes has detected iPad in recovery mode. You must restore this iPad before it can be used with iTunes.
    7. Select "Restore iPad"...
    Note:
    1. Data will be lost if you do not have backup
    2. You must follow step 1 to step 4 VERY CLOSELY.
    3. Repeat the process if necessary.

  • I am having problems with my 3D preferences, all I can see is "Get more content" and " 3D Print Utilities"

    I am having problems with my 3D preferences, all I can see is "Get more content" and " 3D Print Utilities"

    That means either your graphics card does not support 3D or that there is a problem with your graphics drivers. See if your GPU maker has an update.
    Error: "Graphics hardware not officially supported for 3D" | Photoshop CC, 13.1

  • "Economizing" in a list of maps with identical keys (like a database table)

    Hi there!:
    I've been checking this forum for information about something like what I state in the title of this message, but haven't found such a specific case. I'm commenting my doubt below.
    I'm working with a list of maps whose keys are exactly the same in all them (they're of type String). Indeed it could be considered an extrapolation of a database table: The list contains maps which act as rows, and every map contains keys and values which represent column names and values.
    However, this means to repeat the same key values on every map and this spends memory. Right, maybe it's not such a big spent, but since the list can contains thousands of maps, I think that it would be better to choose a more "economical" way to achieve the same result.
    I had thought about building a class which stored everything as a list of lists and, internally, it mapped that String keys with the corresponding Integer indexes of every list. But then I realized that maybe I was re-inventing the wheel, because it's very probable that someone has already made that. Maybe is there a class on the Core API which allows that?
    Thank you very much for your help.

    Well, after re-reading the Java tutorial which is located in the Sun website I've came to a conclusion which I should have before, when I thought about using StringBuffers as keys of the maps instead of Strings.
    I'm so used to build Strings using literals instead of the "new String ()" constructor (just as everyone) that I had forgotten that, as it happens with any kind of object but not the primary data types, Strings are not passed to the methods by value, but by reference. The fact of them being immutable made me think that they were passed by value.
    Apart of that, my problem also was that using literals I was creating different String objects every time, despite the fact that they were equal about their content (making 400 different keys called "name" for example)
    In other words, I was doing something like this:
    // It makes a list of maps which will contain maps of boy's personal data (as if they were "rows" in a table).
    List <Map <String, Object>> listData = new ArrayList <Map <String, Object>> (listBoy.size ());
    // It loops over a list of Boy objects, obtained using EJB.
    for (Boy boy : listBoy) {
         // It makes a new map containing only the information which I'm interested on from the Boy object.
         Map <String, Object> map = new HashMap <String, Object> (2);
         map.put ("name", boy.getName ());
         map.put ("surname", boy.getSurname ());
         // It adds the map to the list of data.
         listData.add (map);
    }Well, the "problem" here (being too demanding, but I'm :P ) is that I was adding all the time new Strings objects as keys in every map. The key "name" in the first map was different from "name" in the second one and so on.
    I guess that my knowledge got messed at certain point and thought that it was impossible to use exactly the same String object in different maps (the reference, not the same value!). Thus, my idea of using StringBuffers instead.
    But thinking about it carefully, Why not to do this?:
    List <Map <String, Object>> listData = new ArrayList <Map <String, Object>> (listBoy.size ());
    // It makes the necessary String keys previously, instead of using literals on every loop later.
    String name = "name";
    String surname = "surname";
    for (Boy boy : listBoy) {
         // It uses references (pointers) to the same String keys, instead of new ones every time.
         Map <String, Object> map = new HashMap <String, Object> (2);
         map.put (name, boy.getName ());
         map.put (surname, boy.getSurname ());
         listData.add (map);
    }Unfortunately, the "hasCode" method on String is overloaded and instead of returning the typical hash code based on the single ID of the object in memory, it returns one based on its content. That way I can't make sure that the "name" key in one map refers to the same object in memory than another one. I know, I know. The common sense and the Java documentation confirm that, but had loved having an empiric way to demonstrate it.
    I guess that using "javap" and disassembling the generated bytecode is the only way to make sure that it's that way.
    I believe that it's solved now :) (if no one tells me the contrary). I still am mad at myself for thinking that Strings were passed by value. Thinking about it now it had no sense!
    dannyyates: It's curious because re-reading every answer I think that you maybe were pointing to this solution already. But the sentence "you put the +same+ string" was a little ambiguous for me and thought that you meant putting the same String as "putting the same text" (which I already was doing), not the same object reference (in other words, using a common variable). I wish we could have continued discussing that in depth. Thanks a lot for your help anyway :) .

  • Select distinct records without using distinct

    hi experts,
    my retrieved data like these:
    cnt_id cnt_type rcrd_id wrkflw_id
    558848     PRODUCT     553503     248     
    558848     PRODUCT     553503     248     
    558848     PRODUCT     553503     248     
    558808     PRODUCT     553463     248     
    558808     PRODUCT     553463     248     
    558808     PRODUCT     553463     248     
    558810     PRODUCT     553463     248     
    558810     PRODUCT     553463     248     
    558810     PRODUCT     553463     248
    now i want to select one record for each cnt_id without using any distinct function .. how can i do that?
    regards,
    SKP

    you can use the below query
    select * from t where rowid in (select max(rowid)
    from t group by cnt_id)You're query is not the equivalent of DISTINCT.
    SQL> ed
    Wrote file afiedt.buf
      1  create table t as
      2            (select 558848 as cnt_id, 'PRODUCT' as cnt_type, 553503 as rcrd_id, 248 as wrkflw_id from dual union all
      3             select 558848, 'RETURN', 553503, 248 from dual union all
      4             select 558848, 'PRODUCT', 553503, 248 from dual union all
      5             select 558808, 'PRODUCT', 553463, 248 from dual union all
      6             select 558808, 'PRODUCT', 553463, 248 from dual union all
      7             select 558808, 'PRODUCT', 553463, 248 from dual union all
      8             select 558810, 'PRODUCT', 553463, 248 from dual union all
      9             select 558810, 'PRODUCT', 553463, 248 from dual union all
    10*            select 558810, 'PRODUCT', 553463, 248 from dual)
    11  /
    Table created.
    Elapsed: 00:00:00.01
    SQL> select * from t where rowid in (select max(rowid) from t group by cnt_id);
        CNT_ID CNT_TYP    RCRD_ID  WRKFLW_ID
        558810 PRODUCT     553463        248
        558808 PRODUCT     553463        248
        558848 PRODUCT     553503        248
    Elapsed: 00:00:00.00
    SQL> select distinct * from t;
        CNT_ID CNT_TYP    RCRD_ID  WRKFLW_ID
        558810 PRODUCT     553463        248
        558808 PRODUCT     553463        248
        558848 RETURN      553503        248
        558848 PRODUCT     553503        248
    Elapsed: 00:00:00.00
    SQL>

  • Select distinct record based on column

    Hello All,
    I have a table that has more than one row as Detail for a single invoice number(screenshot below). When I create report based on this table, I get multiple rows for single invoice. I mean Invoice 000027 shows up with 5 different rows on the SSRS report.
    Is there a way I could display a single row for a single invoice? Any thoughts on this will be greatly appreciated. Thanks.
    Regards,
    Amol
    eport )

    Thank you all for your suggestions. The issue is how can I get single distinct columns after joining 2 tables (InvoiceHeader & InvoiceDetail). I am using following query in my dataset.
    SELECT DISTINCT I.recid, I.InvNumber, D.Detail, I.CompanyName, I.Addr1, I.SalesRep, I.JobNumber, I.Status, I.InvDate, I.TotalInvAmount
    FROM            InvoiceHeader AS I INNER JOIN
                             InvoiceDetails AS D ON I.InvNumber = D.InvoiceNumber
    WHERE        (I.InvNumber = @InvoiceNumber) AND (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) OR
                             (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (I.JobNumber = @JobNo) OR
                             (I.InvNumber = @InvoiceNumber) AND (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) 
                             AND (@JobNo = '') OR
                             (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (I.JobNumber = @JobNo) AND 
                             (@JobNo = '') OR
                             (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (@JobNo = '') AND 
                             (@InvoiceNumber = '')
    ORDER BY I.InvNumber DESC
    Thanks again.
    Amol

  • Select distinct records in query

    If I want to read a table in an infoset, how can I just select distinct entries from the table?
    Is it done at the infoset level or the query level?

    I've actually created the infoset for table VBFA and created a query.
    But I can't limit the output such that for each DO, show only distinct subsequent Invoice.
    eg. DO 123 has 3 items, and this DO 123 has only 1 Invoice 456, then in the output, there will be
    DO    |     Invoice
    123   |     456
    123   |     456
    123   |     456
    It's repeated 3 times because there are 3 items in VBFA for this DO. How can I create the infoset/query so that the output will be 1 entry only, ie
    DO    |     Invoice
    123   |     456
    Thanks

  • Using MAP to license keys on ALL connected machines

    Hi!
    Is it possible to read out the license keys on all connected machines, when running this from the server?

    I would like to make the distinction that MAP is just a data collection tool and does not determine compliance. Licensing is mostly about documentation and you can use MAP to help compare what it finds to what they have for license documentation. So, if
    they have 20 Windows 7 licenses but MAP finds 25 computers with Windows 7, then you know there is a problem, regardless of the product key used.
    Please remember to click "Mark as Answer" on the post that helps you, and to click
    "Unmark as Answer" if a marked post does not actually answer your question. Please
    VOTE as HELPFUL if the post helps you. This can be beneficial to other community members reading the thread.

  • Issue with DEBMAS IDoc,not all fields are reflected in the IDoc Seg E1KNB1M

    For IDoc type DEBMAS, there is a segment E1KNB1M. This segment is relate to the customer correspondence details (XD02 -> company code data -> Correspondence).
    For any change to the customer master a DEBMAS IDoc is triggered which has data in segments including the E1KNB1M.
    In my case for few customers, the not all fields in the segment E1KNB1M contain data. Few fields contain data but the rest are filled with u2018\u2019. This is happening only in the production system, for the same customer in the quality system the data is there as required.
    I checked in debugging, and found that the data is correctly passed to the segment in program SAPLVV01 Include LVV01F01. And the segment contains data till the IDoc is triggered.  I.e. the fields are not getting cleared at any point.
    Can anyone suggest what is happening and how to fix this? Please note that the issue is only in the production system and not in the quality system ( for the same customer).

    BTT... Need some help on the above

Maybe you are looking for

  • Creating a Range in BI 7.0

    Friends - We have an infoObject called Zcustomer.  Zcustomer has a navigational attribute called ZEMP (this is the number of employees at the companies - numc type).   I want to create another navigational attribute called ZEMP2 where it calculates a

  • Console font size in console mode Arch x86_64

    hi i do fresh install Archlinux 2013 x86_64. so i see some change btwin that and 2011, any way , everythings work OK, fast (KDE) but sometime i need work in console mode (ctrl+alt+f1) but i cant change resolution of console font, because now is setti

  • Determining the Directories based on a condition to poll the file

    Hi All, I have One requirement, that i want to poll the file in the target directory  based on the following condition. 1) If name1 = "ABC"   the file should go to //xi/test/file1.xml 2) If name1= "XYZ" the file should go to //xi/develop/file2.xml Ho

  • Does Adobe Reader XI work with Windows Starter 7?

    I've been having trouble downloading Adobe Reader XI. It kept hanging at 96% during the installation. I tried to restart and download again and checked for viruses, but the installation never worked. I also tried the adobe cleaner to clean the produc

  • Update calendar from year to year

    Does anyone know of a way to update a calendar created for 2007 for example to 2008? I have created a 2007 calendar last year and now I want to update the photos in it and use the same dates in there (ie birthdays) for 2008.