Combination of records

hi all,
i have query like below
SELECT BLCHG_CODE,BLCHG_COMPANY,TTM_COMPANY,TTM_CODE
FROM BL_CHARGE_MASTER,TAX_TYPE_MASTER
WHERE BLCHG_COMPANY = TTM_COMPANY
AND BLCHG_STATUS = 'A'
AND TTM_STATUS = 'A'
i have a module called ('I','E')
i should get the records for the combination of above said query and module.
for example the above said query returns 10 rows means i should get 10 rows for the combination 'I' and 'E'
in the above case i should get 20 records.
Please help me..

hi,
my table structure are like
SQL> desc bl_charge_master;
Name                            Null?    Type
BLCHG_GROUP                     NOT NULL VARCHAR2(10)
BLCHG_CODE                      NOT NULL VARCHAR2(15)
BLCHG_COMPANY                   NOT NULL VARCHAR2(5)
BLCHG_DESC                      NOT NULL VARCHAR2(240)
BLCHG_MODE                               VARCHAR2(3)
BLCHG_REVENUE                            VARCHAR2(20)
BLCHG_AMOUNT                    NOT NULL NUMBER
BLCHG_STATUS                    NOT NULL VARCHAR2(3)
BLCHG_CRT_BY                    NOT NULL VARCHAR2(15)
BLCHG_CRT_ON                    NOT NULL DATE
BLCHG_UPD_BY                    NOT NULL VARCHAR2(15)
BLCHG_UPD_ON                    NOT NULL DATE
SQL> desc tax_type_master;
Name                            Null?    Type
TTM_COMPANY                     NOT NULL VARCHAR2(5)
TTM_CATG                        NOT NULL VARCHAR2(15)
TTM_CODE                        NOT NULL VARCHAR2(15)
TTM_DESCRIPTION                 NOT NULL VARCHAR2(240)
TTM_TYPE                        NOT NULL VARCHAR2(3)
TTM_STATUS                      NOT NULL VARCHAR2(3)
TTM_NOTES                                VARCHAR2(4000)
TTM_CRT_ON                      NOT NULL DATE
TTM_CRT_BY                      NOT NULL VARCHAR2(15)
TTM_UPD_ON                      NOT NULL DATE
TTM_UPD_BY                      NOT NULL VARCHAR2(15)the module is not comming from any table it is going to be user parameter. the value for that is 'I' and 'E".

Similar Messages

  • Combining 2 records in a single cube

    Hi Everyone,
    I would like to get your opinion about this particular requirement.
    I have an opportunities cube (CRM) which stores info about different opportunities. One customer may go from one opportunity to another. Both the opportunities are saved as different records in BW for instance Oppt A (Record 1)and Oppt B (Record 2)
    So now client wants to see in a single record, which customer went from Oppt A to Oppt B.
    I am thinking about creating another cube and write a routine to check the Bill Account ( which is the only field available linking the 2 opportunities.
    Is this possible? Has anyone encountered or made such a routine?
    have you got other ways of doing this?
    Your inputs will be greatly appreciated.
    Thanks
    Kumar.

    Hi Vamsi,
    Thanks for your offer to help with the coding. That wont be necessary anymore as I figured out I will not be able to join the 2 records since there is a One to Many relationship between Oppt A and Oppt B. I will just display them as different records and sort them together.
    But since we have this idea of combining 2 records of a single cube, why don't we continue and close this.
    If there was a 1 to 1 Rel, the records would have shown this way
    Oppt A
    Bill Account
    Meter ID
    Transaction no
    Customer Name
    Address
    AutoDR Flag (Checked)
    Load Approved
    Oppt B
    Bill Account
    Meter ID
    Transaction no
    Customer Name
    Address
    TI Indicator Flag (Checked)
    Campaign Enrolled
    The Key fields would have been Bill Account and Meter ID
    So the final Oppt would have been ...
    Bill Account
    Meter ID
    Transaction no
    Customer Name
    Address
    AutoDR Flag (Checked)
    Load Approved
    TI Indicator Flag (Checked)
    Campaign Enrolled

  • Selecting distinct combination of records

    Hi Expart ,
                   I have table fields like function ,tcode,objects,fields,from ,to ,user like that in which except user all r primary key fields but i want Number of unique Function-Tcode-Object combinations when select the data.
    i am doing like that
    SELECT COUNT( distinct  FUNCTIONID TCODE OBJECT)
    FROM /PSYNG/FUNCTTRAN
    INTO L_FUN_TCD_OB
    WHERE VRSIO =  P_VRSIN.
    but it will give an error
    plz help me to get no of this combination of records .
    Thanks in advance .
    Tsen

    hi
    u can write code like this
    SELECT distinct FUNCTIONID TCODE OBJECT
    FROM /PSYNG/FUNCTTRAN
    INTO table it_L_FUN_TCD_OB
    WHERE VRSIO = P_VRSIN.
    data: var type sy-tabix.
    describe table it_L_FUN_TCD_OB lines var.
    L_FUN_TCD_OB = var.
    refresh  it_L_FUN_TCD_OB.
    Regards
    Sajid

  • Pop up message while updating diff. combination of records in manual planin

    Hi,
    I would like to know how to create pop up message while updating different combination of records in manual planning using flat file upload in BW BPS 3.5.
    Business Logic: Correct Combination
    Team X    1    0    1   1
    Team Y    1    1     0   1
    While Updating: Wrong Combination
    Team X    0    0    1   1
    Team Y    1    1     0  0
    While uploading Wrong Combination flat file The system want to show as pop up message "The combination is invalid".For manual uploading flat files created 2 function modules (init file,full file) using by how to upload paper and also created one ABAP table for Correct Combination table in the system.
    Regards,
    anil
    Message was edited by:
            anil kumar

    Hi,
    Why don't use characteristic relationship  which is defined in the planning area?
    Regards,
    Siva.

  • Combining multiple records into a single record (View)

    Okay so here is my scenerio:
    There is a table I have made that details SQL jobs and the various details about them. What i wan't to do is make a view with specific logic implemented. Fields that will be taken across to this view will be: LastRunDate, LastRunTime and Step_Status.
    JobName will also be used to define the logic but will not be a column in itself.
    What i wan't is an additional column using this logic, called 'DataSet'. For each Dataset there are multiple jobs that are unique to it, so there are multiple records being brought over from the table to view for one particular dataset. For example,
    for 'ExampleDataSet' there are three jobs, i wan't it so these jobs are combined and named as 'ExampleDataSet' under a calculated column called 'Dataset'. For the following fields i would like it so that LastRunDate and LastRunTime are the time in whichever
    job was last to be intitiated is the date and time set. For Step_Status, there are three possible results, 'Running', 'Failed' or 'Succeeded'. If any of the three jobs are 'Running', then 'Running'. If neither are running yet one has failed then 'Failed'.
    Only when all three have succeeded should it then be set to 'Succeeded'.
    I hope i have made that clear enough, please feel free to ask any questions if not. I am relatively new to SQL but i thought to at least try least try (I knew it wouldn't work) and it didn't work. But it may give you a better idea of
    what i wan't:
    CREATE VIEW [dbo].[vw_DataAvailabilityAnalysts] AS
    SELECT CASE
    WHEN JobName in ('Job1','Job2','Job3') and step_status='Running' THEN 'Running'
    WHEN JobName in ('Job1','Job2','Job3') and step_status='Failed' THEN 'Failed'
    WHEN JobName in ('Job1','Job2','Job3) and step_status='Succeeded' THEN 'Succeeded'
    END as StatusCheck,
    CASE WHEN JobName in ('Job1','Job2','Job3') THEN 'ExampleDataSet'
    END as DATASET,
    LastRunDate,
    lastruntime,
    step_status,
    FROM [CDS_Common].[dbo].[DataAvailability]
    Many Thanks,
    Plain_Clueless
    Plain_Clueless

    Okay so here is what my table looks like (Simplified). There are four columns and the data within is extracted via a Stored Procedure.
    JobName
    LastRunDate
    LastRunTime
    Step_Status
    Job1
    11/06/2014
    09:30:00
    Succeeded
    Job1
    10/06/2014
    09:37:20
    Succeeded
    Job2
    11/06/2014
    04:05:00
    Succeeded
    Job1
    09/06/2014
    02:17:41
    Succeeded
    As you can see there are 3 jobs which are all 'Job1'. This jobs are obviously different within the table however this represents that they are jobs which all update the same DataSet within our local warehouse. Whereas Job2 updates a different dataset alltogether.
    I wan't to create a view which will alagmate the jobs that are of the same DataSet, which will disclude the column JobName but would create a whole new column that looks like this:
    DataSet
    LastRunDate
    LastRunTime
    Step_Status
    DataSet2
    11/06/2014
    04:05:00
    Succeeded
    DataSet1
    11/06/2014
    09:30:00
    Succeeded
    Bascically what this shows you is all the Job 1's combined so they are one record, Amaglamated. The last time any of these jobs were run is the LastRunDate & LastRunTime, which was the first record in the first table provided. Again for Step_Status,
    there are three possible results, 'Running', 'Failed' or 'Succeeded'. If any of the three jobs are 'Running', then 'Running' (Absolute). If none of the three jobs are running yet one has failed then 'Failed'. If one has failed yet another is also running then
    'Running'.Only when all three have succeeded should it then be set to 'Succeeded'. (This last bit isn't as important).
    Hope this clears it up a bit,
    Plain_Clueless
    Plain_Clueless

  • VBA script to combine all records in a sub-form into a usable string

    I am using the Outlook 15.0 Object Library to create emails and appointments.
    I have a form that contains event information and subform that contains event participants (a related table).
    Right now I am able to click a button that will take information from the Event table and one selected record at a time from the participants table. Some of the participants are instructors, some are staff. I only want to list instructors.
    That code looks something like this:
    .body = "Participants: <ul><li> " & [Forms]!MainForm!SubForm.Form![Participant]
    This means I have to create three emails or manually type additional details.
    What I am looking to do is do some sort of loop to combine these before inserting them into the .body code. Below is a sketch of what I want to happen, but again -- I'm not sure where to begin.
    Dim Instructors as String
    If [Subform].[Type] = "Instructor" Then
    Add to Instructors & "</li><li>"
    End if
    .body = "Participants: <ul><li> " & Instructors & "</li></ul>"

    You might like to take a look at the file Concat.zip in my public databases folder at:
    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
    This little demo file includes a solution for concatenating values from a related table using the very efficient GetString method of the ADO recordset object to concatenate values.  As the example it uses data from Northwind.  In my file the function
    is called in a report, but you could call it in your code to build a list of participants as a string expression.  If you want the participants listed on separate lines use the left hand column of my report as the example of how to call the function;
    for a comma separated list use the right hand column.
    Allen Brown also provides a concatenation function at:
    http://allenbrowne.com/func-concat.html
    which I believe loops through a DAO recordset to build the list.
    Ken Sheridan, Stafford, England

  • How to combine 3 records into one?

    Hi frnds
    I have data like this in my ODS
    Material |    ID |   Name |       Address
    M1            1             
    M1                   AAA             
    M1                                  address1
    M2            2             
    M2                   BBB             
    M2                                  address2
    M3            3             
    M3                   CCC            
    M3                                  address2
    But I want it like this
    Material | ID | Name |   Address
    M1         1     AAA       address1
    M2         2     BBB       address1
    M3         3     CCC       address1
    Please tell me how can I do this?
    Regards
    Swati

    Hi Swati,
    If the Material is a master, then in the infoobject level of the Master, assign the infoobjects Name, Address and Id as a compounding and not as attribute.
    When you'll do this, automatically for every unique set of combination you will get a new record.
    For eg:
    Before,  Material      Item        Name          Address
                 M1               A        
                 M1                                123
                 M1                                                 XYZ
    Now,  Material      Item        Name          Address
                M1             A            123            XYZ
                                       Or
    As per your current quest'n:
                Material      Item        Name          Address
                   M1            A            123            XYZ
                   M2            A            123            XYZ
    Then Output will be:
                Material      Item        Name          Address
                 M1            A            123            XYZ
                 M2            A            123            XYZ
    and you dont need to write any code on ODS, as doing this will server your purpose.
    Hope it helps.
    Regards,
    Neha.

  • Combine Multiple Records in Crystal Reports

    I have a table with our clients buying preferences, The first three columns is the client ID, Name and Last name and the fourth and fifth columns is the clients buying preference, I have multiple records per client depending on the preference the client has chosen.
    ID First Name Surname Type Suburb
    5 John Smith House Melrose
    6 John Smith House Rosebank
    7 John Smith House Kilarney
    8 John Smith Cluster Melrose
    9 John Smith Cluster Rosebank
    10 John Smith Cluster Kilarney
    I need to combine the fourth column into one string and the same for the fifth column.
    ID First Name Surname Property Type Suburb
    5 John Smith House, Cluster Melrose, Rosebank, Kilarney
    I have been getting closer by using the formula in a similar post,  Combine Field from Multiple Records
    but still struggling a bit
    Any help with this would be greatly appreciated.

    Thank you so much, I was a bit blind there. That works brilliant for one client,
    As I was saying yesterday, that was just one client of many in my report, What do I do in the case of multiple clients...
    ID     First Name     Surname     Property Type     Suburb
    5     John     Smith     House     Melrose
    5     John     Smith     House     Rosebank
    5     John     Smith     House     Kilarney
    5     John     Smith     Townhouse     Melrose
    5     John     Smith     Townhouse     Rosebank
    5     John     Smith     Townhouse     Kilarney
    6     Jack     Black     Cluster     Sandton
    6     Jack     Black     Cluster     Houghton
    6     Jack     Black     Cluster     Fourways
    6     Jack     Black     Appartment     Sandton
    6     Jack     Black     Appartment     Houghton
    6     Jack     Black     Appartment     Fourways
    obviously if I use that formula, with many records the following happens, before I suppress...
    ID     First Name     Surname     Property Type     Suburb
    5     John     Smith     House     Melrose
    5     John     Smith     House     Melrose, Rosebank
    5     John     Smith     House     Melrose, Rosebank, Kilarney
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    6     Jack     Black     House, Townhouse, Cluster     Melrose, Rosebank, Kilarney, Sandton
    6     Jack     Black     House, Townhouse, Cluster     Melrose, Rosebank, Kilarney, Sandton, Houghton
    6     Jack     Black     House, Townhouse, Cluster     Melrose, Rosebank, Kilarney, Sandton, Houghton, Fourways
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton, Houghton
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton, Houghton, Fourways
    obviously if I have to suppress, NOT ONLASTRECORD
    I have the following result...
    ID     First Name     Surname     Property Type     Suburb
    6     Jack     Black     House, Townhouse, Cluster, Appartment     Melrose, Rosebank, Kilarney, Sandton, Houghton, Fourways
    Where as the result I desire is
    ID     First Name     Surname     Property Type     Suburb
    5     John     Smith     House, Townhouse      Melrose, Rosebank, Kilarney
    6     Jack     Black     Cluster, Appartment     Sandton, Houghton, Fourways
    Is there anything I can do to get this result?

  • Combine 2 record in 1 record

    I have 2 row data in my table like below :
    Id Name Sturc
    1 Test Unit
    Id Name Value
    1 Test 123
    I want my output like below:
    Id Name Sturc Value
    1 Test Unit 123
    Did anyone want had how to write PL/SQL to update on my table?
    I really appreciate.
    Thanks.
    Message was edited by:
    user582813
    Message was edited by:
    user582813
    Message was edited by:
    user582813
    Message was edited by:
    user582813
    Message was edited by:
    user582813

    Do you mean you have two rows in the same table, like this?
            ID NAME       STURC      VALUE
             1 Test       Unit
             1 Test                    123If so, then you could use a query like this.
    SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jun 29 23:43:58 2007
    create table t ( id number, name varchar2(10), sturc varchar2(5), value number );
    insert into t values ( 1, 'Test', 'Unit', null ) ;
    insert into t values ( 1, 'Test', null  , 123  ) ;
    commit;
    select
      t1.id ,
      t1.name ,
      t1.sturc ,
      t2.value
    from
      t t1 inner join t t2 on
      ( t1.id = t2.id and
        t1.name = t1.name and
        t1.sturc is not null and
        t1.value is null and
        t2.sturc is null and
        t2.value is not null
            ID NAME       STURC      VALUE
             1 Test       Unit         123--
    Joe Fuda
    SQL Snippets

  • Combine multiple record column valus into 1

    Hi All,
    When I run a simple sql
    Select C1,C2,C3 from Tab; I get these values
    x,y,1
    x,y,2
    x,y,3
    x1,y1,8
    x1,y1,10
    How do I these to show up like this
    x,y,(1,2,3)
    x1,y1,(8,10)
    using only SQL query
    Appreciate any ideas.
    Thanks.

    This is one of the most commonly asked question on this forum. Search for Pivot queries. It is possible in SQL only if we know the maximum number of values for any group (x,y group in this case has 3 values). If we do not know this, it has to be a PLSQL solution. Hope this helps.
    SriDHAR

  • Combine values from two records in one query

    Hello.
    Is it possible to combine two record - only one column value?
    With one query we get these results:
    A____B____C____D____E_______F_______G______H
    +++++++++++++++++++++++++++++++++++++++++
    28___84___P___16____________1____02.06.09___1
    28___84___p___8_____________1____02.06.09___1
    28___84___S___16____________1____02.06.09___1
    28___84___T___12____________1____02.06.09___1
    28___84___1___137___________1____02.06.09___1
    28___84___5___18___66,42____1____02.06.09____1
    28___84___6___14____________1____02.06.09___1
    28___84___8___17___214,2____1____02.06.09___1
    If there is a record with column C value 'p', then column value 'D' should be added to record with C value 'P' and 'S': result should be like this:
    No 'p' record and values (D column) for 'P' and 'S' should be a summed by 8 from record 'p'.
    A____B____C____D____E_______F_______G______H
    +++++++++++++++++++++++++++++++++++++++++
    28___84___P___24____________1____02.06.09___1
    28___84___S___24____________1____02.06.09___1
    28___84___T___12____________1____02.06.09___1
    28___84___1___137___________1____02.06.09___1
    28___84___5___18___66,42____1____02.06.09____1
    28___84___6___14____________1____02.06.09___1
    28___84___8___17___214,2____1____02.06.09___1
    And this should be restricted to column A value.
    Any idea?
    Thanks.
    Edited by: DejanH on Jun 2, 2009 11:39 AM

    OK, that's a messy requirement, here's one for 'p' but no 'P' (and 't' but no 'T'), and you can expand that for others yourself.
    WITH test_data AS (
    SELECT 28 A, 84 B, 'p' C, 8 D, NULL E, 1 F, TO_DATE('02.06.09','DD.MM.YY') G, 1 H FROM DUAL UNION ALL
    SELECT 28 A, 84 B, 'S' C, 16 D, NULL E, 1 F, TO_DATE('02.06.09','DD.MM.YY') G, 1 H FROM DUAL UNION ALL
    SELECT 28 A, 84 B, 'T' C, 12 D, NULL E, 1 F, TO_DATE('02.06.09','DD.MM.YY') G, 1 H FROM DUAL UNION ALL
    SELECT 28 A, 84 B, '1' C, 137 D, NULL E, 1 F, TO_DATE('02.06.09','DD.MM.YY') G, 1 H FROM DUAL UNION ALL
    SELECT 28 A, 84 B, '5' C, 18 D, 66.42 E, 1 F, TO_DATE('02.06.09','DD.MM.YY') G, 1 H FROM DUAL UNION ALL
    SELECT 28 A, 84 B, '6' C, 14 D, NULL E, 1 F, TO_DATE('02.06.09','DD.MM.YY') G, 1 H FROM DUAL UNION ALL
    SELECT 28 A, 84 B, '8' C, 17 D, 214.2 E, 1 F, TO_DATE('02.06.09','DD.MM.YY') G, 1 H FROM DUAL)
    -- end test data
    SELECT td1.A, td1.B, td1.C,
         CASE WHEN td1.C IN ('P', 'S') THEN NVL(td1.D,0) + NVL(td2.D, 0) ELSE td1.D END D,
         TO_CHAR(td1.E * 100, 'fm99990,09') E, td1.F, td1.G, td1.H
       FROM test_data td1
       LEFT JOIN (
      SELECT A, SUM(D) D
         FROM test_data
        WHERE C= 'p'
        GROUP BY A) td2
        ON (td1.A = td2.A)
    WHERE C != 'p'
    GROUP BY td1.A, td1.B, td1.C, CASE WHEN td1.C IN ('P', 'S') THEN NVL(td1.D,0) + NVL(td2.D, 0) ELSE td1.D END, TO_CHAR(td1.E * 100, 'fm99990,09'), td1.F, td1.G, td1.H
    UNION
    SELECT td1.A, td1.B, UPPER(td1.C) C,
         SUM(td1.D) D,
         TO_CHAR(td1.E * 100, 'fm99990,09') E, td1.F, td1.G, td1.H
       FROM test_data td1
      WHERE td1.C in ('p', 't')
    GROUP BY td1.A, td1.B, UPPER(td1.C),TO_CHAR(td1.E * 100, 'fm99990,09'), td1.F, td1.G, td1.H
    ORDER BY 1
             A          B C          D E                  F G                  H
            28         84 1        137                    1 02-JUN-09          1
            28         84 5         18 66,42              1 02-JUN-09          1
            28         84 6         14                    1 02-JUN-09          1
            28         84 8         17 214,20             1 02-JUN-09          1
            28         84 P          8                    1 02-JUN-09          1
            28         84 S         24                    1 02-JUN-09          1
            28         84 T         12                    1 02-JUN-09          1
    7 rows selected.

  • Can not copy data within a realtime cube due to combination issues

    Hello all,
    I want to use a planning function on a realtime cube in order to copy data from from Co_area CO1 into Co_Area CO2. The Co_Are and the profit center are part of the realtime cube, but not the nav attribute of the profit center.
    When I test/run the planning function via a sequence in planning modeller I get an error message: The combination 'CO2/PCxy,#' is not valid, valid is 'CO2/PCxy,abcd': characteristic '0PROFIT_CTR' .
    Has this error something to do with the relationship of the master data of profit center and its nav attributes?
    Any help would be great.
    Best regards,
    Stefan form Munich/Germany

    I guess this problem is coming because of some wrong combination of records present in cube for controlling area 1. Make the below changes in the planning function. Dont include profit center in the level. Just include controlling area. Create a characteristic relationship of type derivation by master data attributes. Give source char as Controlling area and target as profit center. This will mantain consistency of char. combinations b/w controlling area and profit center in cube for the newly generated records.

  • Need Help With File Matching Records

    I need help with my file matching program.
    Here is how it suppose to work: FileMatch class should contain methods to read oldmast.txt and trans.txt. When a match occurs (i.e., records with the same account number appear in both the master file and the transaction file), add the dollar amount in the transaction record to the current balance in the master record, and write the "newmast.txt" record. (Assume that purchases are indicated by positive amounts in the transaction file and payments by negative amounts.)
    When there is a master record for a particular account, but no corresponding transaction record, merely write the master record to "newmast.txt". When there is a transaction record, but no corresponding master record, print to a log file the message "Unmatched transaction record for account number ..." (fill in the account number from the transaction record). The log file should be a text file named "log.txt".
    Here is my following program code:
    // Exercise 14.8: CreateTextFile.java
    // creates a text file
    import java.io.FileNotFoundException;
    import java.lang.SecurityException;
    import java.util.Formatter;
    import java.util.FormatterClosedException;
    import java.util.NoSuchElementException;
    import java.util.Scanner;
    import org.egan.AccountRecord;
    import org.egan.TransactionRecord;
    public class CreateTextFile
      private Formatter output1;  // object used to output text to file
      private Formatter output2;  // object used to output text to file
      // enable user to open file
      public void openTransFile()
        try
          output1 = new Formatter("trans.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openTransFile
      // enable user to open file
      public void openOldMastFile()
        try
          output2 = new Formatter("oldmast.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openOldMastFile
      // add transaction records to file
      public void addTransactionRecords()
        // object to be written to file
        TransactionRecord record1 = new TransactionRecord();
        Scanner input1 = new Scanner(System.in);
        System.out.printf("%s\n%s\n%s\n%s\n\n",
          "To terminate input, type the end-of-file indicator",   
          "when you are prompted to enter input.",
          "On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
          "On Windows type <ctrl> z then press Enter");
        System.out.printf("%s\n%s",
           "Enter account number (> 0) and amount.","? ");
        while (input1.hasNext())  // loop until end-of-file indicator
          try // output values to file
            // retrieve data to be output
            record1.setAccount(input1.nextInt());    // read account number
            record1.setAmount(input1.nextDouble());  // read amount
            if (record1.getAccount() > 0)
              // write new record
              output1.format("%d %.2f\n", record1.getAccount(), record1.getAmount());
            } // end if
            else
              System.out.println("Account number must be greater than 0.");
            } // end else
          } // end try
          catch (FormatterClosedException formatterClosedException)
            System.err.println("Error writing to file.");
            return;
          } // end catch
          catch (NoSuchElementException elementException)
            System.err.println("Invalid input. Please try again.");
            input1.nextLine(); // discard input so user can try again
          } // end catch
          System.out.printf("%s %s\n%s", "Enter account number (> 0) ",
            "and amount.","? ");
        } // end while
      } // end method addTransactionRecords
      // add account records to file
      public void addAccountRecords()
        // object to be written to file
        AccountRecord record2 = new AccountRecord();
        Scanner input2 = new Scanner(System.in);
        System.out.printf("%s\n%s\n%s\n%s\n\n",
          "To terminate input, type the end-of-file indicator",   
          "when you are prompted to enter input.",
          "On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
          "On Windows type <ctrl> z then press Enter");
        System.out.printf("%s\n%s",
           "Enter account number (> 0), first name, last name and balance.","? ");
        while (input2.hasNext())  // loop until end-of-file indicator
          try // output values to file
            // retrieve data to be output
            record2.setAccount(input2.nextInt());    // read account number
            record2.setFirstName(input2.next());      // read first name
            record2.setLastName(input2.next());       // read last name
            record2.setBalance(input2.nextDouble());  // read balance
            if (record2.getAccount() > 0)
              // write new record
              output2.format("%d %s %s %.2f\n", record2.getAccount(), record2.getFirstName(),
                record2.getLastName(), record2.getBalance());
            } // end if
            else
              System.out.println("Account number must be greater than 0.");
            } // end else
          } // end try
          catch (FormatterClosedException formatterClosedException)
            System.err.println("Error writing to file.");
            return;
          } // end catch
          catch (NoSuchElementException elementException)
            System.err.println("Invalid input. Please try again.");
            input2.nextLine(); // discard input so user can try again
          } // end catch
          System.out.printf("%s %s\n%s", "Enter account number (> 0),",
            "first name, last name and balance.","? ");
        } // end while
      } // end method addAccountRecords
      // close file
      public void closeTransFile()
        if (output1 != null)
          output1.close();
      } // end method closeTransFile
      // close file
      public void closeOldMastFile()
        if (output2 != null)
          output2.close();
      } // end method closeOldMastFile
    } // end class CreateTextFile--------------------------------------------------------------------------------------------------
    // Exercise 14.8: CreateTextFileTest.java
    // Testing class CreateTextFile
    public class CreateTextFileTest
       // main method begins program execution
       public static void main( String args[] )
         CreateTextFile application = new CreateTextFile();
         application.openTransFile();
         application.addTransactionRecords();
         application.closeTransFile();
         application.openOldMastFile();
         application.addAccountRecords();
         application.closeOldMastFile();
       } // end main
    } // end class CreateTextFileTest-------------------------------------------------------------------------------------------------
    // Exercise 14.8: TransactionRecord.java
    // A class that represents on record of information
    package org.egan; // packaged for reuse
    public class TransactionRecord
      private int account;
      private double amount;
      // no-argument constructor calls other constructor with default values
      public TransactionRecord()
        this(0,0.0); // call two-argument constructor
      } // end no-argument AccountRecord constructor
      // initialize a record
      public TransactionRecord(int acct, double amt)
        setAccount(acct);
        setAmount(amt);
      } // end two-argument TransactionRecord constructor
      // set account number
      public void setAccount(int acct)
        account = acct;
      } // end method setAccount
      // get account number
      public int getAccount()
        return account;
      } // end method getAccount
      // set amount
      public void setAmount(double amt)
        amount = amt;
      } // end method setAmount
      // get amount
      public double getAmount()
        return amount;
      } // end method getAmount
    } // end class TransactionRecord -------------------------------------------------------------------------------------------------
    // Exercise 14.8: AccountRecord.java
    // A class that represents on record of information
    package org.egan; // packaged for reuse
    import org.egan.TransactionRecord;
    public class AccountRecord
      private int account;
      private String firstName;
      private String lastName;
      private double balance;
      // no-argument constructor calls other constructor with default values
      public AccountRecord()
        this(0,"","",0.0); // call four-argument constructor
      } // end no-argument AccountRecord constructor
      // initialize a record
      public AccountRecord(int acct, String first, String last, double bal)
        setAccount(acct);
        setFirstName(first);
        setLastName(last);
        setBalance(bal);
      } // end four-argument AccountRecord constructor
      // set account number
      public void setAccount(int acct)
        account = acct;
      } // end method setAccount
      // get account number
      public int getAccount()
        return account;
      } // end method getAccount
      // set first name
      public void setFirstName(String first)
        firstName = first;
      } // end method setFirstName
      // get first name
      public String getFirstName()
        return firstName;
      } // end method getFirstName
      // set last name
      public void setLastName(String last)
        lastName = last;
      } // end method setLastName
      // get last name
      public String getLastName()
        return lastName;
      } // end method getLastName
      // set balance
      public void setBalance(double bal)
        balance = bal;
      } // end method setBalance
      // get balance
      public double getBalance()
        return balance;
      } // end method getBalance
      // combine balance and amount
      public void combine(TransactionRecord record)
        balance = (getBalance() + record.getAmount()); 
      } // end method combine
    } // end class AccountRecord -------------------------------------------------------------------------------------------------
    // Exercise 14.8: FileMatch.java
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.lang.IllegalStateException;
    import java.util.NoSuchElementException;
    import java.util.Scanner;
    import java.util.Formatter;
    import java.util.FormatterClosedException;
    import org.egan.AccountRecord;
    import org.egan.TransactionRecord;
    public class FileMatch
      private Scanner inTransaction;
      private Scanner inOldMaster;
      private Formatter outNewMaster;
      private Formatter theLog;
      // enable user to open file
      public void openTransFile()
        try
          inTransaction = new Scanner(new File("trans.txt"));
        } // end try
        catch (FileNotFoundException fileNotFoundException)
          System.err.println("Error opening file.");
          System.exit(1);
        } // end catch
      } // end method openTransFile
      // enable user to open file
      public void openOldMastFile()
        try
          inOldMaster = new Scanner(new File("oldmast.txt"));
        } // end try
        catch (FileNotFoundException fileNotFoundException)
          System.err.println("Error opening file.");
          System.exit(1);
        } // end catch
      } // end method openOldMastFile
      // enable user to open file
      public void openNewMastFile()
        try
          outNewMaster = new Formatter("newmast.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openNewMastFile
      // enable user to open file
      public void openLogFile()
        try
          theLog = new Formatter("log.txt");
        catch (SecurityException securityException)
          System.err.println("You do not have write access to this file.");
          System.exit(1);
        } // end catch
        catch (FileNotFoundException filesNotFoundException)
          System.err.println("Error creating file.");
          System.exit(1);
      } // end method openLogFile
      // update records
      public void updateRecords()
        TransactionRecord transaction = new TransactionRecord();
        AccountRecord account = new AccountRecord();
        try // read records from file using Scanner object
          System.out.println("Start file matching.");
          while (inTransaction.hasNext() && inOldMaster.hasNext())
            transaction.setAccount(inTransaction.nextInt());     // read account number
            transaction.setAmount(inTransaction.nextDouble());   // read amount
            account.setAccount(inOldMaster.nextInt());     // read account number
            account.setFirstName(inOldMaster.next());      // read first name 
            account.setLastName(inOldMaster.next());       // read last name
            account.setBalance(inOldMaster.nextDouble());  // read balance
            if (transaction.getAccount() == account.getAccount())
              while (inTransaction.hasNext() && transaction.getAccount() == account.getAccount())
                account.combine(transaction);
                outNewMaster.format("%d %s %s %.2f\n",
                account.getAccount(), account.getFirstName(), account.getLastName(),
                account.getBalance());
                transaction.setAccount(inTransaction.nextInt());     // read account number
                transaction.setAmount(inTransaction.nextDouble());   // read amount
            else if (transaction.getAccount() != account.getAccount())
              outNewMaster.format("%d %s %s %.2f\n",
              account.getAccount(), account.getFirstName(), account.getLastName(),
              account.getBalance());         
              theLog.format("%s%d","Unmatched transaction record for account number ",transaction.getAccount());
          } // end while
          System.out.println("Finish file matching.");
        } // end try
        catch (NoSuchElementException elementException)
          System.err.println("File improperly formed.");
          inTransaction.close();
          inOldMaster.close();
          System.exit(1);
        } // end catch
        catch (IllegalStateException stateException)
          System.err.println("Error reading from file.");
          System.exit(1);
        } // end catch   
      } // end method updateRecords
      // close file and terminate application
      public void closeTransFile()
        if (inTransaction != null)
          inTransaction.close();
      } // end method closeTransFile
      // close file and terminate application
      public void closeOldMastFile()
        if (inOldMaster != null)
          inOldMaster.close();
      } // end method closeOldMastFile
      // close file
      public void closeNewMastFile()
        if (outNewMaster != null)
          outNewMaster.close();
      } // end method closeNewMastFile
      // close file
      public void closeLogFile()
        if (theLog != null)
          theLog.close();
      } // end method closeLogFile
    } // end class FileMatch-------------------------------------------------------------------------------------------------
    // Exercise 14.8: FileMatchTest.java
    // Testing class FileMatch
    public class FileMatchTest
       // main method begins program execution
       public static void main( String args[] )
         FileMatch application = new FileMatch();
         application.openTransFile();
         application.openOldMastFile();
         application.openNewMastFile();
         application.openLogFile();
         application.updateRecords();
         application.closeLogFile();
         application.closeNewMastFile();
         application.closeOldMastFile();
         application.closeTransFile();
       } // end main
    } // end class FileMatchTest-------------------------------------------------------------------------------------------------
    Sample data for master file:
    Master file                         
    Account Number            Name                     Balance
    100                            Alan Jones                   348.17
    300                            Mary Smith                    27.19
    500                            Sam Sharp                   0.00
    700                            Suzy Green                   -14.22Sample data for transaction file:
    Transaction file                    Transaction
    Account Number                  Amount
    100                                         27.14
    300                                         62.11
    300                                         83.89
    400                                         100.56
    700                                         80.78
    700                                         1.53
    900                                         82.17  -------------------------------------------------------------------------------------------------
    My FileMatch class program above has bugs in it.
    The correct results for the newmast.txt:
    100  Alan  Jones  375.31
    300  Mary  Smith  173.19
    500  Sam  Sharp  0.00
    700  Suzy Green  68.09The correct results for the log.txt:
    Unmatched transaction record for account number 400Unmatched transaction record for account number 900------------------------------------------------------------------------------------------------
    My results for the newmast.txt:
    100 Alan Jones 375.31
    300 Mary Smith 111.08
    500 Sam Sharp 0.00
    700 Suzy Green -12.69My results for the log.txt
    Unmatched transaction record for account number 700-------------------------------------------------------------------------------------------------
    I am not sure what is wrong with my code above to make my results different from the correct results.
    Much help is appreciated. Please help.

    From the output, it looks like one problem is just formatting -- apparently you're including a newline in log entries and not using tabs for the newmast output file.
    As to why the numbers are off -- just from glancing over it, it appears that the problem is when you add multiple transaction values. Since account.combine() is so simple, I suspect that you're either adding creating transaction objects incorrectly or not creating them when you should be.
    Create test input data that isolates a single case of this (e.g., just the Mary Smith case), and then running your program in a debugger or adding debugging code to the add/combine method, so you can see what's happening in detail.
    Also I'd recommend reconsidering your design. It's a red flag if a class has a name with "Create" in it. Classes represent bundles of independant state and transformations on that state, not things to do.

  • MSSQL Query/View Single Line Output For Combined Multiple Data Elements - Possible Pivot Table?

    HELLO...
    I hope you experts out there can help me.  Consider the following (2) Tables in MSSQL:
    1. TENDERED --> Primary Key = DATE / DOC_NO / PAYMENT_SEQ_NO
    DATE
    DOC_NO
    PMNT_SEQ_NO
    PAYCODE_TYPE
    AMOUNT
    2. TENDERED_CR_CARD -->Primary Key = DATE / DOC_NO / PAYMENT_SEQ_NO
    DATE
    DOC_NO
    PMNT_SEQ_NO
    CR_CARD_NO_MASKED
    CR_CARD_NAME
    CR_CARD_EXP_DATE
    These two tables are certainly related, based on their Primary Key values.
    Now, consider the following data in those two tables:
    DATE            
    DOC_NO      PMNT_SEQ_NO              
    PAYCODE_TYPE               
    AMOUNT
    03/10/2014         100001 
    1             
    CASH            
    100.00
    03/10/2014         100001 
    2             
    CASH                             
    -9.75
    03/10/2014         100002 
    1             
    CASH                             
    50.00
    03/10/2014         100002 
    2             
    VISA                             
    100.00
    03/10/2014         100002 
    3             
    VISA             
                   250.00
    03/10/2014         100003 
    1             
                            MC
    125.00
    03/10/2014         100003 
    2             
    AMEX           
    75.00
    DATE          
    DOC_NO PMNT_SEQ_NO  CR_CARD_MASKED     
    NAME            
    CR_CARD_EXP
    03/10/2014  100002   2                       4225******801289  
    MARY JONES   2016/08/31
    03/10/2014  100002   3                       4121******637442  
    JOHN DOE      2015/04/30
    03/10/2014  100003   1                       5428******971134  
    MIKE BAKER   2018/09/30
    03/10/2014  100003   2                       3732*****344756    
    LINDA LIU      2017/07/31
    OK...so what we NEED...is a Combined, SINGLE RECORD Audit Report type query. 
    The resulting query should show, based on the Data from above, the SINGLE LINE represented in the Attached Spreadsheet. 
    NOTE...what's important to point out here..is that ONLY the 'CASH' Tender gets "summed"...EACH INDIVIDUAL Credit Card record MUST have its own Field...as represented in the corresponding Columns of the Spreadsheet (i.e. PMT_TYP_1, AMT_1, PMT_TYP_2,
    AMT_2, and so forth).
    PLEASE HELP!  Any suggestions/advice would be most appreciated! 
    Thank You!...Mark

    I would not do this in SQL if I could possibly avoid it.  Instead do it in the front end.
    If you must do it in SQL, this is a dynamic pivot on multiple columns.  Naomi Nosonovsky has a blog at
    http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/dynamic-pivot-on-multiple-columns/ on how to do that.  Look especially at her second example using the claims table.  Of course, you must do some manipulation even before you do the multi-column
    pivot, since you must first combine all the cash entries.
    So one way to do it would be to build a temp table with all the entries you have except the cash entries combined into one payment sequence number.  To do that you may need specifications that are not clear to me from what you have given us.  For
    example, if PMT SEQ 1 is VISA,  PMT SEQ 2 is CASH, PMT SEQ 3 is VISA, PMT SEQ 4 is CASH, and PMT SEQ 5 is VISA, you want to combine the two cash payments.  So they become PMT SEQ 2?  If so, what happens to PMT SEQ 4 - is it left N/A or does
    PMT SEQ 5 become PMT SEQ 4?
    But once you have this temp table with the cash payments combined in the algorithm you need, then you can use Naomi's method to do the multi-column pivot.  Note that Naomi uses the code
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_Name = 'Claims'
    to get the column names from the permanent table Claims.  To get the column names from a temp table use code like the following.  To find the column names in a temp table named #MyTempTable, do
    From tempdb.sys.columns
    Where object_id = OBJECT_ID('#MyTempTable')
    But as I say, if feasible, I would do this in the front end, not in SQL.  T-SQL is a very good language for storing and retrieving data, not so good at formatting it. 
    Tom

  • How to populate multiple records into 1 using addtl keyfigs

    Hi Gurus,
    Please take a look at this scenario.
    I have 3 records coming from source system.
    ex:
    key dateid startdate enddate
    c    1      d1         d2
    c    2      d3         d4
    c    3      d5         d6
    i need to populate these 3 records as one into the infoobject based on dateid.
    (dateid =1 then kf1=d1,kf2=d2;dateid =2 kf3=d3,kf3=d4 dateid = 3 kf1=d5,kf2=d6)
    i added 6 key figures ( kf1 kf2 kf3 kf4 kf5 kf6) as attributes to infoobject.The final
    record should look like the below one.
    key kf1 kf2 kf3 kf4 kf5 kf6
    c d1 d2 d3 d4 d5 d6
    Could you pls give me some thoughts on how to do this in a better way.
    Do i need to write update routine or just the formula in update rule is enough  ??
    Thanks in advance
    -dooDle

    Hi Ramesh,
    The scenario you have mentioned looks really complicated reason being, maintainance.
    Combining 3 records to one is possible in Start Routine. But it will be an expensive one.(I mean loopin)
    Pseudo code:
    LOOP AT DATA_PACKAGE.
    Check which records satisfy your criteria and fill a Temporary table. The fields will be your entire record to be appended to the fact table.
    Endloop.
    Delete your Data Package.
    populate the Temporary Internal Table onto the Data Package.
    Hope it helps.
    Regards,
    Praveen.

Maybe you are looking for

  • Delete skype accounts that are no longer in use.

    Hi We use skype at our company for communicating with clients. Over the years some of our employees have left but their skype accounts are still searchable. We have had cases where customers are not aware that the employee has left and leave messages

  • Help! My calendar synch no longer works!

    I use my work PC to synch my calendar + contacts, and my home Mac to synch music/videos with my iPhone. I typically synch my calendar with my phone every other day, and maybe once a week with my Mac. Ever since I upgraded my iphone to the new Apple f

  • "stopped" status while creating pdf from AI

    Hi, my friend taught me a way (to "print" pdf) to create PDF from illustrator that could make the file size much smaller, but now my question is, it works in my macbook (ppd version 1.1) but not my desktop imac (ppd version 1.0), the printer status a

  • Multiple Documents in Same Window

    I hate bothering people with such a trivial question, but this is driving me nuts... I had been using Acrobat 9.0 Std and opening several documents within the same window, and toggling thru the docs using Ctrl+Tab.  Somehow, something changed and now

  • ORA-01033:ORACLE

    hi, i have this error ORA-01033:ORACLE INITIALIZATION OR SHUTDOWN IN PROGRESS i cant open the database, the database is mounted but i cant open it, because my tablespace is damaged, please help me it emergency