How to put error checking on a code

hi im creating a daily dairy prototype i have almost finished the code it works but there no error checking and i dont know how to write a code to help me validate my prototype here is the code:
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.awt.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTextField;
     public class DailyDairy extends Applet implements ActionListener {
          DailyDairy panel1, panel2, panel3, panel4;
          Component[][] rowData;
          private JComboBox[] jcboxShapeCombo = new JComboBox[7];     
          private String [] shapeName={"Meeting", "Lunch", "Holiday", "Sickness", "Preparing report", "Administrative work", "Emails", "Query"};
          public void init(){
               setLayout(new BorderLayout());
               setBounds (20, 30, 300, 180);
               Panel headerPanel = new Panel();
               headerPanel.setLayout(new GridLayout(1,4));
               //JButton button1 = new JButton("SUBMIT");
               //add(button1);
               Label lblHeader = new Label("Start Time");
               headerPanel.add(lblHeader);
               lblHeader = new Label();
               headerPanel.add(lblHeader);
               add(headerPanel, BorderLayout.NORTH);
               Label lblHeader1 = new Label("End Time");
               headerPanel.add(lblHeader1);
               lblHeader1 = new Label();
               headerPanel.add(lblHeader1);
               add(headerPanel, BorderLayout.NORTH);
               Label lblHeader2 = new Label("Category of Task");
               headerPanel.add(lblHeader2);
               lblHeader2 = new Label();
               headerPanel.add(lblHeader2);
               add(headerPanel, BorderLayout.WEST);
               Label lblHeader3 = new Label("Comment");
               headerPanel.add(lblHeader3);
               lblHeader3 = new Label();
               headerPanel.add(lblHeader3);
               add(headerPanel, BorderLayout.NORTH);
               Label lblHeader4 = new Label("Total Time(Minutes)");
               headerPanel.add(lblHeader4);
               lblHeader4 = new Label();
               headerPanel.add(lblHeader4);
               add(headerPanel, BorderLayout.NORTH);
               Panel data = new Panel();
               data.setLayout(new GridLayout(7, 4));
               rowData = new Component[ 7 ][];
               // One row
               for(int row = 0; row < 7; row++) {
                    rowData[ row ] = new Component[ 5 ];
                         rowData[ row ][ 0 ] = new TextField(10);
                         rowData[ row ][ 1 ] = new TextField(10);
                         ((TextField)rowData[ row ][ 1 ]).addActionListener(this);
                         rowData[ row ][ 2 ]= new JComboBox (shapeName);
                         ((JComboBox)rowData[ row ][ 2 ]).addActionListener(this);
                         //((TextField)rowData[ row ][ 2 ]).addActionListener(this);
                         rowData[ row ][ 3 ] = new TextField(10) ;
                         ((TextField)rowData[ row ][ 3 ]).addActionListener(this);
                         //JComboBox jcboxShapeCombo;
                         //System.out.println(rowData[row][2]);                    
                         //jcboxShapeCombo[2] = new JComboBox (shapeName);
                         //rowData[ row ][ 3 ] = new TextField(10);
                         rowData[ row ][ 4 ] = new TextField(10);
                         ((TextField)rowData[ row ][ 4 ]).addActionListener(this);
                         java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("h:mm");
                         ((TextField) rowData[ row ][ 0 ]).setText(sdf.format(new java.util.Date()));
                         data.add(rowData[ row ][ 0 ]);
                         data.add(rowData[ row ][ 1 ]);
                         data.add(rowData[ row ][ 2 ]);
                         data.add(rowData[ row ][ 3 ]);
                         data.add(rowData[ row ][ 4 ]);
               add(data, BorderLayout.CENTER);
          public void actionPerformed(ActionEvent event) {
               java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("h:mm");
               java.util.Date start = new java.util.Date();
               try {
                    start = sdf.parse(((TextField)rowData[ 0 ][ 0 ]).getText());
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               java.util.Date end = new java.util.Date();
               try {
                    end = sdf.parse(((TextField)rowData[ 0 ][ 1 ]).getText());
                    //System.out.println("end" +end.getTime());
                    //System.out.println("start" +start.getTime());
                    if (end.getTime() > 0) {
                         long difference = (end.getTime() - start.getTime()) / 60000L;
                         ((TextField)rowData[ 0 ][ 4 ]).setText(Long.toString(difference));
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               //long difference = (end.getTime() - start.getTime()) / 60000;
               //java.util.Date difference = new java.util.Date();
               java.util.Date start1 = new java.util.Date();
               try {
                    start1 = sdf.parse(((TextField)rowData[ 1 ][ 0 ]).getText());
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               java.util.Date end1 = new java.util.Date();
               try {
                    end1 = sdf.parse(((TextField)rowData[ 1 ][ 1 ]).getText());
                    if (end1.getTime() > 0) {
                         long difference1 = (end1.getTime() - start1.getTime()) / 60000;
                         //java.util.Date difference = new java.util.Date();
                         ((TextField)rowData[ 1 ][ 4 ]).setText(Long.toString(difference1));
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               java.util.Date start2 = new java.util.Date();
               try {
                    start2 = sdf.parse(((TextField)rowData[ 2 ][ 0 ]).getText());
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               java.util.Date end2 = new java.util.Date();
               try {
                    end2 = sdf.parse(((TextField)rowData[ 2 ][ 1 ]).getText());
                    if (end2.getTime() > 0) {
                         long difference2 = (end2.getTime() - start2.getTime()) / 60000;
                         //java.util.Date difference = new java.util.Date();
                         ((TextField)rowData[ 2 ][ 4 ]).setText(Long.toString(difference2));
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               //long difference2 = (end2.getTime() - start2.getTime()) / 60000;
               //java.util.Date difference = new java.util.Date();
               //((TextField)rowData[ 2 ][ 4 ]).setText(Long.toString(difference2));
               java.util.Date start3 = new java.util.Date();
               try {
                    start3 = sdf.parse(((TextField)rowData[ 3 ][ 0 ]).getText());
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               java.util.Date end3 = new java.util.Date();
               try {
                    end3 = sdf.parse(((TextField)rowData[ 3 ][ 1 ]).getText());
                    if (end3.getTime() > 0) {
                         long difference3 = (end3.getTime() - start3.getTime()) / 60000;
                         ((TextField)rowData[ 3 ][ 4 ]).setText(Long.toString(difference3));
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               //long difference3 = (end3.getTime() - start3.getTime()) / 60000;
               //java.util.Date difference = new java.util.Date();
               java.util.Date start4 = new java.util.Date();
               try {
                    start4 = sdf.parse(((TextField)rowData[ 4 ][ 0 ]).getText());
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               java.util.Date end4 = new java.util.Date();
               try {
                    end4 = sdf.parse(((TextField)rowData[ 4 ][ 1 ]).getText());
                    if (end4.getTime() > 0) {
                         long difference4 = (end4.getTime() - start4.getTime()) / 60000;
                         ((TextField)rowData[ 4 ][ 4 ]).setText(Long.toString(difference4));
               } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               //long difference4 = (end4.getTime() - start4.getTime()) / 60000;
               //java.util.Date difference = new java.util.Date();
               //JTextField aField= (JTextField)event.getSource();
               //if (aField)== rowData[ 0 ][ 1 ])calc row(0, 4);
               //if (aField)== rowData[ 1 ][ 1 ])calc row(1, 4);
}

edit your post to have [ c o d e ] tags around your code,
then maybe someone will have a look.
And try to better explain your goals and your problem. Let us know what you have tried, what did you expect and what have you got.
What is a "prototype" and on what specs should it be validaded?

Similar Messages

  • How to put a check with the date

    Hi,
    I have created a ztable with 3 fields .
    clientcode(3),
    date,--date geneated
    version--- fileversion
    i need to update this table everytime i execute the data. Every time version shd get incremented when i execute the program.  When i excute the program next day version shd be updated by '1'.
    i wrote the code for version updated i'm not getting the logic how to put a check with the date.
      SELECT *
       FROM zfi_enetflver
       INTO TABLE gt_flver.
      SORT gt_flver DESCENDING.
      CLEAR: gv_dt, v_file.
      CONCATENATE sy-datum6(2) sy-datum4(2) INTO gv_dt.
      READ TABLE gt_flver WITH KEY client_code = gv_clcd.
      IF sy-subrc = 0.
        idx = sy-tabix.
        IF gt_flver-zdate = ' '.
          gt_flver-zdate = sy-datum.
        ENDIF.
        IF gt_flver-version = ' '.
          gt_flver-version = '001'.
          gv_filever = gt_flver-version.
          MODIFY gt_flver INDEX idx TRANSPORTING zdate version.
          MODIFY zfi_enetflver FROM TABLE gt_flver. "TRANSPORTING version.
          CONCATENATE 'E:\' 'ENET\' gv_clcd gv_dt '.' gt_flver-version INTO v_file.
        ELSE.
          gt_flver-version = gt_flver-version + 1.
          gv_filever = gt_flver-version.
          MODIFY gt_flver INDEX idx TRANSPORTING version.
          MODIFY zfi_enetflver FROM TABLE gt_flver .
          CONCATENATE 'E:\' 'ENET\' gv_clcd gv_dt '.' gt_flver-version INTO v_file.
        ENDIF.
      ENDIF.
    clientcode is the key field in ztable do i need to make date field key ??
    please help me with the logic

    You need to implement below logic:
    1. check if field_date = sy-datum. in this case do nothing.
    2. else . move sy-datum to field_date .
    3. modify your internal table with field_date .
    4. populate final table to database table .
    hope you get it.

  • How to put a check mark in a PDF document, if using an iPad 2

    How to put an check mark in a PDF document, if using an iPad 2?

    You need to implement below logic:
    1. check if field_date = sy-datum. in this case do nothing.
    2. else . move sy-datum to field_date .
    3. modify your internal table with field_date .
    4. populate final table to database table .
    hope you get it.

  • How to Handle Error Check in a BADI

    Hi all,
    I have implemented a BADI "IWO1_ORDER_BADI" with method CHANGE_COSTRELEVNCY.
    I have put a check , which raises a error on some condition.
    But my problem is that after getting the error the transaction stop in non-editable mode and doesn't allow the user to modify the error and also this method was in PAI.
    Pls let me know how to handle this error.
    Thanks in advance

    Hello Vivek
    Since you do not really tell us on which condition you need to send an error message it is difficult to address your question.
    However, since method CHANGE_COSTRELEVNCY contains the IMPORTING parameter IS_CAUFVD I could imagine that you might successful by implementing ORDER_SCHEDULE as well.
    Perhpas the following scenario might work:
    Check condition in method CHANGE_COSTRELEVNCY and set (e.g.) instance attribute MD_FAILED = 'X' (which you have to define in your implementing class)
    Check error attribute in method ORDER_SCHEDULE
    IF ( me->md_failed = 'X' ).
      do_not_schedule = 'X'.
    ENDIF.
    This logic assumes that your failure condition is due to values in CAUFVD and that the error message should suppress scheduling of the order (both of which might be wrong because we do not know what you want exactly...).
    Regards
      Uwe

  • How to put a report which contains code for  BDC in background

    Hello Experts ,
    Please provide your valuable opinions on following issue,
    My BDC execution is taking longer time and it gives time out error. To avoid this problem i have created a separate report which l contains the BDC code (Call transaction ) and  i have put this report for background execution. But upon doing this My BDC code is not performing the transaction call which it was performing when it was executed individually.  In sm37 it shown the job that i am creating but nothing is actually happening as a result of transaction call.
    The code that i have written is :
    RFC code
    SUBMIT ZREPORT AND RETURN.
    RFC end
    Z_REPORT .
    PERFORM open_job.
    PERFORM get_print_parameters.
    PERFORM job_submit. here in Submit i have specified the another report name(zbdcreport) which contains the actual logic for bdc 
    PERFORM job_close.
    Report END.
    zbdcreport
    The call transaction is as follows :
    ( CALL TRANSACTION TCODE USING BDCDATA
                         MODE   'N' "CTUMODE "N
                         UPDATE 'S' "CUPDATE "S
                         MESSAGES INTO MESSTAB .)
    end zbdcreport
    Can anybody provide the reason for the error . 
    Regards,
    Uma

    Hi
    Check the code using this...
    DATA: number           TYPE tbtcjob-jobcount,
          name             TYPE tbtcjob-jobname VALUE 'JOB_TEST',
          print_parameters TYPE pri_params.
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname          = name
      IMPORTING
        jobcount         = number
      EXCEPTIONS
        cant_create_job  = 1
        invalid_job_data = 2
        jobname_missing  = 3
        OTHERS           = 4.
    IF sy-subrc = 0.
      SUBMIT submitable TO SAP-SPOOL
                        SPOOL PARAMETERS print_parameters
                        WITHOUT SPOOL DYNPRO
                        VIA JOB name NUMBER number
                        AND RETURN.
      IF sy-subrc = 0.
        CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
            jobcount             = number
            jobname              = name
            strtimmed            = 'X'
          EXCEPTIONS
            cant_start_immediate = 1
            invalid_startdate    = 2
            jobname_missing      = 3
            job_close_failed     = 4
            job_nosteps          = 5
            job_notex            = 6
            lock_failed          = 7
            OTHERS               = 8.
        IF sy-subrc <> 0.
        ENDIF.
      ENDIF.
    ENDIF.

  • How to put custom check box in a tableview column

    Hi,
    I would like to put a custom checkbox in a tableview column for each row of the table.
    Such that when the user selects the rows and among those rows if for fews rows this checkbox is active, i need to do some special processing. how can i add a custom check box to a tableview column.
    Can anyone help me in this regard?
    Thanks and Regards,
    Kumar

    Hi,
    You can use the checkbox code within your tableview column:
    <htmlb:tableView id = ".."
    >
    <htmlb:tableViewColumn id = " "
    type = "USER"
    >
    <htmlb:checkBox id = ".."
    selected = " "
    />
    </htmlb:tableViewColumn>
    </htmlb:tableView>
    I hope it helps.
    regards,
    Rohit

  • How to put a check boc in alv grid

    hi gurus i  need to put a checkbox in alv grid output
    not a pop up window
    can anybody inform me
    thank you
    raghavendra

    Hi,
    check these threads
    How can I display a checkbox in ALV? http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Regards

  • How to put Authorisation Check?

    Hi,
    I have built a Module Program. In this there is a Save Button where information in the screen is saved to a Z table.
    I need to put an Authorisation check to this save button. That is only users who have “Save” capability could save.
    Simply there should be an authorisation check before the Save where it will check if the User has the Save option.
    Please guide me on how to do this.
    Thanks,
    Kishan

    Hi Kishan,
    1. AUTHORITY-CHECK
       The above statement is required for authority checking.
        Just see help on it for syntax purpose.
    2. Moreover,
       u will also have to know which authorisation object
       is necessary for your purpose.
       (or else new authorisation object may need tobe created)
    Hope the above helps.
    Regards,
    Amit M.

  • How to put vallidation check

    Respected,
       I have created sales order then billing document of particular service and created an invoice for that order through CIC0 transaction code .customer enjoys the services if payment is due then i had to stop the services so how can I add a validation check  if payment is not cleared or not.
    AVANISH GULATEE
    Edited by: avanish gulatee on Oct 7, 2011 9:45 AM

    Hi Kishan,
    1. AUTHORITY-CHECK
       The above statement is required for authority checking.
        Just see help on it for syntax purpose.
    2. Moreover,
       u will also have to know which authorisation object
       is necessary for your purpose.
       (or else new authorisation object may need tobe created)
    Hope the above helps.
    Regards,
    Amit M.

  • How can I error-check multiple pdf files at once?

    There are programs online but they're too costly.  Isn't there sometime Adobe has built-in where I can hilight an entire list of pdf files and check for errors to see if one of them is giving a font-issue error or etc.
    I'm using Windows 7 and we have different versions of Adobe installed in our office, so if I know which version has what I want that'll help, too.
    Thanks.

    GKaiseril is correct ... Acrobat X Pro you create an action to Start With "A Folder on My Computer" (if there are multiple files in the folder you can set options to ignore them).  Then add the step "Accessibility Check (Full)" and  "Full Check" to that action. 
    You can

  • To put validatition check on date

    hi
    there is data being loaded from a flat file i want to input check on date format as yyyymmdd format only please suggest how to put this check
    regards
    arora

    If you want to understand - run the program in debug and watch what happens to the values.  Or add some more write statements like this.
    PARAMETERS: p_dat TYPE c LENGTH 8.
    DATA: test_date TYPE d,
          input_date TYPE d.
    input_date = p_dat.
    WRITE:/ 'Value of p_dat', p_dat DD/MM/YYYY.
    WRITE:/ 'Value of input_date', input_date DD/MM/YYYY.
    test_date = input_date - 1.
    WRITE:/ 'Subtracted one from input_date to give', test_date DD/MM/YYYY.
    ADD 1 TO test_date.
    WRITE:/ 'Added one to test_date to give', test_date DD/MM/YYYY.
    IF test_date = input_date.
      WRITE: / 'Test_date same as input_date, so the original date was valid'.
    ELSE.
      WRITE: / 'Test_date NOT the same as input_date, so the original date was invalid'.
    ENDIF.
    If p_dat contains an invalid date, then when you subtract one from input_date it gives you '00000000' - i.e. INITIAL for a type D.
    So you could rewrite the code:
    PARAMETERS: p_dat TYPE c LENGTH 8.
    DATA: input_date TYPE d.
    input_date = p_dat.
    SUBTRACT 1 FROM input_date.
    IF input_date IS NOT INITIAL.
      WRITE: / 'Subtraction from input date is not blank so the original date was valid'.
    ELSE.
      WRITE: / 'Subtraction from input date is blank so the original date was invalid'.
    ENDIF.
    matt

  • Check on T-code vl02n

    There is a requirement that i have to put a check on T-code vl02n.
    If the status of that particular delivery doc is 'C' then if i change the quanity in the additional tab then it should not allow me to change the quantity as the status is 'C' and throw a message.
    But if the same delivery doc is reversed then it sholud allow me to change the quanity.
    Please help.
    Thanks in advance.
    Moderator message : Spec dumping is not allowed, search for available information.  Thread locked.
    Edited by: Vinod Kumar on Nov 3, 2011 3:33 PM

    Dear Consultant,
    SAP note 32654 explains why the system takes the account
    assignment at a higher level for automatically generated lines like
    small differences.  You should maintain an entry in OKB9 at a higher
    level than valuation area, profit center or business area.
    You should define a default value in OKB9 at company code level.
    This is the highest level and you have to enter a default value as the
    note 32654 describes. There are some circumstances where the system
    needs this high level default value, and it does not take the one
    defined at business area / valuation area / material (profit center)
    level.
    This particular problem with the system not being able to use
    the 'detailed' OKB9 assignment happens when the system creates
    an automatically generated line in a document. This is driven by
    the transaction key and is then linked to OKB9 by the G/L account
    defined for the transaction key. The most common transaction keys
    that are used in auto-generated lines are 'DIF' (small diff) and
    'KDR' (exchange rate).
    The system works as designed because in the above cases, it cannot
    decide from which material master it should take the profit center.
    I would suggest to either set up an default account assignment at a
    higher level (company code level), which is the first screen when
    you access OKB9.
    Please, let me know the results after changing the customizing
    settings accordingly.
    Kind regards,
    Dr. Ravi Surya Subrahmanyam. PhD (Finance),
    Senior Consultant,
    SAP’s Global Delivery Center,
    Answerthink India Ltd
    Hyderabad. India
    Phone :  +91 – 9848550024
    Mail : fico_rss at yahoo,com

  • JOptionPane.showInputDialog error checking?

    menu = JOptionPane.showInputDialog("What would you like to do next: \n" +
    "1: Enter another person (" + (data.length - index - 1) + " entries left)\n" +
    "2: Display data sorted by First Name\n" +
    "3: Display data sorted by Last Name\n" +
    "4: Display data sorted by Birth Date\n" +
    "5: Search data by First Name\n" +
    "6: Search data by Last Name\n" +
    "7: Search data by Birth Date\n\n" +
    "0: Exit");How can I error check that to make only those values will be entered. I thought I would be able to say something like, if(menu != "0") and so on, but that doesn't seem to work, neither does if(menu == null). Thanks in advance for any help, I am probably just doing something stupid.

    You will get more chance on a suitable answer if you post this Swing related question in the Swing forum: http://forum.java.sun.com/forum.jspa?forumID=57

  • HT1451 How do I re-check all songs.  I somehow unchecked them and to manually re-check them all will take forever

    I accidentally un-checked all my songs in I-Tunes and re-checking them manually will take forever!  Anyone know how to put the check mark next to all the songs at the same time?

    CTRL+click on any empty check box will check all visible tracks.
    tt2

  • When I error check my Pages-created epub, I get the error code "undeclared prefix: ibooks." How do I resolve this error?

    I'm creating an epub with Pages for upload to various sites. When I error check the epub, I get only one error message: "undeclared prefix: ibooks." The file itself works perfectly and looks fantastic when I open it directly from my computer/ipad with numerous Mac-compatible reading apps. However, I have no idea what distortions this "error" will cause when the epub is uploaded and redistributed. Has anyone else had this problem? If so, did it create problems in distribution? Or is it irrelevant? Thanks for any practical and straight forward answers and/or suggestions.

    Based on that, it does sound like the sites you were having problems with had to do with filenames, not this error.  I can imagine a site running a standard EPUB verifier, and if any errors at all are thrown rejecting the file, but practically speaking an unknown META tag (what's causing this error) should be ignored by the parser and therefore by definition be harmless.
    I was using a free Java-based checker myself, and the fact that I managed to clear up the error indicates to me (unless I'm remembering wrong or misunderstood what fixed it in my case) that it's probably not technically the EPUB checker's failure to recognize the Apple META property; more accurately, it's that the XML dictionary the file is referencing doesn't include the Apple items in it, so the EPUB checker is correctly complaining about it.
    It could also be something as simple as Pages generating a file that is marked as an EPUB v2 file but that uses EPUB v3 features (I know my book was intended to be v3, and I could have inadvertently used headers for v2).
    Regardless, if the sites accept it, there's a good chance it is okay; DRM, at least, isn't going to change anything--only if an e-reader changes its EPUB parser at some point and breaks something, which seems unlikely.
    However, the best way to find out if it's going to work right is to test it.  Kindle is far and away the most popular reader, so try it with that and see if it comes out looking how you expect.  You should be able to view it in the Kindle application, and there is also a Kindle simulatior available from Amazon that lets you see how an e-paper Kindle will render books without having to buy one.  They have very limited EPUB support as far as features go, so it's definitely worth testing even if there are no errors--a lot of things iBooks will display just fine a Kindle will choke on.  The older e-paper Nooks, in my experience, are even worse.

Maybe you are looking for