Help Required with Collections

Hi,
I have retrieved a number of records from a database that each contain a "code" and a "value". The code is non-unique, e.g. I have multiple records where the code="A", the code ="B" etc.
What I want is a total of all the values per code, e.g. a total of all the values for code A, total of all thecode B values etc.
I can iterate over my records and add the codes to a Set, which gives me a collection of unique codes. Somehow I need to interate over my original list of records and check the code, then add the value to a total. I guess the psedo-code would look a little like this:
for each record
if code = "A", add the value to A's total
if code = "B", add the value to B's total
etc etc.
Is there way I can make this generic?
Sorry for the newbie question. There must be a fairly straightforward way of doing this but I have no idea what it is :(
Thanks in advance.

This should of have been done in the database code. If this is a homework restriction, you should of change your logic to:
for each record do
    if code exists in the set then
        add value to the accumulator within the set
    else
        put code with value to the setThere's no need to do a two-pass on this.

Similar Messages

  • Help required with Photoshop Elements 4.0 this has been installed on my new Toshiba laptop with windows 8.1 for some 18 months and operating well. Now it will not open, message pops up saying "attempt to access invalid address" then "application not respo

    Help required with Photoshop Elements 4.0 this has been installed on my new Toshiba laptop with windows 8.1 for some 18 months and operating well. Now it will not open, message pops up saying “attempt to access invalid address” then “application not responding” Suggestions how to access would be much appreciated. Tks. Stuart

    What is the size of your hard disk?  PSE 4 is a very old program and I suspect it is not able to access the entire hard disk on your machine.  Just a thought here.

  • Help require with installing Adobe Acrobat onto my Macbook Pro Retina.

    Help require with installing Adobe Acrobat onto my Macbook Pro Retina.
    I have successfully installed all of my creative cloud apps with the exception being acrobat.
    I cannot print from Indesign to PDF.
    I have unistalled, reinstalled and still no Adobe Acrobat.
    I now have to go back to Windows 8 and create the PDF's there.
    Any one know how to get around this issue?
    Thanks in advance
    Kelvin

    OSX has effectively killed the ability to print to pdf, (print to pdf eliminates most of the "Rich features" of current pdf).
    Export from InDesign, always, excpet for the 1% of the time where you know why print to pdf would produce a better result.

  • Help required with (soundcard) connection / settings, thanks in advan

    Help required with connection / settings between a Creative Sound Blaster Audigy Platinum EX (soundcard) and a Creative DTT3500 Digital (5. speakers).
    The problem
    No sound from any of the speakers. (Exception can plug in headphones at front)
    Background
    My computer has been recently upgraded at my local computer shop and all programs re-installed (including driver update from Creative's website). However after reconnecting speakers and restoring the original settings I?m getting no sound from any of the speakers. I?ve followed all the available advice/instructions I can find on this website and manuals to no avail.
    Set-up
    Physical
    (Digital DIN) Speakers/decoder amplifier (DTT3500) connected to the (digital out) soundcard (Audigy Platinum EX) using minijack to DIN cable. (As per instruction manual)
    Software
    Creative Audio Consul ? setting as per instructions, however have tried variations in vain. (Note: above tabs there is a select device box with SB Audigy [A0000] in it ? only option. Just wondering what [A0000] means?)
    Your advice please. A simple step by step guide would be appreciated, many thanks in advance, Jon

    "My computer has been recently upgraded at my local computer shop and all programs re-installed (including driver update from Creative's website). "
    Do you have the original installation disk?
    If so, try installing THOSE drivers, ESPECIALLY if it worked before. Be sure to uninstall what is there now, first.
    Its natural for most people to want the 'latest' drivers for their hardware. However:
    After experiencing some difficulties with some CL 'updates' for certain products, I now avoid them UNLESS I am having a PROBLEM with the existing drivers.

  • Immediate help required with this job scheduling scenario

    I have a job that needs to run a procedure hourly but not between 6:00 AM to 8:00 AM and 6:00 PM to 8:00 PM.
    Can anyone help me with how to schedule this job.

    If you use a window the job would only execute if the window opens. If for some reason the window did not open then the job would not execute.
    Windows should be used to specify which resource plan should be active for the time interval.
    In this case you are better off using FREQ=DAILY; BYHOUR=; and specify the hours.

  • Help required with Select statment..... ASAP pls

    HI All,
    Let me desc my table first .
    01                             NOT NULL VARCHAR2(5)                                                                                                                                                                                  
    02                             NOT NULL VARCHAR2(5)                                                                                                                                                                                  
    03                             NOT NULL VARCHAR2(5)                                                                                                                                                                                  
    04                             NOT NULL VARCHAR2(5)
    31                                                    This is how table has been created(Note:not by me)
    select name from  od_shift  where year=2011 and month='Feb' and  "02"='W"{code}-->no doubt this is working fine
    My problem is ...here rather putting the number directly ("01","02","03"....."31") 
    I need to take it from the first two digits of date('01-feb-2011') 
    like {code}
      select name from  od_shift  where year=2011 and month='Feb' and  to_char(to_date('01-feb-2011','dd-mon-yyyy'),'dd')='W" but this is not working
    kindly help me with this .
    Edited by: Basva on Mar 8, 2011 4:53 AM

    Pleiadian wrote:
    You could do a case statement. It's not elegant, but it works
    Edit: smon's solution is better if pl/sql is an optionI disagree, it's quite elegant given the cirumstances of that sick table. And it definitely beats a dynamic SQL solution.
    @Basva - when will you realize that your table is no good, and needs to be normalized into a more traditional relational table?
    Regards
    Peter

  • Help required with an image

    Hi all,
    I wonder if someone can help me with the following issue.
    If you see the attached image in the top left hand corner their is a square box which is a different shade to the rest of the header.
    I need to rectify this and blend it in with the rest on the header colour; however, I do not know how to do this and would appreciate some assistance in doing this.
    I'm a noobie to photoshop so any help is much appreciated.

    It seems you've copied another portion of the texture to overlay something you didn't want seen...
    As opposed to copy/paste of a rectangular region, this is almost a textbook use for Content Aware Fill, which should (assuming it works properly) match the pattern and blend the colors.
    Try selecting just the blemish or whatever you're trying to cover, then expand the selection a few pixels, then Edit - Fill - Content Aware.
    -Noel

  • Help required with User exit logic

    Hi gurus,
    Please help me with the logic I wrote for the user exit for a PP Work Center View extract structure. Here is the details of the add on fields: VGW01, VGW02, VGW03, STEUS(from table PLPO); DataSource: 2LIS_04_P_ARBPL,
    data: l_s_pp1 like MC04P_0ARB(extract structure of 2LIS_04_P_ARBPL),
    l_tabix like sy-tabix,
    lv_VGW01 like PLPO-VGW01.
    lv_VGW02 like PLPO-VGW02.
    lv_VGW03 like PLPO-VGW03.
    lv_STEUS like PLPO-STEUS.
    tables : PLPO.
    case i_datasource.
    when '2LIS_04_P_ARBPL'.
    loop at c_t_data into l_s_pp1.
    select single vgw01into lv_vgw01
    from PLPO
    where field = l_s_pp1-field.
    if sy-subrc = 0.
    l_s_pp-zzvgw01 = lv_vgw01.
    l_s_pp-zzvgw02 = lv_vgw02.
    l_s_pp-zzvgw03 = lv_vgw03.
    l_s_pp-zzsteus  = lv_steus.
    endif.
    modify c_t_data from l_s_pp1 index l_tabix.
    endloop.
    Any additional comments welcome. Thanks in advance.

    Hi,
    Try coding as per the below code
    case i_datasource.
      When '2LIS_04_P_ARBPL'.
      DATA: lt_data TYPE TABLE OF MC04P_0ARB.
      FIELD-SYMBOLS: <ls_data> TYPE MC04P_0ARB.
    Internal table for
      TYPES:
            BEGIN OF ty_tbl1,
                     lv_VGW01 TYPE PLPO-VGW01,
                     lv_VGW02 TYPE PLPO-VGW02,
                     lv_VGW03 TYPE PLPO-VGW03,
                     l_bmsch  TYPE XXXX-XXXX,
                     l_plnnr  TYPE XXXX-XXXX
                     l_datuv  TYPE XXXX-XXXX
                     l_aennr  TYPE XXXX-XXXX
                     l_plnkn  TYPE XXXX-XXXX
                     l_plnal  TYPE XXXX-XXXX
            END OF ty_tbl1.
      DATA:
             lt_tb1 type standard table of ty_tbq,
             ls_tb1 type ty_tb1.
      lt_data[] = c_t_data[].
    Read data into internal memory using jOins
      select aVGW01 aVGW02 aVGW02 aVGW02 bbmsch bplnnr bdatuv baennr bplnkn bplnal into into  CORRESPONDING FIELDS OF TABLE
      lt_tb1 from PLPO as a innerjoin XXXX as b where aXXXX=bXXXX.        
    use the internal table to get the data to the enhaced fileds
    LOOP AT lt_data ASSIGNING <ls_data>.
        read table lt_tb1 into ls_tb1
             with key XXXXX = <ls_data>-XXXX .
        if sy-subrc eq 0.
          <ls_data>-lV_VGW01 = ls_tb1-lv_VGW01,
          <ls_data>-lV_VGW02 = ls_tb1-lv_VGW02,
          <ls_data>-lV_VGW03 = ls_tb1-lv_VGW03,
          <ls_data>-bmsch    = ls_tb1-bmsch,
          <ls_data>-plnnr    = ls_tb1-plnnr,
          <ls_data>-datuv    = ls_tb1-datuv,
          <ls_data>-aennr    = ls_tb1-aennr,
          <ls_data>-plnkn    = ls_tb1-plnkn,
          <ls_data>-pln1l    = ls_tb1-plnal.
          MODIFY lt_data FROM <ls_data>.
        endif.
      ENDLOOP.
      REFRESH c_t_data.
      c_t_data[] = lt_data[].
    Note that the code is not written with the exact fields. Change the fields where necessary(also i have joined only 2 tables if needs to be joind form more than 2  table change the join statement accordingly).
    Thanks,
    Nagarjuna
    Edited by: Nagarjuna Reddy on Oct 20, 2011 3:39 AM

  • Help required with ADFS 3.0 client certificate authentication

    Hi,
    I am currently working on integrating ADFS 3.o for Single Sign On to some 3rd party services along with PKI solution. The basic requirement is that I should be able to choose client authentication certificate as an authentication method in ADFS and then
    federate user credentials to 3rd party trust for single-sign-on.
    I had done this successfully with ADFS 2.0 and that setup is working fine. I have the setup as ADFS 3.0 client authentication method enabled. When I open browser to logon, the ADFS 3.0 page displays a message as "Select a certificate that you want to
    use for authentication. If you cancel the operation, please close your browser and try again." but the certificates are not displayed for selection.
    The certificates are valid and have valid chaining to CA. Could someone help me resolve this issue?
    Thanks!
    -Chinmaya Karve

    Hi Yan,
    Thanks for your response. I have gone through the posts that you have suggested, and my setup looks pretty much as expected.
    So, as I mentioned earlier, I have 2 parallel setups with 3rd party service(SalesForce). Once of them is running ADFS 2.0 and another one has ADFS 3.0. I can logon to the third-party services, from both the setups using username/format. I can logon to SF
    using client authentication certificate from ADFS 2.0 setup, but from the same client machine, when I try to logon SF via ADFS 3.0, the browser just does not pick up any certificate. The page just shows message of "Select a certificate that you want to use
    for authentication. If you cancel the operation, please close your browser and try again.".
    I have checked the browser, and it has the right certificates. Also, the same browser/machine is used to logon to SF through ADFS 2.0 via client certificate, which works just fine !
    I am really confused now, as to whose issue this really is...
    Just to confirm, I am using Certificate Authentication from ADFS 3.0 Authentication Methods for both Intranet and Extranet.
    Any suggestion or inputs where I could have gone wrong in the setup?
    Thanks!

  • Help required with DAQ and waveform generation

    Hi,
    I'm using DAQ 6024E card for waveform acquisition using LabVIEW 8.2 version. I've also attached my vi for your reference.
    My next step is , I want to add another waveform to the acquired waveform, i.e. I mean to say if the acquired waveform is a sine wave with 60 Hz frequency and amplitude of 8V peak-to-peak, I want to finally display a wave which is 8V peak-to-peak with sinusoidally changing freuency.
    To be more clear...I want a sine wave with frequency =  60 Hz + 1*sin( 2*pie**t).
    As cane bveen seen in my vi, I can extract the phase and magnitude of the original acquired signal.
    Can anyone help me out with this...as I'm not able to figureout how should I proceed next.
    Looking forward to hear soon,
    Regards,
    Rohit
    Attachments:
    test_analog.vi ‏162 KB

    You'd probably want to use the DAQmx VI's instead of the Express VIs, when doing something more exotic. You can start by converting the existing Express VIs to code by opening their front panels and saving them as a VI.
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • Some help required with logic for a dynamic sql query

    i have below code but not sure how to resolve this problem - what i need is to be able to dynamically
    the problem:
    i have a rabbge of paratmeters coming in from a form and need to be able to create a dynamic query string to go into a prepared statement object.
    the problem i have is there are 2 fields year range and year.
    if year range is none i need to create the query string as such :
    where the value of year can be serached on exactly
    str.append("VOLUME_YEAR = ? ");the probelm is if the year range is 5 or year range is 10 i dont know how to maipulate the query string to be able to set the string such that i can then place the year value in the place holder in preparedStatement.setInt(1, year)
    how can i create the intial query string ie.- what are the possible things that i can do. - i'm thinking of things like putting some type of between or such type query statement - but not at all sure how the syntax would go - ie. how would i use the year value and how would i create this dynamic part of the query string so that the JDBC regonises it?
    thanks for any help.
    public String setVolumeYearQuerySt(String year, String yearRange, StringBuffer str){
              String volumeYearQueryString = null;
              Sring doAction= null;
              if (yearRange.equals("None")){str.append("VOLUME_YEAR = ? ");}
              else if(yearRange.equals("5 Years")){doAction = "Nothing";}
              else if (yearRange.equals("10 Years")){doAction = "Nothing";}
              return volumeYearQueryString;
              }

    Saish - thanks a lot for the code example.
    Although, i think its far too advanced for me to understand and try to manipulate it and fit my problem. I'm pretty new to programming as you can probably see from my simple if else type statements. But i'm going to give it a try and see how it goes.
    could you please be kind enough to demonstrate how i could use the above syntax to do the following. --
    i have a year being entered in form .  in the database there is a column year volume which contains year in single year value format and also in a year range  value format - thus as in below - how could i do this -
    eg.
    user can enter a value in the year field a single value or a range value - then he can select +/-5 or 10 yrs range on that value - the DB holds the values as single values and ranges as below -
    one suggested apporach is as follows if a single user is alloweed to enter only a single value in the filed and select a query range +/- 5 etc..
    volume year of �1926-1928� and the user enters �1927�, the query has to find all records where
    look for records that are �less than or equal to� 1927.  It then has to check to see if it contains a range.  For those that it finds containing a range, it has to work out what the �upper� year is and check to see if that is �greater than or equal� to 1927.  If it is, then that is a possible matchanother approach that is suggested is to have a drop down with all years from databse and user is only llowed to select value from drop down and following logic is suggested :
    Because volumes can be received as ranges (e.g. 1964-1966), some extra coding is required where the user asks for a Year Range (such as + or � 5).
    Using the Year selected from the dropdown list, split it into 2 values, a low year and a high year. For example, if �1965-1968� is selected from the year dropdown, split it into �1965� and �1968� for the low year and high year respectively. If �1964� is selected from the year dropdown, split it into �1964� and �1964�. Now take the Year Range that the user has entered into account. For example, if the user has entered 5, subtract 5 from the low year and add 5 to the high year. Using these values, include the following search criteria in the query to the database:-
    (<low year>     BETWEEN
                 left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
         AND     right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1))
    OR     (<high year>     BETWEEN
                 left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
         AND     right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1))regards - i think if i could solve the first approach that would be something good as its most user freindly
    thanks

  • Help required with Gnome 3 Input Sources

    I used CapsLock before gnome 3.6 upgrade all working fine, however new Input Sources broke my system a little bit
    I fixed my CapsLock by dconf-editor org\gnome\desktop\input-sources\xkb-options ['grp:caps_toggle', 'grp_switch', 'grp_led:caps'], but I can't get work
    - language switch indicator not working
    - show-flags does nothing anymore
    Any help fit is required because of usability issues

    Also, with Gnome 3.6 it's no longer possible to switch layouts with the Caps key. That setting is not available even in gnome-tweak-tool.
    I figured out how to do make the settings a lot more flexible, and fix all the layout bugs introduced by 3.6. This is done by configuring everything through setxkbmap and not letting gnome interfere with the settings.
    Remove all input sources, and the typing shortcuts from gnome keyboard settings window.
    Open dconf-editor and remove everything from "org\gnome\desktop\input-sources\xkb-options". I was not able to set it to nothing, but setting it to ['grp_led:caps'] worked. These 2 steps were needed not to interfere with the config described below.
    Install kbdd-git from aur, if you want separate layout for each window.
    Create a script with preferred setxkbmap settings. Here is mine, setting Caps to switch languages, and swapping alt and win keys on MacBook.
    #!/bin/sh
    setxkbmap -layout us,ru
    setxkbmap -option 'grp:caps_toggle'
    setxkbmap -option 'altwin:swap_lalt_lwin'
    # kbdd is needed to keep separate layout for each window.
    `which kbdd` && kbdd
    Launch gnome-session-properties and add this script to the list.
    Last edited by ikatson (2012-11-02 21:51:13)

  • Help required with oracle user management

    My requirement is to hide the developer toolbar that shows at the bottom of all the pages in the application. This happens when I log into the application as an administrator or a developer. When I try logging in as an end user, who does not have developer or administrator privileges, I get a message saying that " Access denied by application security check". This problem does not depend on whether I use apex security or database security for my application, in both the cases, as soon as I login to the worksapce with a user account, this message is displayed. Please help me out. Any sort of help will be appreciated.
    Message was edited by:
    shantanu

    Hi Shantanu
    When you log in to the workspace, the URL will end with something like: /pls/htmldb/f?p=4550 (it may also end with /pls/htmldb/htmldb_login)
    To log in to your application, you need to change the final number to the number of your application. For example, if your application is number 105, then change the end of the URL to: /pls/htmldb/f?p=105.
    Your application should have a login page (typically, Page 101) which should be loaded as soon as the user tries to get to your application.
    Regards
    Andy

  • Help Required with HD Backup

    Hi,
    A Friend of mine has a PC with windows on 2x Samsung 320gb HD's in Raid 0, one of the drives started to fail, so he put in his 1tb backup drive that he made a hd image using boot it dos software. He has now purchased 2x Corsair M4 128gb SSD's and made a volume Raid 0, when trying to backup from the 1tb drive the software says that a min hd of approx 320gb is required even though the total used on windows in only approx 140gb. and the new SSD volume is approx 240gb
    The software is by terrabyte.
    also when we did a hd tach with 1x ssd and 2x ssd the performance was similar, not mutch gain. I am not familiar with SSD or HD image backups so please advise. or is there any other software recomendations.
    Thanks

    Well most software imaging requires the same size as the source.  What in the
    world is the objective of a RAID 0 boot disk.  As has been said here while it
    may help load a program faster, it will not run the program faster
    Also HDtach is not a good benchmark for SSD's
    Bill Gehrke

  • Help required with payroll issue

    i got an issue with Wt 9avc we have one employee on partime who is processed for maternity leave from july 2008 every thing looks fine except her avc salary sacrifice which is at 1%of her salary so can any help help me how to go forward and what steps i need to configure.
    many thanks
    dasari

    Hi,
    you can not copy function as i know. you should create a new one and copy code from the existing function to new function and modify code for the new requirement. this will be mush easier.
    Çağatay

Maybe you are looking for

  • How do you set up iTunes 10.5 on a new computer?, How do you set up iTunes 10.5 on a new computer?

    I have a new computer  with Windows 7, Outlook and I use iTunes with an Apple iPhone 4 and a iPad. My devices have iOS5. How do you set up iTunes 10.5 on a new computer and sync these devices. I have already downloaded iTunes 10.5 on my computer. Als

  • Using PL/SQL in Reports

    Hi There I want to use a store procedure in my reprt the procedure have one in and one out parameter. My procedure is my_procedure(dname in varchar2, cp_1 out varchar2) the in value is from database and out values store into place holder column and t

  • Exporting and retaining quality

    Hi there. I'm having some issues exporting from Premiere Pro CS5 and retaining image quality. Rather than retype the problem could I ask you to have a look at the following blog post where I break down the problems I'm having and give some examples.

  • Webarchive files are not opening- what to do?

    My webarchive files are not opening.  I have a lot saved from previous months of research.  I never had a problem opening them before.  Now all of a sudden I get a page from mywebsearch that simply says "Recently closed."  All of them...even the ones

  • Reverse enginnering design back into Rose - which jars to include

    I have built some custom controls code into designer and want to reverse gen my class files back into Rose to complete my documentation. Rose keeps complianing that it cant resolve the com.bea.control.ControlContext context; (there are probably other