Need help implementing Radix sort to handle negative values

Hi !
I'm in desperate need for some help here...
I've been struggling with this Radix sort algorithm for some time now. It sorts positive integers very well, and very fast, but it cant handle negative values. Is there anyone who can help me improve this algorithm to also sort negative integer values?
I need it to be as fast or even faster then the current one, and it has to be able to sort values in an array from address x -> y.
Here's what I have so far
/** sorts an int array using RadixSort (can only handle positive values [0 , 2^31-1])
      * @param a an array to be sorted
      * @param b an array of the same size as a (a.length) to be used for temporary storage
      * @param start start position in a (included)
      * @param stop stop position in a (excluded)
     public void sort(int[] a, int[] b, int start, int stop){
          int[] b_orig = b;
          int rshift = 0, bits = 8;
          for (int mask = ~(-1 << bits); mask != 0; mask <<= bits, rshift += bits) {
               int[] cntarray = null;
               try{cntarray = new int[1 << bits];}catch(Exception e){System.out.println("Error");};
               for (int p = start; p < stop; ++p) {
                    int key = (a[p] & mask) >> rshift;
                    ++cntarray[key];
               for (int i = 1; i < cntarray.length; ++i)
                    cntarray[i] += cntarray[i-1];
               for (int p = stop-1; p >= start; --p) {
                    int key = (a[p] & mask) >> rshift;
                    --cntarray[key];
                    b[cntarray[key]+start] = a[p];
               int[] temp = b; b = a; a = temp;
          if (a == b_orig)
               System.arraycopy(a, start, b, start, stop-start);
     }I think it can be solved by offsetting all positive values the with the number of negative values found in "a" during the last run through the main for loop (as the last (or first) 8 bits in an 32 bit integer contains the prefix bit (first bit in an 32 bit integer), 0 for positive value, 1 for negative).
Thanks in advance !
/Sygard.

ah, beautiful !
/** sorts an int array using RadixSort (can handle values [-2^31 , 2^31-1])
      * @param a an array to be sorted
      * @param b an array of the same size as a (a.length) to be used for temporary storage
      * @param start start position in a (included)
      * @param stop stop position in a (excluded)
     public void sort(int[] a, int[] b, int start, int stop){
          int[] b_orig = b;
          int rshift = 0;
          for (int mask = ~(-1 << bits); mask != 0; mask <<= bits, rshift += bits) {
               int[] cntarray = null;
               try{cntarray = new int[1 << bits];}catch(Exception e){System.out.println("Error");};
               if(rshift == 24){
                    for (int p = start; p < stop; ++p) {
                         int key = ((a[p] & mask) >>> rshift) ^ 0x80;
                         ++cntarray[key];
                    for (int i = 1; i < cntarray.length; ++i)
                         cntarray[i] += cntarray[i-1];
                    for (int p = stop-1; p >= start; --p) {
                         int key = ((a[p] & mask) >>> rshift) ^ 0x80;
                         --cntarray[key];
                         b[cntarray[key]+start] = a[p];
                    int[] temp = b; b = a; a = temp;
               else{
                    for (int p = start; p < stop; ++p) {
                         int key = (a[p] & mask) >>> rshift;
                         ++cntarray[key];
                    for (int i = 1; i < cntarray.length; ++i)
                         cntarray[i] += cntarray[i-1];
                    for (int p = stop-1; p >= start; --p) {
                         int key = (a[p] & mask) >>> rshift;
                         --cntarray[key];
                         b[cntarray[key]+start] = a[p];
                    int[] temp = b; b = a; a = temp;
          if (a == b_orig)
               System.arraycopy(a, start, b, start, stop-start);
     }That's what I ended up with - and it works !
Thanks a million !!

Similar Messages

  • I need help with error ORA-06502: numeric or value error

    Hi, all, i need help finding the error here, im getting a numeric or value error when i add information to the variable vlcadena when vlcadena is a clob type, and i check the length of the vlcadena variable and sometimes makes the error at 8000 characters some other times 32k i have no idea whats happening, does anyone have a clue?
    PROCEDURE REGISTRO_551 (
    VPNUMPARTE IN PARTESC.NUMPARTE%TYPE,
    VPFRACCION IN IMPOMAT.FRACCIONMEXIMPO%TYPE,
    VPDESCRIPCION IN PARTESC.DESCESPANOL%TYPE,
    VPVALORDLS IN IMPOMAT.VALORDOLARES%TYPE,
    VPCANTIDAD IN IMPOMAT.CANTIDAD%TYPE,
    VPUNIMED IN PARTESC.UNIMEDPARTE%TYPE,
    VPCANTIDADTARIFA IN IMPOMAT.CANTIDAD%TYPE,
    VPVALORAGREGADO IN EXPOPT.VALORAGREGADO%TYPE,
    VPPAISORIGEN IN PARTESC.PAISORIGEN%TYPE,
    VPCOMPVEND IN PARTESC.PAISORIGEN%TYPE,
    VPTIPOFRACCION IN IMPOMAT.TIPOFRACCION%TYPE,
    VPPESONETO IN IMPOMAT.PESONETO%TYPE,
    VPTIPOMONEDA IN MIMPOMAT.TIPOMONEDAEXTRANJERA%TYPE
    ) AS
    BEGIN
        vgproceso := 207310;
        vllong2:=length(vlCadena);
        vlCadena:=vlCadena||'551'||'|'; --1. TIPO DE REGISTRO
        vgproceso := 207311;
        vllong2:=length(vlCadena);
        vlCadena:=vlCadena||VPFRACCION||'|'; --2. FRACCION
        vgproceso := 207312;
        vllong2:=length(vlCadena);
        QUITA_ENTERS(NVL(VPDESCRIPCION,' '),VLTEMP);
        IF LENGTH(VLTEMP)>80 THEN
            VLTEMP:=SUBSTR(VLTEMP,1,80);
        END IF;
        vgproceso := 207313;
        vllong2:=length(vlCadena);
        IF VLTEMP IS NULL THEN
            vlCadena:=vlCadena||'|'; --3. DESCRIPCION
        ELSE
            vlCadena:=vlCadena||VLTEMP||'|'; --3. DESCRIPCION
        END IF;
        vgproceso := 207314;
        vllong2:=length(vlCadena);
        IF VPNUMPARTE IS NULL THEN
            vlCadena:=vlCadena||'|';--4. NO. DE PARTE
        ELSE
            vlCadena:=vlCadena||VPNUMPARTE||'|';--4. NO. DE PARTE
        END IF;
        vgproceso := 207315;
        vllong2:=length(vlCadena);
        vlCadena:=vlCadena||VPVALORDLS||'|'; --5. VALOR MERCANCIA
        vgproceso := 207316;
        vllong2:=length(vlCadena);
        vlCadena:=vlCadena||VPCANTIDAD||'|'; --6. CANTIDAD COMERCIAL
        vgproceso := 207317;
        vllong2:=length(vlCadena);
        IF VPUNIMED IS NULL THEN
            VPDESCERROR:='ALGUNA PARTIDA CON FRACCION '||VPFRACCION||' NO TIENE UNIDAD DE MEDIDA';
        END IF;
        vgproceso := 207320;
        GET_CATGRAL('ADUANAS','UNIMED',NVL(VPUNIMED,' '),CL_D1,CL_D2,CL_D3,CL_D4,CL_V1,CL_V2,CL_V3,CL_CATG);
        IF CL_V2=0 THEN
           vlCadena:=vlCadena||VPUNIMED||'|'; --7. UNIDAD MEDIDA COMERCIAL
        ELSE
            SELECT TO_CHAR(TRUNC(CL_V2)) INTO VLUMCOMERCIAL FROM DUAL;
            IF LENGTH(VLUMCOMERCIAL)=1 THEN
                VLUMCOMERCIAL:='0'||VLUMCOMERCIAL;
            END IF;
            vlCadena:=vlCadena||VLUMCOMERCIAL||'|'; --7. UNIDAD MEDIDA COMERCIAL
        END IF;
        vlCadena:=vlCadena||VPCANTIDADTARIFA||'|';--8. CANTIDAD TARIFA
        vlCadena:=vlCadena||VPVALORAGREGADO||'|';--9. VALOR AGREGADO
        GET_CATGRAL('ADUANAS','CONFADU','IVIN-REG',CL_D1,CL_D2,CL_D3,CL_D4,CL_V1,CL_V2,CL_V3,CL_CATG);
        vlCadena:=vlCadena||CL_D1||'|'; --10. VINCULACION
        vlCadena:=vlCadena||CL_D2||'|'; --11. METODO DE VALORACION
        vlCadena:=vlCadena||'|'; --12. MARCA
        vlCadena:=vlCadena||'|'; --13. MODELO

    If the expected maximum length of the concatenated string is less than 32K, then use VARCHAR2 and at the end convert to CLOB if necesary.
    :p
    PS: At what line in the code does it give the error?
    Edited by: LKBrwn_DBA on Aug 20, 2009 2:49 PM

  • ACE - need help implementing basic parameter map

    Hi,
    I'm trying to implement a connection parameter on an ACE module that sumply sets the TCP timeout to 0.
    I can get this to work fine if I permit all TCP traffic in the class-map, but it doesn't work if I use an ACL;
    >>Match all TCP;
    parameter-map type connection TCP-Timeout
    set timeout inactivity 0
    class-map match-all TCP-Timeout-Out-Class
    2 match port tcp any
    class-map match-all TCP-Timeout-in-Class
    2 match port tcp any
    policy-map multi-match TCP-Timeout-Out-Policy
    class TCP-Timeout-Out-Class
    connection advanced-options TCP-Timeout
    policy-map multi-match TCP-Timeout-in-Policy
    class TCP-Timeout-in-Class
    connection advanced-options TCP-Timeout
    Interface vlan 920
    service-policy input TCP-Timeout-in-Policy
    Interface vlan 923
    service-policy input TCP-Timeout-Out-Policy
    >>Match ACL;
    access-list TCP-Timeout-Group-Out line 10 extended permit ip 10.221.178.0 0.0.0.255 any
    access-list TCP-Timeout-Group-in line 10 extended permit ip any 10.221.178.0 0.0.0.255
    parameter-map type connection TCP-Timeout
    set timeout inactivity 0
    class-map match-all TCP-Timeout-Out-Class
    match access-list TCP-Timeout-Group-Out
    class-map match-all TCP-Timeout-in-Class
    match access-list TCP-Timeout-Group-in
    policy-map multi-match TCP-Timeout-Out-Policy
    class TCP-Timeout-Out-Class
    connection advanced-options TCP-Timeout
    policy-map multi-match TCP-Timeout-in-Policy
    class TCP-Timeout-in-Class
    connection advanced-options TCP-Timeout
    Interface vlan 320
    service-policy input TCP-Timeout-in-Policy
    Interface vlan 323
    service-policy input TCP-Timeout-Out-Policy
    Any ideas?
    Many Thanks

    Try changing the class-map from "type match-all" to "type match-any". Match all implies both statments need to be true. The match-any is probably what you want. Either of the ACL statements can be true.
    Also try to apply the policy globally instead of the interfaces, simplifying the config might help as well.
    e.g.:
    access-list TCP-Timeout-Group line 10 extended permit ip 10.221.178.0 0.0.0.255 any
    access-list TCP-Timeout-Group line 20 extended permit ip any 10.221.178.0 0.0.0.255
    class-map match-any TCP-Timeout-Class
    match access-list TCP-Timeout-Group
    parameter-map type connection TCP-Parameter-Map
    set timeout inactivity 0
    policy-map multi-match TCP-Timeout-Out-Policy
    class TCP-Timeout-Out-Class
    connection advanced-options TCP-Parameter-Map
    service policy input TCP-Timeout-Out-Policy <- apply it globally
    Hope it helps.
    Roble

  • I need help on Oracle 9  file handler & utility packet!

    Hello ALL:
    I need to write a short SQL program to update the database via reading an external data file. How do I configure the standard oracle packet of oracle 9 to include the file handler? Please help me with details on oracle init files and some sample SQL commands to call the external file. I really appreciate the help. OracleUser.

    Tubby:
    Again, thank you. My answers to your feedback is Yes, No, Yes.
    I would thought that using the file handle would get the job done.
    Any how,
    1) how do I loop thru rows, say A1, A2.....A10,000 and use the content
    reading the this external table such as the content in A1 to compare against a certain column with many entries in a table in oracle using Loop/End Loop and select?
    2) What does oracle do the this external table at the end of session!
    3) Could I also create multiple external tables, let say 2?
    Thanks Tubby.

  • Need help, implementing streams between oracle 10g databases

    Hello all.
    Please help me, and give me instruction if any body implement streams between databases (Oracle 10g)
    I have implemented streams between schema table on (10g) and result was success.
    Firstly I want to know some thing, such as:
    1) Is it possible make streams with conditions, (make only DML or DDL i know) but make DML and not DELETE operation, just INSERT and UPDATE operations on the table?
    2) After changes was applied on target database, can I delete that records which copied (replicated) on source database?
    I have 2 databases and one of them is for archive purpose (I want use it as target database for streams). Other one is PROD database, applications make DML operation.
    I) record insert with null status
    II) processing (status 1)
    III) if success (status 2) unsuccess (status 3)
    For now, I have cron script on (Linux host) and in this script has PLSQL anonymous block and it works couple times during the day. This script works as archive.
    My task is: Make it via Oracle streams.
    Thank you beforehand.

    For conditions on the type of operation (Insert) check in the doc after apply handler and you can associate what ever code and conditions you want. You can also choose to work with a subset rules but there are some restriction as no lobs :
    [http://download.oracle.com/docs/cd/B28359_01/server.111/b28321/strms_rules.htm#insertedID7|http://download.oracle.com/docs/cd/B28359_01/server.111/b28321/strms_rules.htm#insertedID7]
    For a complete list of the restrictions :
    [http://download.oracle.com/docs/cd/B28359_01/server.111/b28321/ap_restrictions.htm#i1012965|http://download.oracle.com/docs/cd/B28359_01/server.111/b28321/ap_restrictions.htm#i1012965]

  • Need Help to delet sort key! Please help!

    Hi,
    I have a problem in the following program.
    Source Code:
    t-belnr  = bsid-zuonr.
    SPLIT t-belnr at '#' into wk_belnr wk_x_belnr.
    CLEAR t-belnr.
        t-belnr  = wk_belnr.
        t-xblnr  = bsid-belnr.
        IF t-belnr NE space.
          s-belnr      = t-belnr.
        ELSE.
          t-belnr      = t-xblnr.
          s-belnr      = t-xblnr.
        ENDIF.
    IF t-xblnr NE space.                                    "WD041005a
          s-xblnr      = t-xblnr.                               "WD041005a
        ELSE.                                                   "WD041005a
          s-xblnr      = t-belnr.                               "WD041005a
        ENDIF.                                                  "WD041005a
        WHILE s-xblnr(1) EQ '0'.                            "INS MG130606
          SHIFT s-xblnr LEFT.                               "INS MG130606
        ENDWHILE.                                "INS MG130606
    In the final ALV.
    If first colum (t-zuonr) (sort key for the document )is blank, the document need to be deleted.
    Question:
    How can I write the code to deleted the t-zuonr when it is space?
    Please help!!!
    Thank you!!

    Try as below:
    DELETE <itab> WHERE <fld> IS INITIAL.
    i.e
    DELETE t WHERE zuonr IS INITIAL.
    Kind Regards
    Eswar

  • Need Help with Array.sort and compare

    Hi
    I have a big problem, i try to make a java class, where i can open a file and add new words, and to sort them in a right order
    Ok everthing works fine, but i get a problem with lower and upper cases.
    So i need a comparator, i tried everything but i just dont understand it.
    How do i use this with Array.sort??
    I hope someone can help me

    Okay, you want to ignore case when sorting.
    There are two possibilities: Truly ignore case, so that any of the following are possible, and which one you'll actually get is undefined, and may vary depending on, say, which order the words are entered in the first place:
    English english German german
    english English german German
    English english german German
    english English German german
    The second possibility is that you do consider case, but it's of lower priority--it's only considered if the letters are the same. This allows only the first two orderings above.
    Either way, you need to write a comparator, and call an Arrays.sort method that takes both array and Comparator.
    The first situation is simpler. Just get an all upper or lower case copy of the strings, and then compare thosepublic int compare(Object o1, Object o2) {
        String s1 = ((String)o1).toUpper();
        String s2 = ((String)o1).toUpper();
        return s1.compareTo(s2);
    } You'll need to add your own null check if you need one.
    For the second way, your comparator will need to iterate over each pair of characters. If the characters are equal, ignoring case, then you compare them based on case. You pick whether upper is greater or less than lower.
    Of course, the need to do this assumes that such a method doesn't alrady exist. I don't know of one, but I haven't looked.

  • Need help implementing AJAX in an existing Struts Application

    Hi!
    I am trying to implement AJAX in my existing Struts Application. I need a good approach to go ahead and implement Ajax. I was thinking.. may be i will have to club all the code in the forms n actions (in the current Struts application) to one form and action, So I can easily include the dynamic content in the page.
    Please let me know if you have any ideas of how to implement AJAX in a fully developed Struts application.
    Thanks,
    Swapna.

    Hello Friends,
    Check out whether the link below could be of somehelp for you folks...
    http://www.it-eye.nl/weblog/2005/12/13/ajax-in-struts-implementing-dependend-select-boxes/
    http://today.java.net/pub/a/today/2005/10/27/sprinkle-ajax-magic-into-struts-webapp.html
    http://www.theserverside.com/news/thread.tss?thread_id=37355
    http://getahead.ltd.uk/dwr/examples/lists
    http://www.componentsource.com/products/backbase-ajax-struts/summary.html
    http://www.jibbering.com/2002/4/httprequest.html
    added to it there are few implementation frameworks which are addressing this issue you may further search on it and update abt the info which could be very much useful for all of the ppl out here.
    and there is a current thread running on the same topic it'd really appriciated if u can accomadate ur posts there.
    http://forum.java.sun.com/thread.jspa?threadID=784924&tstart=0
    REGARDS,
    RAHUL

  • Need Help regarding JTable Sort?

    Hello friends, i am working on the JTable and want to sort it by clicking on header of the column. I am using jdk1.5 and as my project is based on it so i cant change the jdk. I dont have the rowsorter class in jdk 1.5. So Is there any way through which i can sort the the Jtable by clicking its column header.
    Thanks for any help.

    Here is a link to the 1.5 Swing tutorial:
    https://www.cs.auckland.ac.nz/references/java/java1.5/tutorial/uiswing/TOC.html
    The Table section has a sorting example.

  • Need help implementing a Questionnaire page

    Hi,
    I have a requirement to build a web page which is like a Questionnaire page.
    There are multiple questions and each question can have multiple acceptable responses. The responses can be either an Input text/Check box/RadioGroup depending on the Question type.
    Each question can also have sub-questions depending on the responses. Each sub-question will also have its acceptable responses and further child questions. Currently we are supporting 5 level of parent-child questions hierarchy.
    We are also planning to support the re-arrangement of questions. Is it possible to achieve this functionality using standard ADF components ? I am trying to implement the same using a Tree table. I created a self reference view link to display all the questions in a hierarchal manner. But for displaying the responses I was not able to define the relationship in the tree table.
    The same thing I tried with forEach. Defined view links between Questions and responses VO. But I guess forEach does not support view links. So I was not able to get the responses corresponding to each question.
    [UI Mockup|http://apps-ux.us.oracle.com/fusion_prototypes/v2/prc/PRC_Qualification/shells/questionnaire.htm] for this page.
    Please suggest some approach to implement the above functionality.
    Thanks in Advance,
    Rakesh

    The Questionnaire page will look somewhat like the below questions.
    1.How long has your company been in business? //Parent question#1 : There are 3 radio group for selecting A/B/C.
    A.○ 0-2 years
    B.○ 3-5 years
    C.○ 5-10 years
    1.A.1 What is the founding month & year of your company? // For response A there are two sub-questions 1.A.1 & 1.A.2, 1.A.1 is of type I/p text & 1.A.2 shows 3 checkboxes.
    1.A.2 Who are some of your key investors?
    A.□ Advantage Capital Partners
    B.□ Goldman Sachs
    C.□ Others
    1.A.2.C Who are your key investor(s)? // For response C to qn 1.A.2 this is a sub-question of type i/p text.
    2. What is your annual revenue? // Parent question#2 which can also have sub-questions
    A.○ $5-$10 million
    B.○ $10-$15 million
    C.○ $15+ million
    Edited by: user775413 on Feb 14, 2011 9:42 AM
    Edited by: user775413 on Feb 14, 2011 9:52 AM

  • Need help fast! Sort of on that exclimation stuff

    I downloaded the updates like it said but it wont let me update my ipod because it doesnt reconize it. does this mean i need to send it in or is it something else?

    To get the computer to recognise the iPod try resetting while it is connected to the computer. (
    Reset = hold menu and select simultaneously until the Apple logo appears.

  • I need help on a sorting array method()

    I'm working on a program that can do a calculation for a swimming event where there will be no more than 200 paticipants. The swimmers that signed up first for the race will be swimming in the last heat.They swim in a pool with 7 lines.The swimmer that signed up first ( and so has the lowest sign up time)swimms in line 4,the swimmer that signed up second ( and so has the second lowest sign up time)swimms in line 5, and the swimmer that signed up after that in line 3.
    Which meens that the lines are filled as follow:
    line 1 time 7
    line 2 time 5
    line 3 time 3
    line 4 time 1
    line 5 time 2
    line 6 time 4
    line 7 time 6
    When the last heat is filled, the heat before the last one is filled after the same pattern and so on, so that the first heat is filled last.
    Now, I have written a class that can sort the times from the lowest to the highest, but how do I write a method that can sort the swimmers into the heats and the right lines??
    public class SwimmingEvent
    private String name;
    private int birthYear;
    private int number;
    private double signUpTime;
    private Swimmer[] record;
    private int numberOfSwimmers;
    public SwimmingEvent()
    name = "No record";
    birthYear = "No record";
    number = "No record";
    signUpTime = 0;
    public SwimmingEvent(String initialName, int initialBirthYear,
    int initialNumber, double initialSignUpTime)
    set(initialName, initialBirthYear, initialNumber, initialSignUpTime);
    public void set(String newName, int newBirthYear, int newNumber, double newSignUpTime)
    name = newName;
    birthYear = newBirthYear;
    number = newNumber;
    signUpTime = newSignUpTime;
    public void readInput()
    System.out.print("Indtast sv�mmerns navn:");
    name = SavitchIn.readLine();
    System.out.print("Indtast �rgang:");
    birthYear = Savitch.readLine();
    System.out.print("Indtast l�bsnummer:");
    number = SavitchIn.readLine();
    System.out.print("Indtast tid for anmeldelse:");
    signUpTime = SavitchIn.readLineDouble();
    public void getFigures()
    System.out.println("Indtast antalet af sv�mmer:");
    numberOfSwimmers = Savitch.readLineInt();
    record = new Swimmer[numberOfSwimmers];
    int i;
    for (i = 0; i < numberOfSwimmers; i++)
    record[i] = new Swimmer();
    System.out.println("Indtast data for sv�mmer: " + (i+1));
    record.readInput();
    System.out.println();
    public static void sort(double[] a)
    int index, indexOfNextSmallest;
    for (index = 0; index < a.length - 1; index++);
    indexOfSmallestNumber = indexOfSmallest(index, a);
    interchange(index, indexOfNextSmallest, a);
    private static void interchange(int i, int j, int[] a)
    int temp = a[i];
    temp = a[i];
    a[i] = a[j] = temp;
    private static int indexOfSmallest(int startIndex, int[] a)
    int min = a[startIndex];
    int indexOfMin = startIndex;
    int index;
    for (index = startIndex + 1; index < a.length; index++)
    if (a[index] < min)
    min = a[index];
    indexOfMin = index;
    return indexOfMin;
    public void writeOutput()
    public String getName()
    return name;
    public int getBirthYear()
    return birthYear;
    public int getNumber()
    return number;
    public double getSignUpTime()
    return signUpTime;

    Now, I have written a class that can sort the times from the lowest to
    the highest, but how do I write a method that can sort the swimmers into
    the heats and the right lines??Once you have a working general sort algorithm, issues like this come down to how you make your comparisons between elements. So what you want to do is write your sort code so that the comparison code is modular. (for example, using a class to express comparisons, so you can swap out comparison classes). Then whatever your requirements for sorting elements are, you can achieve them by writing the right comparison code and leaving your sort alone.
    This is how Java's core libraries do it, by the way. See:
    http://java.sun.com/j2se/1.4.1/docs/api/java/util/Comparator.html
    I'm assuming this is your homework. If it's not, then you shouldn't be writing your own sort routines -- use the ones java provides. See the API.

  • Need help-SQL with result format suppressing duplicate values

    I am trying to write a SQL which would select data from the below tables(in reality i have many other tables also) but I wanted to know how do i get the data in the format given below.
    The scenario is :-A training_plan can N no. of OBJECTIVES and EACH objective has N no.of activities
    Insert into TEST_TRAINING_PLAN
       (TPLAN_ID, TPLAN_NAME, TPLAN_DESC, T_PERSON_ID
    Values
       ('111', 'test_name', 'test_name_desc', '****')
    Objectives table:-
    Insert into TEST_TRAINING_OBJECTIVE
       (T_OBJECTIVE_ID,  T_OBJECTIVE_NAME,T_owner)
    Values
       ('10', 'objective1', '1862188559')
    Objective and Training Plan relationship table where TPLAN_ID is the foreign key.
    Insert into TEST_TP_OBJECTIVE
       (TPLAN_TOBJ_ID, TPLAN_ID, T_OBJECTIVE_ID, 
        REQUIRED_CREDITS)
    Values
       ('1', '111', '10',5)
    Objective and Activity relationship table where T_OBJECTIVE_ID is the foreign key from the TEST_TRAINING_OBJECTIVE table.
    Insert into TEST_TRAIN_OBJ_ACTIVITY
       (TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
        ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
    Values
       ('1000', '10', 'selfstudy event', SS1, NULL,
        'Event', 0, 0);
    Insert into TEST_TRAIN_OBJ_ACTIVITY
       (TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
        ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
    Values
       ('1001', '10', 'SQLcourse', 1, NULL,
        'Course', 1, 0);
    Insert into TEST_TRAIN_OBJ_ACTIVITY
       (TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
        ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
    Values
       ('1002', '10', 'testSQL', 1, NULL,
        'test', 2, 0);
    COMMIT;
    firstname     emplid     Tplan name     Number of activities/credits completed(for TP)     Objective Name     Number of required activities/Credits (for objective)     Number of activities/credits completed(for objective)     activity  name     activity completion status
    U1     U1     TP1     5                         
                        OBJ1     4     3     C1     PASSED
                                       C2     PASSED
                                       C3     WAIVED
                                       T1     ENROLLED
                                       T2     ENROLLED
                        OBJ2     3     2          
                                       S1     ENROLLED
                                       S2     PASSED
                                       T3     WAIVED
    U1     U1     TP2                         C4     INPROGRESS
                   50     OBJ11     50     30     C11     PASSED
    **The second row where we have another training_plan record and accordingly all objectivesand their objective.**similarly ,i need to display many Training_plan records in such tabular format.Please help with the SQL query to select and display data in the above format
    If you want to suppress duplicate values in some of your results columns
    I am using toad 9.1 using Oracle 10g version 2

    Hi,
    You can use the BREAK command to suppress duplicate values.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12009.htm#SQPUG030
    (scroll down for an example)
    It's a 'SQL*Plus-ism', not sure if TOAD's capable to handle it.
    Simple example:
    HR%xe> break on department_name
    HR%xe> select l.department_name
      2  ,        e.last_name
      3  ,        e.first_name
      4  from     departments l
      5  ,        employees e
      6  where    e.department_id = l.department_id;
    DEPARTMENT_NAME                LAST_NAME                 FIRST_NAME
    Executive                      King                      Steven
                                   Kochhar                   Neena
                                   De Haan                   Lex
    IT                             Hunold                    Alexander
                                   Ernst                     Bruce
                                   Austin                    David
                                   Pataballa                 Valli
                                   Lorentz                   Diana
    Finance                        Greenberg                 Nancy
                                   Faviet                    Daniel
                                   Chen                      John
                                   Sciarra                   Ismael
                                   Urman                     Jose Manuel
                                   Popp                      Luis
    Purchasing                     Raphaely                  Den
                                   Khoo                      Alexander
                                   Baida                     Shelli
                                   Tobias                    Sigal
                                   Himuro                    Guy
                                   Colmenares                Karen
    Shipping                       Weiss                     Matthew
                                   Fripp                     Adam
                                   Kaufling                  Payam
                                   Vollman                   Shanta
                                   Mourgos                   Kevin
                                   Nayer                     Julia
                                   Mikkilineni               Irene
                                   Landry                    James
    Public Relations               Baer                      Hermann
    Accounting                     Higgins                   Shelley
                                   Gietz                     William
    106 rijen zijn geselecteerd.

  • Need to change the Sort field(kna1-sortl) value

    Hi All,
    We have the requirement to fill the Search Term   (kna1-sortl) based the accounting group and 'kunnr' value.
    I.e as per the legacy system number range in brazil we need fill the sortl field based on accoung goup by concating the kunnr value to it.
    for Ex: 2GXXXXX0 this number need to filled in sortl field.
    where 'X' is repplaced by kunnr value.'2' and '0' are the constant values.Based on accounting group after value '2' we need to add either 'g' or  'S'.
    We find one user exit 'EXIT_SAPMF02D_001' but which does not contain the kna1 as the change perameter.
    kindly help me on it .if there is any other badi

    Hi,
    There is no std user-exit for this (at least we haven't found it as well).
    We have created implicit enhancement point implementation athe the end of form AUFRUF_USER_EXIT in include MF02DFEX.
    The code should be similiar to following:
    ENHANCEMENT 1  YEDSD_EO_ADD_DOC_PREFIX.    "active version
        DATA:
          ltp_doc_prefix TYPE y_dt_docpref.
    *--only in creation and change mode
        IF T020-AKTYP = 'H' OR
           T020-AKTYP = 'V'.
          CONCATENATE kna1-ktgrd kna1-kunnr INTO ltp_doc_prefix.
          kna1-yydocpre = ltp_doc_prefix.
        ENDIF.
    ENDENHANCEMENT.
    Regards,
    Marcin

  • Need help with locating a key using a value in a HashMap.

    I am quite new to Java and programming, and am just learning this in High School (enjoying it thoroughly). Sorry if I don't respect the etiquette or formatting of this board (it's unintentional).
    I am using the book, Objects First Wth Java A Practical Introduction Using Blue J and am working on extensively improving the "World of Zuul" project. Which is a text-based adventure game.
    Here is a code sample;
    public String getNameFromList(String name)
      boolean found = false;
      Set pairSet = xItemList.entrySet();
      for(Iterator iter = pairSet.iterator(); (found == false && iter.hasNext());){
      Item currentItem = (Item) iter.next().getValue();
      String currentKey = currentItem.getName();
      if(name.equals(currentKey)){
        String changedName = iter.next().getKey();
        return changedName;
    error; cannot resolve symbol:
    method: getValue()xItemList is a HashMap with String keys, and Item values.
    The relevant field of Item is name, which is a string.
    The currentKey local variable is a little misleading, it is the current name, but acts as the 'key' when looking for the actual key.
    changedName (if the parameter name is found from the item.getNames()), is what the method returns, the key associated with a object (by looking at the object's field).
    My objective for this method is for it to have a name as a parameter, which it searches for in the HashMap (by Iteration over the entrySet - or I suppose iteration over Set values(), but this loses which object value is tied to which key, doesn't it?), and returns the respective key.
    Any help would be very much appreciated (even if it is telling me that this can't be done with HashMaps!).

    It's not clear to me what your question is, or if indeed you even have a question.
    You seem to be having a problem with types. Iterators return Objects.
    So in this line:
      Item currentItem = (Item) iter.next().getValue();The iterator's next() method is returning an Object, and you're trying to call getValue() on that Object. But Object doesn't have a getValue() method. That would explain your error message. Map.Entry does; you apparently meant to call Map.Entry's getValue() method. You would cast the result of iter.next() to Map.Entry before you call getValue().
    Also you're calling next() on your iterator twice in the body of the loop, which means you're getting two different values... this is probably not what you intend.
    But you're making this more complicated than it needs to be anyway.
    Why are you iterating through the set of entries in the HashMap?
    The whole point of a Map is that you get an item using an object as the key. Just do xItemList.get(name). Right?

Maybe you are looking for

  • One iPod, two PCs.  iPod no longer recognized on on PC after latest updater

    I have a 4G 20GB with color display that I sync to 2 PCs; my DT at home where my music library is, and my office laptop where I manage Podcasts. About 2 weeks ago, after updating to iT6 (6.0.3) and the 1-10 updater, my laptop stopped recognizing my i

  • Connecting cProjects 4.5 to SAP R/3 4.7 possible ?

    Hi Guru's, we have the challange in an customer project to connect a cProjects 4.5 to a SAP R/3 4.7 system. The installation guide said that the component ECC 5.0 is mandatory for the connection from cProjects 4.x. So this component is not part of R/

  • Does Acrobat X (Pro) work properly in OS 10.9 Mavericks?

    Does anyone know if Acrobat X (Pro) works properly in 10.9 Mavericks? Acrobat 9 Pro does not work all that smoothly, and has the sidebar issue. I am thinking of upgrading the whole Creative Suite from CS5 to CS6, but it doesn't make sense if I will s

  • Problem in FB60 bapi

    Hi friends , i m developing a prog with bapi of FB60 it always fire the error no 014 i.e. FI/CO interface: Line item entered several times i am feeding the data which is given below in the BAPI . Please help me if anybody has worked on this BAPI w_it

  • Sub radio buttons

    I have an interactive form where the user applies for a leave of absence and selects one of 6 reasons. Maternity Medical Worker's Comp Family Military Personal If the user selects Family, there are two sub-reasons: Serious Illness Child-related I've