Need help with representing 2 bits of data in a column

I Need help representing only 2 bits of data in a column in order to save space.
Is that possible?

CommitMan wrote:
I Need help representing only 2 bits of data in a column in order to save space.
Is that possible?Yes - using Assembler....
If you need to count bits to save space, then you must be on 70's, or early 80's, hardware. So using Assembler should not be a problem. Let me guess.. a 8051 microcontroller from the 1980?
Here's what the 8051 code and memory optimisation manual says:
>
The simplest and best way to get dramatic improvements
in efficiency is to look for all variables that will have only
binary values (0 and not 0), and define them as type 'bit‘:
bit myVar;With bit variables, the full set of 8051 bit-level assembler
instructions can be used to generate very fast and
compact code. For example, the following C code:
myVar = ~myVar;
if (!myVar)
}Generates only two lines of assembler:
B200    CPL myVar
200006  JB myvar,?C0002This example uses only 5 flash bytes and 8 CPU cycles.
When you use bit variables, you can implement a
nontrivial line of C code with just one assembler
instruction.
>
<i>PS. Yes, the above is really from a manual for a real 80s microcontroller. And yes, I'm poking fun at your question as saving bits were a problem in the 80s and prior. It should not be a problem in the 21st century information system and database.</i>

Similar Messages

  • Need help with code for adding dates to form

    Hello forum goers
    I'm new to making forms and figured out how to auto add the date, however I need the form to change the date for every copy made.
    For example today is 06/08/2012 if I print 10 copies of the form it will output 10 pages ranging from 06/08/2012 to 06/17/2012. If code exists to do this I would be very gratefull to whoever helps, I also wouldn't mind if that is not possible for manually inputing the start / end dates.
    Currently I print 15-30 copies of the form and hand write each of the dates but I'm just getting to busy to do that. I also cannot print one a day it must be in batches.
    Thanks in advanced.

    What you are asking for is more complex than just setting the current date. Each time the form prints it has to know that it has to change the date. I would suggest doing this.
    First, setup a document level script to set the date to the current date. I suspect that you have already done this?
    Next, Create a "DidPrint" document action to increment the date.  To do this the script will need to scan the current text value of the date, add one day to it, and then reformat it.  You'll find information on this type of scripting in these articles:
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt-part-2
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt-part-3
    Since the increment happenes in the Did Print you will need to print each copy individually. If you enter 10 copies in the print dialog it won't work. You have to print one at a time.  You can automate this activity with a console script.
    One of the advantages of incrementing in the DidPrint is that you can also manually enter a date and it will increment from there.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)
    Having trouble, Why Doesn't my Script Work?

  • Urgent-Need help with code for Master data enhancement

    hi Experts,
    I have appended YMFRGR field(Table MARC) to 0MAT_PLANT_ATTR datasource.
    The key fields in the MARC table are MATNR and WERKS.Can anybody help with the user exit to populate this field,as am pretty new to ABAP.
    Thanks in advance

    Hi,
    go through this link which has the similar problem:
    https://forums.sdn.sap.com/click.jspa?searchID=1331543&messageID=2794783
    hope it helps.
    Thanks,
    Amith

  • Need help with RANK() on NULL data

    Hi All
    I am using Oracle 10g and running a query with RANK(), but it is not returning a desired output. Pleas HELP!!
    I have a STATUS table that shows the history of order status.. I have a requirement to display the order and the last status date (max). If there is any NULL date for an order then show NULL.
    STATUS
    ORD_NO | STAT | DT
    1 | Open |
    1 | Pending |
    2 | Open |
    2 | Pending |
    3 | Open |1/1/2009
    3 | Pending |1/6/2009
    3 | Close |
    4 | Open |3/2/2009
    4 | Close |3/4/2009
    Result should be (max date for each ORD_NO otherwise NULL):
    ORD_NO |DT
    1 |
    2 |
    3 |
    4 |3/4/2009
    CREATE TABLE Status (ORD_NO NUMBER, STAT VARCHAR2(10), DT DATE);
    INSERT INTO Status VALUES(1, 'Open', NULL);
    INSERT INTO Status VALUES(1, 'Pending', NULL);
    INSERT INTO Status VALUES(2, 'Open', NULL);
    INSERT INTO Status VALUES(2, 'Pending',NULL);
    INSERT INTO Status VALUES(3, 'Open', '1 JAN 2009');
    INSERT INTO Status VALUES(3,'Pending', '6 JAN 2009');
    INSERT INTO Status VALUES(3, 'Close', NULL);
    INSERT INTO Status VALUES(4, 'Open', '2 MAR 2009');
    INSERT INTO Status VALUES(4, 'Close', '4 MAR 2009');
    COMMIT;
    I tried using RANK function to rank all the orders by date. So used ORDER BY cluse on date in descending order thinking that the null dates would be on top and will be grouped together by each ORD_NO.
    SELECT ORD_NO, DT, RANK() OVER (PARTITION BY ORD_NO ORDER BY DT DESC)
    FROM Status;
    ...but the result was something..
    ORD_NO |DT |RANKING
    *1 | | 1*
    *1 | | 1*
    *2 | | 1*
    *2 | | 1*3 | | 1
    3 |1/6/2009 | 2
    3 |1/1/2009 | 3
    4 |3/4/2009 | 1
    4 |3/2/2009 | 2
    I am not sure why didn't the first two ORD_NOs didn't group together and why ranking of 1 was assigned to them. I was assuming something like:
    ORD_NO |DT |RANKING
    *1 | | 1*
    *1 | | 2*
    *2 | | 1*
    *2 | | 1*
    3 | | 1
    3 |1/6/2009 | 2
    3 |1/1/2009 | 3
    4 |3/4/2009 | 1
    4 |3/2/2009 | 2
    Please guide me if I am missing something here?
    Regards
    Sri

    Hi,
    If i well understood, you don't need rank
    SELECT   ord_no, MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
        FROM status
    GROUP BY ord_no
    SQL> select * from status;
        ORD_NO STAT       DT
             1 Open
             1 Pending
             2 Open
             2 Pending
             3 Open       2009-01-01
             3 Pending    2009-01-06
             3 Close
             4 Open       2009-03-02
             4 Close      2009-03-04
    9 ligne(s) sélectionnée(s).
    SQL> SELECT   ord_no, MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
      2      FROM status
      3  GROUP BY ord_no;
        ORD_NO DT
             1
             2
             3
             4 2009-03-04
    SQL>

  • Need help with certain bit of server code

    i am making a chat messenger and are having trouble with this part, i have created outputstreams as a hashtable, i hope thats correct.. the problem is it wont call up the serverThread.. is there and easier way using static variables so it doesnt have to pass the parameters? any ideas..
          // Create a DataOutputStream for writing data to the
          // other side
          DataOutputStream dout = new DataOutputStream(s.getOutputStream());
          // Save this stream so we don't need to make it again
         // Hashtable outputstreams = new Hashtable();
          outputStreams.put(s, dout);
          // Create a new thread for this connection, and then forget
          // about it
          new ServerThread(this, s);
       static void ServerThread(Server server,Socket socket) {
        // Save the parameters
        this.server = server;
        this.socket = socket;
        // Start the thread
        start();
      }

    This application is in functional state. The only thing which
    is not working is "send private message". Gui is there and functionality
    is also there but I dont have time to put it together.
    There is a readme file inculded in the zip file PLEASE READ THE FILE BEFORE RUNNING THE APPLICATION
    Dont complain for dirty code.

  • Need help with how to store data in array in from reading file

    i have a file named xxx.txt
    i need to retreive data from that file. the data that i want to retrieve is enclosed with << >>
    temp xxx-123 ccc << 90.5>>
    haha xxx-563 sss 85.2
    after a few lines, the another record appear.
    temp2 xxx-123 ccc << 190.5>>
    haha2 xxx-563 sss 885.2
    i would like to record down the data, 90.5 & 190.5, how do i go about doing so, will appreciated it if someone would guide me along. thanks

    After you have read a line from the file either
    find the location of << and >> and substring the stuff in between or
    use regex (regular expression) however this is advanced and may be beyond your level of understanding.

  • Need help with dead blackberry / recovering data

    Device: BlackBerry Curve 8320 (Tmobile)
    A few days ago my BB Curve 8320 spontaneously just turned off and would not turn on again.  No blinking light, nothing.  Battery was fully charged, the phone is only 2 months old, and was not damaged in any way.  Battery was pulled out and re-inserted no luck.  Phone taken to T-mobile store and phone tested with new battery, and still no progress.  T-mobile replaced the phone free of charge. 
    I am struggling to recover my addressbook, text messages, and photos from the old device.  Every once in a while when the phone is plugged into the charger, the old device will display a battery with a diagnol red line through it.  I have attempted to use the desktop manager to recover the data, but again no luck.  Most of the time, it does not recognize the phone, and I have tried what has been suggested on multiple forums, with taking the battery out, catching the desktop manager for the split second it recognizes the device on the usb port.  I have been successful with that, but it won't let me sync or backup the device.  It allows me to load the application loader, but when i do this, it prompts me for .alx type application loader files, even though i have downloaded the device manager software from t-mobile, so I am unable to re-load the OS.  I also attempted to use the switch device wizard.  This also seemed like it was working.  I was able to connect both curves to my computer through different USB ports and it seemed like it was doing something, but when it's all done with the process, my new device still does not have my old addresses or text messages. 
    If anyone has any suggestions / advice on restoring my old device without losing the onboard data or some way to access the data so I can import that into my new curve, I would greatly appreciate it.
    Thanks!

     I HAD A BB CURVE 8320, I TRY ALL THE PROGRAMS ANYTHING WORK. MY BB TURN ON N TURN BACK OFF. I TRY LETTING THE BRAND NEW BATTERY SEAT OUT FOR 3O SECONDS STILL DIDNT WORK. WHAT SHOULD I DEW SOMEONE PLZ HELP ME.

  • Need help with clearing on screen data

    Hi all,
    I have a transaction which works like SM30 (table maintenance). In my main screen, I have 50 blank fields (created by appending 50 blank rows to an internal table) on the ALV grid for user new entries with 2 buttons: Save and Delete. Once the user has entered the data and click on Save, it will validate the entries and put into internal table before saving into the database.
    The problem arise when I want to delete the entries. When user click on Delete, it will clear the entries in the selected row. My problem is, how do I clear the data on the screen since this data is not yet inserted into internal table? These entries are new entries just entered by the users and not being put into internal table or in the database yet.

    Once user press the delete button ,
    in the user_command event you need to
    first insert the values to internal table with delete flag in the internal table , then delete the line the user selected for delete,
    then call
    method "g_grid->refresh_table_display" after row has been deleted.
    aRs

  • Need help with small bit of code

    Hello I am using JBuilder 9 and it cannot resolve getHeader() and getSOAPBody() any help will be appreciated to fix the problem or any suggestions
    SOAPHeader header = message.getHeader();
    SOAPBody body = message.getSOAPBody();
    header.detachNode();

    The jar files are added it reads all the imports but it just doesnt read the lines marked by stars and its coming out with errors
    cannot resolve symbol:method getSOAPHeader() in class javax.xml.soap.SOAPMessage (for the 1st 1)
    cannot resolve symbol:method getSOAPBody() in class javax.xml.soap.SOAPMessage (for the 2nd 1)
    cannot resolve symbol:method getSOAPBody() in class javax.xml.soap.SOAPMessage (for the 3rd 1)
    import javax.xml.soap.*;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPPart;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPHeader;
    SOAPHeader header = message.getSOAPHeader();
    SOAPBody body = message.getSOAPBody();
    SOAPBody soapBody = response.getSOAPBody();
    //First create the connection
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection connection = soapConnectionFactory.createConnection();
    SOAPFactory soapFactory = SOAPFactory.newInstance();
    //Create the actual message
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();
    //Create objects for the message parts
    SOAPHeader header = message.getSOAPHeader();*******************
    SOAPBody body = message.getSOAPBody();***********************
    header.detachNode();
    //Populate the message
    Name bodyName = soapFactory.createName("GetLastTradePrice", "m",
    "http://wombats.ztrade.com");
    SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
    Name name = soapFactory.createName("symbol");
    SOAPElement symbol = bodyElement.addChildElement(name);
    symbol.addTextNode("SUNW");
    URL endpoint = new URL("http://wombat.ztrade.com/quotes");
    SOAPMessage response = connection.call(message, endpoint);
    connection.close();
    SOAPBody soapBody = response.getSOAPBody(); *********************

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • Need help with saving data and keeping table history for one BP

    Hi all
    I need help with this one ,
    Scenario:
    When adding a new vendor on the system the vendor is suppose to have a tax clearance certificate and it has an expiry date, so after the certificate has expired a new one is submitted by the vendor.
    So i need to know how to have SBO fullfil this requirement ?
    Hope it's clear .
    Thanks
    Bongani

    Hi
    I don't have a problem with the query that I know I've got to write , the problem is saving the tax clearance certificate and along side it , its the expiry date.
    I'm using South African localization.
    Thanks

  • Need Help with Dates

    I am printing a calendar and certain events will be helds on certain dates.
    One can edit the event if it has not passed the date. Events in the past can be viewed but not edited.
    When I query the database the date must be formatted dd-MMM-yy
    I am able to get today's date by doing this:
    java.util.Date today = new java.util.Date();
    String formatString = "dd-MMM-yy";
    SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    String today_str = sdf.format(today);
    My code for printing the calendar: I left out some of the table formatting in the JSP page.
    GregorianCalendar d = new GregorianCalendar();
    int today = d.get(Calendar.DAY_OF_MONTH);
    int month = d.get(Calendar.MONTH);
    d.set(Calendar.DAY_OF_MONTH,1);
    int weekday = d.get(Calendar.DAY_OF_WEEK);
    for(int i = Calendar.SUNDAY; i < weekday; i++)
    out.print("<td> </td>");
    do {
    int day = d.get(Calendar.DAY_OF_MONTH);
    out.print("<td>" + day + "</td>");
    String formatString = "dd-MMM-yy";
    SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    //if(event exists on this day
    // Get results
    // print link for viewing
    // if (after today) print link for edit
    if(weekday == Calendar.SATURDAY)
    out.println("</tr><tr valign=top>");
    d.add(Calendar.DAY_OF_MONTH,1);
    weekday = d.get(Calendar.DAY_OF_WEEK);
    } while(d.get(Calendar.MONTH) == month);
    if(weekday != Calendar.SUNDAY)
    System.out.println();
    The part I need help on is this:
    //if(event exists on this day
    // Get results
    // print link for viewing
    // if (after today) print link for edit
    I'm looping through each day of the month to print the days. I have the month, day, year as integers. How can I create a date object out of that and compare it to today's date to test if it's before or after today???
    All the function in the Date class that I think would do this have been deprecated.

    Need Help with Dates
    Here is some information about dates:
    There are many edible palm fruits, and one of the most widespread and favored of these is the data (Phoenix dactylifera). Dates were cultivated in ancient land from Mesopotamia to prehistoric Egypt, possibly as early as 6000 B.C. Then--as now--dates were a staple for the natives of those dry regions. Much later, Arabs spread dates around northern Africa, and dates were introduced into California by the Spaniards in 1765, around Mission San Ignacio.
    The date prefers dry, hot climates, because date fruits are injured at temperatures of 20 degrees F, and the damp climate of the California coast was not favorable for fruit production. In the mid-1800s, the date industry developed in California's hot interior valleys and in Arizona. Now the date industry in the United States is localized mostly in the Coachella Valley, where the sandy soils permit the plants to be deeply irrigated. Today the new varieties, mostly introduced in this century, produce about 40 million pounds of dates per annum, or over 60% of the dates consumed in this country. The rest are imported mainly from Persia. According to one survey, about one million people are engaged entirely in date palm cultivation worldwide.
    Hope that helps.

  • Need help with Editor

    I am brand new to doing a post, so please bear with me. I have Photoshop elements 8. the program is not allowing me to open the editor. Any ideas? I click on it and it acts like it is thinking and then nothing....

    oh my!! i think this may be WAY over my head!! i have a computer savvy friend that I will get to look at your suggestion. fyi, I had called the help line and for $30 they can talk to me. he suggested that i buy Photoshop 9 and get free "phone talk".
    thanks
    Date: Mon, 7 Feb 2011 12:20:54 -0700
    From: [email protected]
    To: [email protected]
    Subject: need help with Editor
    Try making a direct desktop icon for the Organizer and Editor and that will bypass the welcome screen and any advertising.
    On Windows right click on the desktop and select New >> Shortcut
    Browse to Computer OS C:
    And find the PSE Organizer application in Program Files or Program Files (x86) on Windows 7 - 64 bit.
    Inside the Adobe >> Photoshop Elements Organizer (yellow folder) you are looking for an application file “PhotoshopEementsOrganizer” with six small icons (e.g. representing thumbnails)
    Select it and click OK
    Click next
    Rename by taking out Photoshop Elements leaving just the word Organizer
    Then click finish
    You should now be able to launch directly form the desktop by double clicking on the icon.
    +You can set up a similar direct link to the Editor application (.exe file which has the blue PSE icon). As before take out Photoshop Elements just leaving the description Editor and it will show up clearly on the desktop.
    +You can keep the standard Photoshop icon which links to the welcome screen but I prefer to delete it from the desktop. If you ever need to get to the welcome screen you simply click Window >>Welcome on the top menu when the application is open.
    >

  • Need help with AnyConnect 2.5.3055

    When I try to connect via the AnyConnect client I am presented with the certificate pop up.
    If I accept the certificate I get a message at the bottom of the AnyConnect screen stating “Connection attempt has failed”.
    If I deny it I get a pop up message from AnyConnect stating “AnyConnect cannot confirm it is connected to your secure gateway. The local network may not be trustworthy. Please try another network”.
    I am connecting to a Cisco 2851 running Cisco IOS Software, 2800 Software (C2800NM-ADVSECURITYK9-M), Version 12.4(24)T2, RELEASE SOFTWARE (fc2)

    CommitMan wrote:
    I Need help representing only 2 bits of data in a column in order to save space.
    Is that possible?Yes - using Assembler....
    If you need to count bits to save space, then you must be on 70's, or early 80's, hardware. So using Assembler should not be a problem. Let me guess.. a 8051 microcontroller from the 1980?
    Here's what the 8051 code and memory optimisation manual says:
    >
    The simplest and best way to get dramatic improvements
    in efficiency is to look for all variables that will have only
    binary values (0 and not 0), and define them as type 'bit‘:
    bit myVar;With bit variables, the full set of 8051 bit-level assembler
    instructions can be used to generate very fast and
    compact code. For example, the following C code:
    myVar = ~myVar;
    if (!myVar)
    }Generates only two lines of assembler:
    B200    CPL myVar
    200006  JB myvar,?C0002This example uses only 5 flash bytes and 8 CPU cycles.
    When you use bit variables, you can implement a
    nontrivial line of C code with just one assembler
    instruction.
    >
    <i>PS. Yes, the above is really from a manual for a real 80s microcontroller. And yes, I'm poking fun at your question as saving bits were a problem in the 80s and prior. It should not be a problem in the 21st century information system and database.</i>

  • 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.

Maybe you are looking for

  • Creation of new infotype 9001

    am trying to create the new infotype 9001 (PM01) for license but SAP not allowing.. asking access key to proceed further.. wot to do? Shan

  • Open Items Are Locked in a Payment Proposal

    Dear experts, Please isn't there an easier way to found out in which proposal run an open item is locked without displaying the database table REGUS via the transaction code SE16? I mean, isn't there a kind of transaction code users can run by themse

  • Aggregation Problem in DSO (Urgent)

    Hello Experts,                      I am loading data from PSA to a DSO where my Key is Activity type (e.g 2020, 2040, 2060, 2080). For each of the activity type I want to aggegate  the gender for male/female. In the key figure for Zmale I am using S

  • In ob28 step buttone is in deactive state

    Dear All, Can any one help me by telling the reason for the Step button in 0b28 screen is in deactive state. Beacuse I am not able to create validation. Help .... B.S.Rao

  • Replace 'raise' with message

    Hello! Replace 'raise' with message is the warning which I get. What has to be done ? Regards sas   CALL FUNCTION '/BMW/STD_IFF_SNR_ZU_AG'        EXPORTING             werk       = iff_daten-werk             sachnummer = iff_daten-sachnummer