Multiple Values per Key - PLEASE HELP!!

hi. im trying to setup a TreeMap so it contains multiple values for each key using a List to store these values and a string as a key to reference them. however, although it compiles, i recieve a ClassCastException: java.util.ArrayList error when it runs. heres some of my code:
Map resultRelation = new TreeMap();
List list = new ArrayList();
list.add(value1);
list.add(value2);
resultRelation.put(Key, list);
i cant seem to find much useful information on this sort of thing. any help would be appreciated.

well after hours of labouring, it turns out that the code i posted is working but the problem is actually to do with printing out the values stored in the array. it was rather stupid of me but before i had created a print method which printed the key and its value from the map, assuming the value was one string not a List, and i hadn't updated it =) so the ClassCastException error was occuring because i was trying to cast the value (which is really a List) to a string in order to print it.
heres my updated printRelation method code as follows:
private static void printRelation(Map relation) {
Iterator keyIter = relation.keySet().iterator();
Iterator valueIter = relation.values().iterator();
while(keyIter.hasNext() == true) {
     String primaryKey = (String)keyIter.next();
     List foreignKey = (List)valueIter.next();
ConsoleIO.out.print(primaryKey); // ignore the ConsoleIO stuff. the key prints no prob.
Iterator iter = foreignKey.iterator();
while(iter.hasNext() == true) {
String value = (String)iter.next();
          ConsoleIO.out.print(value);
at the moment im only adding 1 value to the List as shown in my previous post. e.g.
list.add(foreignKey1);
all this works BUT im getting the wrong results. instead of printing out the key and only its values, its printing out the key and ALL the values from the text file im using. i think its either got something to do with my while loop or my casting of the List but this is all new ground for me =)
thanks.

Similar Messages

  • Selecting multiple values from a search help

    Hi Experts
    Anyone knows if it is possible to select multiple values from a search help?
    Thanks
    Gaurav

    Hi,
    You cannot select mutiple values from search help as it is linked to inputfield and hence it will accept single value only. But at the same time, you may able to pass row of values to different inputfields.
    Refer http://help.sap.com/saphelp_dm40/helpdata/en/3d/e53642e2a3ab04e10000000a1550b0/content.htm
    Thanks,
    Chandra

  • How to assigne multiple value in key of read table

    Hi gurus,
    I want read table xxxx with key field1 = ' xxx' or field1 = 'yyy'.
    how to assign multiple value as key for the same field while reading internal table.
    Regards
    sagar

    Hi ,
    You can loop the internal table like
    loop at  <table xxxx> where field1 = ' xxx' or field1 = 'yyy'
    or you can write two read statements to read the internal table in wrk area.
    read table   <table xxxx> with key field1 = ' xxx'.
    if sy-subrc <>0
    read table   <table xxxx> with key field1 = 'yyy'.
    if sy-subrc = 0
    endif.
    else.
    do your data processing.
    endif.
    Thans.

  • How to pass dynamic values to value mapping? please help!

    Hi Experts,
           I have requirement where I am using email adapter to send emails. Now the "To" email address is different for different environment. In other words:
    DEV - [email protected]
    TEST - [email protected]
    PROD - [email protected]
    When the XI code is migrated to TEST environment the email address will be [email protected] and in production it will be [email protected]
    Similarly, there are many more environments.
    Now to handle this I have decided to use value mapping where Agency refers to the type of environment.
    Now my problem is how do I use it in message mapping.
    I have wriiten a java function that returns me the type of environment. But now how to use this value for value mapping. I mean when using value mapping in message mapping we hardcode the agency (environment type).
    Is it possibel to specify a variable in value mapping for agency. The variable will be populated by java function before connecting to value mapping?
    Please help!
    Thanks
    Gopal

    Hi Gopal,
    why don't you use a "if" after your UDF. Depending on the return parameter of the UDF you call different value mappings?
    Regards Mario

  • Return multiple values from a search help

    Dear All,
    I have a table control on screen with fields:
    doc.no
    doc.type
    doc.ver
    doc.part
    I've coded a search help for doc. no. which returns a single value i.e. doc. no from the search help.
    But my reqmt. is that when the user selects a particular doc.no from search help, it should also return doc. type/ver/part
    and the corresponding table control field should be populated.
    I mean i require multiple values to be returned and populated in my screen.
    Thanks in anticipation

    Hi ,
    Please check this thread where i had done some coding and the OP himself has found the solution
    automatic population of search help value to another field in module pool ... if its a table control you have get the selected line by  using fm DYNP_GET_STEPL. Then update the values to the respective fields using DYNP_VALUES_UPDATE.

  • Selecting multiple checkboxes...Please Help!!!

    I am having an issue I have multiple checkboxes - once the checkboxes are selected, I would like some information to appear in a field and if checkbox is deselected I would like the text to disappear.
    My major problem is if all the checkboxes are selected at one time and the information appears in the textbox only one line of text will appear at once and I would also like for text to appear on separate lines and not on the same line.
    This is what I am working with now:
    if 
    (RadioButtonList4.rawValue == true) TextField.rawValue
    = "This is a value set using a script.";
    else
    TextField1.rawValue
    = "";
    Please Help
    Tammi

    Humm... did you make the Textfield multiline? (Sry but the easiest solutions often are overseen.)
    Okey I try to get what you want. I hope I got you right and didn't completly missunderstand you...
    Let's assume there are 4 checkboxes.
    Okey so the user has 5 options. He can choose each of the checkboxes and NO more or he can choose them all...
    choosing 2 out of 4 is not possible.
    javascript:
    if (this.rawValue == 1 && (checkbox1.rawValue == 1 || checkbox3.rawValue == 1 || checkbox4.rawValue == 1))
    // will select everything when more then one checkbox is selected... this one only goes for checkbox 2 the other are nearly the same though!!!
         checkbox1.rawValue = 1;
         checkbox2.rawValue = 1;
         checkbox3.rawValue = 1;
         checkbox4.rawValue = 1;
    if (this.rawValue == 0) // will deselect everything if one checkbox is deselected...
         checkbox1.rawValue = 0;
         checkbox2.rawValue = 0;
         checkbox3.rawValue = 0;
         checkbox4.rawValue = 0;
    Then you create a Textfield (where you normally input things) and put on the calculate event:
    if (checkbox1.rawValue == 1 || checkbox2.rawValue == 1 || checkbox3.rawValue == 1 || checkbox4.rawValue == 1)
    // will show up if one checkbox is checked. If you want it only to show up if all checkboxes are checked use && instead of ||
    this.presence = "visible";
    else
    this.presence = "invisible";
    if (checkbox1.rawValue == 1 && checkbox2 == 0)
    {this.rawValue = "only checkbox1 is selected";}
    if (checkbox2.rawValue == 1 && checkbox1.rawValue == 0)
    {this.rawValue = "only checkbox2 is selected";}
    if (checkbox3.rawValue == 1 && checkbox1.rawValue == 0)
    {this.rawValue = "only checkbox2 is selected";}
    if (checkbox4.rawValue == 1 && checkbox1.rawValue == 0)
    {this.rawValue = "only checkbox2 is selected";}
    //what will appear if it is only a single checkbox that is selected
    if (checkbox1.rawValue == 1 && checkbox2.rawValue == 1) //don't need the others since it is just one or all
    {this.rawValue = "all checkboxes are selected \ncheck1 \ncheck2 \ncheck3 \ncheck4"}
    The thing is, I don't think you can easily input data in static "text"fields. Since you already know how to show and hide you can do that one on your own I think ^^
    If I missunderstood you and you just want to add/change the text by the checkboxes that are selected plz say so.
    If I got you totally wrong and you just have let's say 10 checkboxes which can be selected and deselected and each one will provide a textfield with data, I can make you a little script for the calculate event...
    Just tell me how many checkboxes they are... could get much to write (especially if they are more checkboxes) but I've got a script that will create even long scripts really fast

  • Group values on Barchart - Please help Urgent

    Hi
    I am plotting a bar chart.
    I am plotting chart "on change of" first group name.and showing 3 values which i get in formulas.
    I had to place these formulas in lowest level of subgroup just above the details ( i don`t need any details).
    i am getting all the values properly.
    But it is plotting the graph with group A values as group B values.
    In other words,
    on starting group all the 3 values will be zeros.By the end of this group (after details) i will get 3 values.
    I want to plot chart with these values as starting group values.
    But as took "on change of" group name it is plotting zeros initially and the result of group A  as the result of Group B and so on.
    Please help me how can i plot chart after a group is evaluated.
    I placed my chart in report header
    Please help me .
    Haima.

    Hi
    I am using bar Chart ( side by side bar chart).
    This time i would like to explain in more detailed.Please find my layout and preview as pictures in the following links.
    [http://i34.tinypic.com/2wc48w9.jpg]
    [http://i33.tinypic.com/2603ern.jpg]
    I want show msx3 in the bar chart .so first i initialized it to zero and counted all the records which suits my criteria and showing the same value in the bar against that group.( i am explaining with one formula msx3 only..anyway remaining are similar).
    This value is initially zero and will give a count number at the end of this Group #1 Name ( plz see pictures).
    My problem is i have take "On change of" Group# 1 Name in the data of chart expert and showing the formulas ( with don`t Summarize  option checked).
    It is giving me the result properly but plotting the values of first iteration ( when the first time the group is evaluated) ans result of second iteration.I understand this is because of "on change of " option ,when it is plotting all the values will be zeros.
    I have to plot the chart with values after evaluating the group #1 but not before evaluating it.
    Please give me any idea over it.I am not an expert and it is urgent.
    Please help.
    Thanks,
    Haima

  • Problem with Logic XS Key, PLEASE HELP

    I use my G4 Powerbook laptop for live. I am running most recent version of logic.
    What happens is that Logic will load up fine, but then for no apparent reason logic will come up with an error message saying that the logic key has been removed, but i have not touched it!! I then have to restart logic.
    PLease help i have to get this sorted ASAP cuz i have a gig tomorrow nite. Cheers guys

    Hmm, it does it on both USB ports? And you haven't noticed any problems with other USB gear on those ports?
    When the key is next not recognised by Logic, go into the system profiler and find your USB port that the XS key is on - the XS key will be labelled when it's functioning correctly. Is it still recognised by the computer, or has it gone completely?

  • Read Internal Table based on Multiple Values for Key Field

    Hi Gurus,
    i have one query can you tell me how read an internal table it_kna1 for multiple values of land1 DE US IND etc.
    i had tried as below but i could not can you try and let me knwo at the earliest.
    here i want read the values with DE or US and want further prosess them.
    REPORT  YC001.
    tables kna1.
    select-options: cust for kna1-kunnr.
    data: begin of it_kna1 occurs 0,
            kunnr like kna1-kunnr,
            name1 like kna1-name1,
            land1 like kna1-land1,
            end of it_kna1.
    select kunnr name1 land1 into table it_kna1 from kna1 where kunnr in cust.
    read table it_kna1 with key land1 = ( 'DE' OR 'US' ) .
    can anybody suggest me some solution.
    Thanks,
    Jeevi.

    This should be what you need:
    REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 80 MESSAGE-ID 00.
    TABLES kna1.
    SELECT-OPTIONS: cust FOR kna1-kunnr.
    DATA: BEGIN OF it_kna1 OCCURS 0,
            kunnr LIKE kna1-kunnr,
            name1 LIKE kna1-name1,
            land1 LIKE kna1-land1,
          END OF it_kna1.
    DATA: itab_index LIKE sy-tabix.
    SELECT kunnr name1 land1
      INTO TABLE it_kna1
      FROM kna1
      WHERE kunnr IN cust.
    SORT it_kna1 BY land1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'DE'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'DE'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    SKIP 1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'US'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'US'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    Rob

  • Charging not supported with this accessory. Multiple cables...please help

    A couple weeks ago I started occasionally getting a "Charging is not supported with this accessory" error when my phone was plugged in to my wall, and car charger. Then, it would randomly start popping up when it wasn't even plugged in to anything... it got worse and now it won't even charge. It just pops on and off like I'm plugging and unplugging the cable. So I decided to restore the iphone and update again, to wipe everything off. During the restore it got to clear the software, but every time before it can finish installing everything back the iphone comes "unplugged" and now I can't even use the phone because it's stuck in recovery mode and just says to plug it into itunes. I've tried 3 different cables, and tried doing this about 6 times now. Please help, I'm at a loss... I even cleaned the port where it connects and everything. It's an iphone 4 with ATT, and I've had it for about a year...

    I tried that earlier today
    I just cleaned it again for about an hour with the toothbrush. It got almost all the way done restoring and then said an unknown error occured and the iphone shut back off. Sigh

  • Multiple iPod User Question, PLEASE HELP!

    I already own a 30GB iPod Video which is updated to 1.1 on my Mac. I purchased a 30GB iPod Video for my wife for Valentine's Day. It will need to be formatted. What do I have to do to get her new iPod updated to 1.1. Also, do I need to update it to 1.0 first before updating to 1.1, how does this work??? If it updates to 1.1 from the start am I losing precious update info from 1.0 or will that be on the 1.1 update as well? Please help!

    All 5th Gen iPods come with at least the 1.0 firmware. There is nothing earlier, you you won't br "missing out" on anything.
    To update the new iPod from 1.0 to 1.1, just run the latest iPod Updater utility on your Mac. It should be in your Applications > Utilities folder.

  • Trying to simplify multiple steps into one - please help

    I have a set up of steps to perform on 3 tables in order to populate two tables, please suggest best way (performance wise) to do this
    CREATE TABLE AE
      EID    VARCHAR2(100 BYTE),
      UKEY   VARCHAR2(1000 BYTE),
      TNAME  VARCHAR2(10 BYTE)
    CREATE TABLE TAB1V
      PID    VARCHAR2(100 BYTE),
      PUKEY  VARCHAR2(100 BYTE)
    (join ae and tab1v with this condition: ae.ukey = tab1v.pukey);
    CREATE TABLE PES
      EID    VARCHAR2(100 BYTE),
      UKEY   VARCHAR2(100 BYTE),
      TNAME  VARCHAR2(1000 BYTE)
    (join condition with other tables, use ukey)
    insert into ae (eid,ukey,tname) values ('eid1','ukey123','tname123');
    insert into ae (eid,ukey,tname) values ('eid2','ukey123','tname123');
    insert into ae (eid,ukey,tname) values ('eid3','ukey222','tname222');
    insert into ae (eid,ukey,tname) values ('eid4','ukey222','tname222');
    insert into ae (eid,ukey,tname) values ('eid5','ukey456','tname456');
    insert into ae (eid,ukey,tname) values ('eid6','ukey789','tname789');
    insert into ae (eid,ukey,tname) values ('eid7','ukey789','tname7891');
    insert into pes(eid,ukey,tname) values('eid2','ukey123','tname123');
    insert into pes(eid,ukey,tname) values('eid6','ukey789','tname789');
    insert into pes(eid,ukey,tname) values('eid5','ukey456','tname456');
    insert into pes(eid,ukey,tname) values('eid2','ukey123','tname123');
    insert into tab1v(pid,pukey) values ('pid1','ukey123');
    insert into tab1v(pid,pukey) values ('pid2','ukey222');
    insert into tab1v(pid,pukey) values ('pid3','ukey111');
    insert into tab1v(pid,pukey) values ('pid4','ukey456');
    insert into tab1v(pid,pukey) values ('pid5','ukey789');my goal:
    i have to populate two tables
    1. result_table
    CREATE TABLE RESULT_TABLE
    PID VARCHAR2(100 BYTE),
    UKEY VARCHAR2(100 BYTE),
    EID VARCHAR2(100 BYTE),
    TNAME VARCHAR2(100 BYTE),
    SRC VARCHAR2(4 BYTE)
    2. no_match table
    CREATE TABLE NO_MATCH
    PID VARCHAR2(100 BYTE),
    UKEY VARCHAR2(100 BYTE),
    my flow of logic:
    1. check all the rows that are common to both tab1v and ae table (by joining with ukey),
    if there are ukeys that are present in tab1v table, but absent in ae table, populate
    them in no_match table, I got this with below query
    select pid,pukey from tab1v
    where not exists
    (select ukey from ae
    where ae.ukey = tab1v.pukey);
    result of no_match table should be:
    pid3 ukey111
    for all those rows that match, probably populate in a staging table
    CREATE TABLE STG_TABLE1
    PID VARCHAR2(20 BYTE),
    UKEY VARCHAR2(100 BYTE),
    TNAME VARCHAR2(100 BYTE),
    EID VARCHAR2(100 BYTE)
    insert into stg_table1(pid,ukey,eid,tname)
    select a.pid,b.ukey,b.eid,b.tname
    from tab1v a, ae b
    where A.PUKEY = b.ukey
    2.After doing point 1, So if I find common rows in both tab1v and ae table (present in stg_tab1), pick up those records and check if they are present in pes table ?
    join stg_table1 and pes table with ukey again
    3. populate records found / and not found in point 2, do the following check and populate result_table
    for records found in both stg_table1 (in other words, present in both ae and tab1v) and pes, do the following check
    if each ukey has multiple same tnames attached to it (ukey123 has tname123, twice ), src should be A
    if there is unique tname per ukey (ukey456 has only tname456), src should be A
    if each ukey has multiple different tnames (ukey 789 has tname789 and tname7891), they should be populated and src column should be B
    result_table should be like below :
    PID     UKEY     EID     TNAME SRC
    pid1     ukey123     eid1     tname123 A
    pid1     ukey123     eid2     tname123 A
    pid4     ukey456     eid5     tname456 A
    pid5     ukey789     eid6     tname789       B
    pid5     ukey789     eid7     tname7891      B
    pid2     ukey222     null     tname222 A
    pid2     ukey222     null     tname222 A
    for records found in stg_table1 but absent in pes, populate the above table and same following check, but assign null to eid : (last 2 rows in above data)
    following can be used to find difference
    select pid,ukey,tname from stg_table1
    where not exists
    (select ukey from pes
    where pes.ukey = stg_table1.ukey);
    if each ukey has multiple same tnames attached to it (ukey222 has tname222, twice ), src should be A
    if there is unique tname per ukey src should be A
    if each ukey has multiple different tnames they should be populated and src should be B (none in my example data)
    I am getting the results in individual sql statements, but how do I populate result_table and no_match with above data, given the above source data with minimal sql statements and considering performace as a key factor ?

    Why so many unanswered questions? 66 (47 unresolved) . Are they really unanswered? Please review your 47 unresolved questions and give credit to the people with either HELPFUL or ANSWERED as appropriate. They will appreciate it.
    Please provide you 4 digit Oracle version number.
    In 11g you could use the INSERT ALL multi-table insert to do this: http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9014.htm
    See the above doc at 'The next examples insert into multiple tables' where you will find this excerpt:
    >
    INSERT ALL
    WHEN order_total < 1000000 THEN
    INTO small_orders
    WHEN order_total > 1000000 AND order_total < 2000000 THEN
    INTO medium_orders
    WHEN order_total > 2000000 THEN
    INTO large_orders
    SELECT order_id, order_total, sales_rep_id, customer_id
    FROM orders;
    >
    This will let you insert into both tables with one query. Your query can use an OUTER JOIN between your tables so that the key value will be NULL when a record is not found. Then your WHEN condition will check the key value and if NULL will insert into one table and if NOT NULL will insert into the other.
    Should not be a need for a staging table. Try to modify the example in the doc for your tables.

  • Default multiple values in custom search help

    Hi All,
    I created a custom search help for the vendor. The fields in the search help are LIFNR (Vendor) and KTOKK (Account Group).
    I would like to be able to set three default values for the account group. That is, when the user clicks on the dropdown to display the search help, I would like to have three values populated in the KTOKK field. Is this possible?
    Any help would be appreciated.
    Thanks!

    Hi,
    I am not sure abt default values, but if you are using this search help in any report than you can set hot keys in your search help and using hot keys, you can set some default filter values in you report's parameter.
    you can set variant in your report where parameter is having values like :: =,<hotkey>,<sel1>,<sel2>
    here <hotkey> : wht you have assingned in search help.
           <sel1>    : one of those default values you want to display.
           <sel2>    : one of those default values you want to display for the second field.
    hope it helps,
    Regards,
    Sagar

  • CMP with auto-increment primary key.Please help

    Hi all,
    I new with EJB technology so please bear with me.
    Env: 2k Server, SQL 2k Server
    Sun One(Forte EE) to develop and deploy CMP
    I got the servlet to load the data from CMP's business mehods
    is fine. Calling the findPrimaryKey is OK too. Even when I try to insert the row into DB is OK. At this time I make key PK is int AND NOT
    AUTO INCREMENT everything is OK. In the ejbCreate method
    I called setPK, setName ...It's fine.
    The problem comes when I try to make the PK(still int) to be auto-increment field.In ejbCreate not call setPK because of in SunOne IDE, under the J2EE RI tab of EJB Module property, the Auto generate SQL I set to false so that I can
    modify the SQL statement under SQL Deployment.createRow not taking the PK. I thought that will do it but it doesnot like it at all (I got Exception with transaction rollback)I just want to insert a single row with ID and name that's all.
    Then I changed the SQL statment take PK and changed the Auto Generate SQL to True and in ejbCreate the PK as one of the args and called setPK this time with null object. It doesn't like neither.(Exception Cannot set the primary key with null. That is reasonable.)
    I thought using EJB fast and clean technique would help developer to develop application with easiness.
    So I realy stuck with this, I wonder ejb 2.0 support for auto increment at all because I would like to take advantage of the auto increment feature of the DB without writing the PrimaryKeySequence generator at all.
    Am I missing something with this? May be just config thing to tell
    that my PK is auto-increment field so that when the ejbCreate called it knows not taking the PK or even not asking to call setPK in ejbCreate.
    Any help would appreciated.

    Check out this thread, there's a bunch of good info:
    http://www.theserverside.com/patterns/thread.jsp?thread_id=4976

  • Forgot WAP key,please help!!!!

    Ok,I use WRT150N model,and windows vista  if it helps...
    I'm connected at this moment,but I want to connect my PS3 wirelessly,the problem is I totaly forgot my SSID  and WAP key,I searched the whole apartment and can't find my notebook where I did put that info. ,how can find this info. on my PC,or what software may help...
    Please explain step by step,I'm reanot that good with computers! ^_^

    have you changed the router's password, if you have type it in. if you haven't, restore to factory settings by pressing reset button(at the back, red color) for 30 second and let it reboot. type 192.168.1.1 and again username blank password admin
    this will put your router in factory default, which means all your settings will be lost.
    Message Edited by luimar on 09-03-2008 05:37 PM
    l. ceron

Maybe you are looking for

  • Reports included in the page keep looping without retrieving any results

    We are facing an issue related to the behaviour of Siebel Analytics when more than 1 answer are included in a dashboard page. When a report is generated, the other reports included in the page keep looping without retrieving any results, but if I man

  • Pink vertical lines appearing on screen

    I have a G5 about 2 years old. Recently a pale pink vertical line appeared down the screen, another about 2 weeks later and today a third line appeared. They do not affect the screen's visibility, but I wander if anyone else has found a resolution to

  • Release billing doc to A/C

    Hi, While releasing the billing doc to A/C, showing below error - Balancing field "Profit Center" in line item 003 not filled. Pls help. Harsh

  • IPhone's 4S & 5 will not charge from wall charger

    Similarly to everyone else, I have updated my iPhone 5 & also 4S to IOS 6.1.3. The batteries in both phones are draining very fast just as a lot of other people are commenting on, but also both phones will not charge from various devices that do work

  • From one computer to another

    I'm transfering my 4000 songs from my laptop to a tower G4, I have transfered with them with most of the informations connected to them: names, titles, comments, track number, etc... However I am missing some important information: ratings, play coun