Help needed in Logical Database Programming

Hello Gurus,
I am working on a Report on ASSET ACTIVITY BY DATE RANGE .
The program is copied from std. program S_ALR_87011990.
The above std. program displays for the whole financial year. This is modified for a particalar period range in the new leveraged program.
My question is in the below code.
We are fetching data using LDB ADA. The statement "GET anlcv" works fine here, I mean Sy-subrc is 0 and anlcv structure has some data in it.
When it comes to statement "GET anepv" in the below code, we are not getting any data into that structure and sy-subrc NE 0. Then it is skipping all the get statements and directly going to statement " PERFORM abga_simulieren.".
My logic lies in between this Get statement and the perform statement. When i see it in debugging mode my statement is not executed at all.
What needs to be done. Please anyone help me.
GET anlcv.
CHECK select-options.
MOVE anlcv TO sav_anlcv.
GET anepv.
CHECK select-options.
Nur Bewegungen des Jahres des Berichtsdatums durchlassen.
CHECK anepv-bzdat GE sav_gjbeg.
CHECK anepv-bzdat IN so_bzdat. "Added for SIR-3132
Bewegungen in SAV_ANEPV sammeln.
MOVE anepv TO sav_anepv.
APPEND sav_anepv.
GET anlb LATE.
Check auf Bestandskonto bei Gruppensummen erst hier, wegen
fehlender Abgänge/Umbuchungen
IF NOT summb IS INITIAL.
IF NOT anlav-ktansw IN so_ktanw.
REJECT 'ANLAV'.
ENDIF.
ENDIF.
ANLCV aus Save-Area zurueckholen.
CHECK NOT sav_anlcv-anln1 IS INITIAL.
MOVE sav_anlcv TO anlcv.
Abg-Simu: Abgang simulieren.
PERFORM abga_simulieren.
Promise to reward points
Regards
Mac

1) delete line  CHECK anepv-bzdat ge sav_gjbeg.
2) test with an asset , which has movements (purchases) in your intervall so_bzdat.
otherwise post a movement (e.g. transaction type 100) with tcode abzon
A.

Similar Messages

  • Need of logical database

    Hi,
    Can any one briefly explain what is the need of Logical database?
    In which case , abapers r going for logical database?
    regards,
    Pooja

    Hi Pooja,
    A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables.
    GET will fetch the table data immediately
    GET LATE
    In the LDB when you define the table structure in hierarchy, first it will fetch the higher node data and then all the below node tables data and comes to a second record in the top node table. for this GET Late is used.
    You can create any number of primary keys in a table
    The programmer need not worry about the primary key for each table.Because Logical database knows how the different tables relate to each other,and can issue the SELECT command with proper where clause to retrieve the data.
    i)An easy-to-use standard user interface.
    ii)check functions which check that user input is complete,correct,and plausible.
    iii)meaningful data selection.
    iv)central authorization checks for database accesses.
    v)good read access performance while retaining the hierarchical data view determined by the application logic.
    GO THROUGH LINKS -
    http://www.sap-basis-abap.com/saptab.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
    /people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
    Re: **LDB**
    www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html
    www.sap-img.com/abap/abap-interview-question.htm
    www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm
    Reward if useful.
    Regards,
    Hemant

  • Problem about logical database programming

    Dear all,
    I have a logical database PRPS_R which contail PRPS and some additional fields.
    In my abap report, I call this logical database by "GET PRPS_R". Can I ask how to perform sorting to the  logical database in ABAP report?
    Thanks
    Sunny

    PRPS_R is a structure of logical database PSJ
    there is a user-exit available EXIT_FDBPS000_001

  • Help need on ALV Report Program

    Hi all.....
    im facing problem in the following code....it shows 'No records found' (as same as my coding generated)whenever i give wrong vendor no:(lifnr), but if i gives the correct one(as in table lfa1)...it shows Runtime error as <b>"the occupied line length in the program text must not exceed the width of the internal table"</b>..
    pls verify...
    just go thru my code and revert me the feedback of what i did wrong and pls i dont want any example codes from u guys since i've seen so much and couldnt solve it with that...
    hope u understand......what i need
    Rewards based on the above reuirements....only
    *******************************CODING***********************************************
    REPORT ZALV_MERGE.
    TABLES:lfa1.
    DATA:BEGIN OF itab OCCURS 100,
    lifnr LIKE lfa1-lifnr,
    land1 LIKE lfa1-land1,
    name1 LIKE lfa1-name1,
    ort01 LIKE lfa1-ort01,
    regio LIKE lfa1-regio,
    sortl LIKE lfa1-sortl,
    END OF itab.
    data: i_repid like sy-repid,
          i_tabix like sy-tabix.
    TYPE-POOLS: slis.
    DATA: fcat TYPE slis_t_fieldcat_alv.
    SELECT-OPTIONS: LIFNR FOR LFA1-LIFNR.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE itab WHERE lifnr IN LIFNR.
    clear i_tabix.
    describe table itab lines i_tabix.
    if i_tabix lt 1.
    write:/ 'No materials found'.
    exit.
    endif.
    i_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = i_repid
       I_INTERNAL_TABNAME           = 'ITAB'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_INCLNAME                   = I_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      CHANGING
        CT_FIELDCAT                  = fcat
      EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM             = i_repid
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
       I_STRUCTURE_NAME               = 'ITAB'
      IS_LAYOUT                      =
       IT_FIELDCAT                    = fcat
       I_SAVE                         = 'A'
      TABLES
        T_OUTTAB                       = ITAB
    EXCEPTIONS
       PROGRAM_ERROR                  = 1
       OTHERS                         = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    Hi,
    think inthis program in the function module REUSE_ALV_FIELDCATALOG_MERGE
    in exporting parameter you are using -->
    I_INTERNAL_TABNAME = <itab_name>
    this <itab_name> is not like any physical structure .So make a structure through SE11 like <itab_name>.
    u have to create a structure in SE11 with the fields, and then pass that structure into the REUSE_ALV_FIELDCATALOG_MERGE , in the parameter
    I_internal_tabname = ' structure name '.
    even though u create a structure, u need to pass it to the table parameter.
    then it will work.
    Otherwise manually build the fieldcatalog.
    find the following code as an example.
    DATA : l_pos TYPE i VALUE 1.
      ist_fieldcat-fieldname = 'POSID'.
      ist_fieldcat-tabname   = 'IT_FINAL'.
      ist_fieldcat-outputlen = 24.
      ist_fieldcat-col_pos   = l_pos.
    ist_fieldcat-ddictxt = 'L'.
      ist_fieldcat-key = 'X'.
      ist_fieldcat-seltext_l = 'Appropriation Request Number'.
      APPEND ist_fieldcat.
      CLEAR ist_fieldcat.
      l_pos = l_pos + 1.
      ist_fieldcat-fieldname = 'TXT04'.
      ist_fieldcat-tabname   = 'IT_FINAL'.
      ist_fieldcat-outputlen = 4.
      ist_fieldcat-col_pos   = l_pos.
      ist_fieldcat-ddictxt = 'L'.
    ist_fieldcat-key = 'X'.
      ist_fieldcat-seltext_l = 'Status'.
      ist_fieldcat-EMPHASIZE = 'C400'.
      APPEND ist_fieldcat.
      CLEAR ist_fieldcat.
      l_pos = l_pos + 1.
      ist_fieldcat-fieldname = 'UDATE'.
      ist_fieldcat-tabname   = 'IT_FINAL'.
      ist_fieldcat-outputlen = 8.
      ist_fieldcat-col_pos   = l_pos.
      ist_fieldcat-ddictxt = 'L'.
      ist_fieldcat-key = 'X'.
      ist_fieldcat-seltext_l = 'Status Date'.
    IST_FIELDCAT-EMPHASIZE = 'C600'.
      APPEND ist_fieldcat.
      CLEAR ist_fieldcat.
    <i><b>Reward point if find helpful
    Debjani</b></i>

  • Help neede in changing standard program CN41

    Dear all,
    I am working on a requirement in PS module.
    The requirement is I need to copy the standard program RCNST000 of CN41 and I need to add some extra fields.
    Here in initial display project object, project object.
    when I select duration and Order cost plan 000 from the list It will display duration and order cost plan in the report.
    My requirement is when they select that I need to display cost per day and cost for currect month.
    Can anybody help me.
    Thnaks and regards
    Anil

    Dear all,
    I am working on a requirement in PS module.
    The requirement is I need to copy the standard program RCNST000 of CN41 and I need to add some extra fields.
    Here in initial display project object, project object.
    when I select duration and Order cost plan 000 from the list It will display duration and order cost plan in the report.
    My requirement is when they select that I need to display cost per day and cost for currect month.
    Can anybody help me.
    Thnaks and regards
    Anil

  • Helps Needed!!Database on Radio Buttons

    Hi i am currently working on a voting system whereby the data will be stored in ODBC..I am not able to use JRadioButton to store into the database access and I need helps fromwhoever can help mi..will appreciate greatly.thanks..
    My codes are as follows:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.text.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class VoteDialog extends JPanel {
         JButton voteButton;
    JLabel label;
    JFrame frame;
    String simpleDialogDesc = "The candidates";
         DataBase db = new DataBase();
    Connection connection = db.getConnection();
    public VoteDialog(JFrame frame) {
    this.frame = frame;
    JLabel title;
    // Create the components.
    JPanel choicePanel = createSimpleDialogBox();
    System.out.println("passed createSimpleDialogBox");
    title = new JLabel("Click the \"Vote\" button"
    + " once you have selected a candidate.",
    JLabel.CENTER);
    label = new JLabel("Vote now!", JLabel.CENTER);
         label.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    choicePanel.setBorder(BorderFactory.createEmptyBorder(20,20,5,20));
    // Set the layout.
    setLayout(new BorderLayout());
    add(title, BorderLayout.NORTH);
    add(label, BorderLayout.SOUTH);
    add(choicePanel, BorderLayout.CENTER);
    void setLabel(String newText) {
    label.setText(newText);
    private JPanel createSimpleDialogBox() {
    final int numButtons = 5;
    final JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();
    final JButton voteButton;
    final String defaultMessageCommand = "default";
    radioButtons[0] = new JRadioButton("<html>Polythenic 1: <font color=red>Nanyang Poly</font></html>");
    radioButtons[0].setActionCommand(defaultMessageCommand);
    radioButtons[1] = new JRadioButton("<html>Polythenic 2: <font color=green>Singapore Poly</font></html>");
    radioButtons[1].setActionCommand(defaultMessageCommand);
    radioButtons[2] = new JRadioButton("<html>Polythenic 3: <font color=blue>Temasek Poly</font></html>");
    radioButtons[2].setActionCommand(defaultMessageCommand);
    radioButtons[3] = new JRadioButton("<html>Polythenic 4: <font color=maroon>Republic Poly</font></html>");
    radioButtons[3].setActionCommand(defaultMessageCommand);
              radioButtons[4] = new JRadioButton("<html>Polythenic 5: <font color=yellow>Ngee Ann Poly</font></html>");
    radioButtons[4].setActionCommand(defaultMessageCommand);
    for (int i = 0; i < numButtons; i++) {
    group.add(radioButtons);
    // Select the first button by default.
    radioButtons[0].setSelected(true);
    voteButton = new JButton("Vote");
    voteButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
         String command = group.getSelection().getActionCommand();
              String insertString;
                   Statement statement;
                   int p1= Integer.parseInt(radioButtons[0].getText());
                   int p2= Integer.parseInt(radioButtons[1].getText());
                   int p3= Integer.parseInt(radioButtons[2].getText());
                   int p4= Integer.parseInt(radioButtons[3].getText());
                   int p5= Integer.parseInt(radioButtons[4].getText());
                   insertString = "Insert into poly (nyp, sp, tp, rp, np) "+
              " VALUES ( '"+ p1 +"', '"+ p2 +"', '"+ p3 +"', '"+ p4 +"','"+ p5 +"')";
              try{
    statement = connection.createStatement();
    statement.executeUpdate(insertString);
    statement.close();
    catch ( SQLException sqlex ) {
    sqlex.printStackTrace();
    // ok dialog
    if (command == defaultMessageCommand) {
         JOptionPane.showMessageDialog(frame,
    "Your Vote Han Been Counted");
    return;
         System.out.println("calling createPane");
    return createPane(simpleDialogDesc + ":",
    radioButtons,
    voteButton);
    private JPanel createPane(String description,
    JRadioButton[] radioButtons,
    JButton showButton) {
    int numChoices = radioButtons.length;
    JPanel box = new JPanel();
    JLabel label = new JLabel(description);
    box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
    box.add(label);
    for (int i = 0; i < numChoices; i++) {
    box.add(radioButtons[i]);
    JPanel pane = new JPanel();
    pane.setLayout(new BorderLayout());
    pane.add(box, BorderLayout.NORTH);
    pane.add(showButton, BorderLayout.SOUTH);
    System.out.println("returning pane");
    return pane;
    public static void main(String[] args) {
    JFrame frame = new JFrame("VoteDialog");
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1,1));
    contentPane.add(new VoteDialog(frame));
    // Exit when the window is closed.
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);

    I had linked the database using ODBC and it works well..the only problem is that when i click the "vote" button of the selected JRadioButtons..It doesn't add to my access database file.It will have a lot of errors in the command line.But for the compiling and execuation it works fine.
    for my access database..I had created a table called "poly" and I had included all the 5 names of the polythenic inside too with fieldnames=nyp,sp,tp,rp,np and data type all to Number.
    My reason behind this is to allows the database to read in values from the radiobutton and once the user who click the vote button will store as 1 and by clicking the second time it will auto add to 2.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.text.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class VoteDialog extends JPanel {
    JButton voteButton;
    JLabel label;
    JFrame frame;
    String simpleDialogDesc = "The candidates";
    DataBase db = new DataBase();
    Connection connection = db.getConnection();
    public VoteDialog(JFrame frame) {
    this.frame = frame;
    JLabel title;
    // Create the components.
    JPanel choicePanel = createSimpleDialogBox();
    System.out.println("passed createSimpleDialogBox");
    title = new JLabel("Click the \"Vote\" button"
    + " once you have selected a candidate.",
    JLabel.CENTER);
    label = new JLabel("Vote now!", JLabel.CENTER);
    label.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    choicePanel.setBorder(BorderFactory.createEmptyBorder(20,20,5,20));
    // Set the layout.
    setLayout(new BorderLayout());
    add(title, BorderLayout.NORTH);
    add(label, BorderLayout.SOUTH);
    add(choicePanel, BorderLayout.CENTER);
    void setLabel(String newText) {
    label.setText(newText);
    private JPanel createSimpleDialogBox() {
    final int numButtons = 5;
    final JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();
    final JButton voteButton;
    final String defaultMessageCommand = "default";
    radioButtons[0] = new JRadioButton("<html>Polythenic 1: <font color=red>Nanyang Poly</font></html>");
    radioButtons[0].setActionCommand(defaultMessageCommand);
    radioButtons[1] = new JRadioButton("<html>Polythenic 2: <font color=green>Singapore Poly</font></html>");
    radioButtons[1].setActionCommand(defaultMessageCommand);
    radioButtons[2] = new JRadioButton("<html>Polythenic 3: <font color=blue>Temasek Poly</font></html>");
    radioButtons[2].setActionCommand(defaultMessageCommand);
    radioButtons[3] = new JRadioButton("<html>Polythenic 4: <font color=maroon>Republic Poly</font></html>");
    radioButtons[3].setActionCommand(defaultMessageCommand);
    radioButtons[4] = new JRadioButton("<html>Polythenic 5: <font color=yellow>Ngee Ann Poly</font></html>");
    radioButtons[4].setActionCommand(defaultMessageCommand);
    for (int i = 0; i < numButtons; i++) {
    group.add(radioButtons);
    // Select the first button by default.
    radioButtons[0].setSelected(true);
    voteButton = new JButton("Vote");
    voteButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    String command = group.getSelection().getActionCommand();
    String insertString;
    Statement statement;
    int p1= Integer.parseInt(radioButtons[0].getText());
    int p2= Integer.parseInt(radioButtons[1].getText());
    int p3= Integer.parseInt(radioButtons[2].getText());
    int p4= Integer.parseInt(radioButtons[3].getText());
    int p5= Integer.parseInt(radioButtons[4].getText());
    insertString = "Insert into poly (nyp, sp, tp, rp, np) "+
    " VALUES ( '"+ p1 +"', '"+ p2 +"', '"+ p3 +"', '"+ p4 +"','"+ p5 +"')";
    try{
    statement = connection.createStatement();
    statement.executeUpdate(insertString);
    statement.close();
    catch ( SQLException sqlex ) {
    sqlex.printStackTrace();
    // ok dialog
    if (command == defaultMessageCommand) {
    JOptionPane.showMessageDialog(frame,
    "Your Vote Han Been Counted");
    return;
    System.out.println("calling createPane");
    return createPane(simpleDialogDesc + ":",
    radioButtons,
    voteButton);
    private JPanel createPane(String description,
    JRadioButton[] radioButtons,
    JButton showButton) {
    int numChoices = radioButtons.length;
    JPanel box = new JPanel();
    JLabel label = new JLabel(description);
    box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
    box.add(label);
    for (int i = 0; i < numChoices; i++) {
    box.add(radioButtons);
    JPanel pane = new JPanel();
    pane.setLayout(new BorderLayout());
    pane.add(box, BorderLayout.NORTH);
    pane.add(showButton, BorderLayout.SOUTH);
    System.out.println("returning pane");
    return pane;
    public static void main(String[] args) {
    JFrame frame = new JFrame("VoteDialog");
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1,1));
    contentPane.add(new VoteDialog(frame));
    // Exit when the window is closed.
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
    }

  • Some help needed for shopping calculator program

    Hi. I would like to thank you in advance for helping me. At the moment I am pretty much stuck. I don't know how to add the input using 'while loop'. This is what I'm suppose to do:
    Write a program called ShoppingCalculator.java that allows the user to enter the prices of several items they have bought and then tells them the total amount. The user can enter the prices for as many items as they want, until they click Cancel. The program should then output the total amount they spent, in a message dialog box. Use pounds for all the amounts.
    So far I have written:
    import javax.swing.JOptionPane;
    public class ShoppingCalculator
        public static void main(String[] args)
                boolean done = false;
                double amount;
                String input;
                while (!done)
                        input = JOptionPane.showInputDialog("Enter the amount you spent on the next item:");
                        amount = Double.parseDouble (input);
                if (done = true)
                        JOptionPane.showMessageDialog (null, "You spent a total amound of £" + amount  );
    }Sorry if the code doesn't make much sense cause I've been changing the code around so many times that.
    At one point when I was playing around with the code, I manage to make the input dialog loop nicely but when I pressed cancel, the message dialog only output the last input I put in. What I'm really stuck here is I need to know how to add the input when using 'while loop' and is it correct to use the IF Statement on this program. Please give me some advice on how to and I will try to work on it again.

    Ok. I have edit the code and this is what it looks like:
    import javax.swing.JOptionPane;
    public class ShoppingCalculator
        public static void main(String[] args)
                boolean done = false;
                double amount;
                String input;
                double total = 0;
                while (!done)
                        input = JOptionPane.showInputDialog("Enter the amount you spent on the next item:");
                        amount = Double.parseDouble (input);
                            if (input == null)
                                        total = total + amount;
                                        JOptionPane.showMessageDialog (null, "You spent a total amound of " + total  );
    }I created another variable (total) and it even compiled. The only problem I have now is the message dialog wouldn't show at the end. When I press cancel and nothing happen. This is what I get on my output command window:
    Exception in thread "main" java.lang.NullPointerException
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:991)
    at java.lang.Double.parseDouble(Double.java:510)
    at ShoppingCalculator.main(ShoppingCalculator.java:23)
    Java Result: 1
    Anything that isn't right here?

  • Selection screen in Logical Database programming

    In my Executable program,i have used 'GET PERNR' .
    but i don't need the standrd selection screen as such.I want to modify the std selection screen . Instead of allowing user to select the PERNR's , i want to set their PERNR's by default .
    Advance Thanks .
    J

    You have write this in your INITIALIZATION and AT SELECTION-SCREEN OUTPUT events.
    In your INITIALIZATION event, default the PERNR to the PERNR of the employee who is running it.
    In the AT SELECTION-SCREEN OUTPUT, add the code to make it display only as follows.
    LOOP AT SCREEN.
      IF SCREEN-NAME = PERNR.
        SCREEN-INPUT =0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
    Srinivas

  • Help Needed on a java program

    I am very new to java and our teacher has given us a program
    that i am having quite a bit of trouble with. I was wondering if anyone could help me out.
    This is the program which i have bolded.
    {You will write a Java class to play the TicTacToe game. This program will have at least two data members, one for the status of the board and one to keep track of whose turn it is. All data members must be private. You will create a user interface that allows client code to play the game.
    The user interface must include:
    � Boolean xPlay(int num) which allows x to play in the square labeled by num. This function will return true if that play caused the game to end and false otherwise.
    � Boolean oPlay(int num) which allows o to play in the square labeled by num. This function will return true if that play caused the game to end and false otherwise.
    � Boolean isEmpty(int num) will check to see if the square labeled by num is empty.
    � Void display() which displays the current game status to the screen.
    � Char whoWon() which will return X, O, or C depending on the outcome of the game.
    � You must not allow the same player to play twice in a row. Should the client code attempt to, xPlay or oPlay should print an error and do nothing else.
    � Also calling whoWon when the game is not over should produce an error message and return a character other than X, O, or C.
    � Client code for the moment is up to you. Assume you have two human players that can enter the number of the square in which they want to play.
    Verifying user input WILL be done by the client code.}

    This is the program which i have bolded.Hmmm, that doesn't look like any programming language I've ever seen. I guess you have the wrong forum here, because it isn't Java.
    That looks like a natural-language programming language that directly understands a homework assignment. Either that, or you really did just post the assignment. You wouldn't have done that though, right?

  • Help needed with a paint program

    Hi, I am writing a program to work as a paint application. I have all the necessary buttons. One of my buttons needs to be able to add a small image to the painting frame by clicking the mouse onto the screen...for example, to display a picture of a house, I click the house button which then puts my house picture onto the scribble panel wherever I click the mouse. My problem is that I am new to java and I am stuck on how I can do this. I have put all the code on here which I have. If any one knows the code which I can add to make this work I would very much appreciate it as it is driving me insane!
    Many thanks....
    CODE "DrawingTools.java".............................
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.geom.*;
    public class DrawingTools {
    public static void main (String [] args) {
         Toolkit tk = Toolkit.getDefaultToolkit(); // get system dependent information
    Dimension dim = tk.getScreenSize(); // encapsulate width and height of system
    JFrame f = new DrawingToolFrame();
    f.setSize(800, 550);
    f.setTitle("Drawing Tool v1.10");
    f.setIconImage(tk.getImage("Paint.gif"));
    f.setVisible(true);
    f.setResizable(false);
    class DrawingToolFrame extends JFrame implements ActionListener {
    private JCheckBox checkNormal, checkBold, checkDotted, checkSpray;
    // private JRadioButton orBlack, orBlue, orRed, orYellow, orNormal, orBold, orDotted, orSpray;
    private JButton boldButton, dottedButton, sprayButton;
    private JButton blackButton, blueButton, yellowButton, redButton, greenButton, houseButton, tvButton, starButton;
    private ScribblePanel scribblePanel;
    private JButton scribbleButton, undoButton, newButton, quitButton;
    private JMenuItem newItem, quitItem, undoItem, houseItem, tvItem, starItem,/* normalItem,*/ boldItem, dottedItem, sprayItem, blackItem, blueItem, redItem, yellowItem, greenItem;
    public DrawingToolFrame() {
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    Container contentPane = getContentPane();
    JMenuBar menuBar = new JMenuBar();
         setJMenuBar(menuBar);
         JMenu fileMenu = new JMenu("File");
         newItem = new JMenuItem("New");
         newItem.setMnemonic(KeyEvent.VK_N); //add Alt-N to New short-cut
         newItem.addActionListener(this);
         fileMenu.add(newItem);
         quitItem = new JMenuItem("Quit");
         quitItem.setMnemonic(KeyEvent.VK_Q); //add Alt-Q to Quit short-cut
         quitItem.addActionListener(this);
         fileMenu.add(quitItem);
         menuBar.add(fileMenu);
         JMenu editMenu = new JMenu("Edit");
         undoItem = new JMenuItem("Undo");
         undoItem.addActionListener(this);
         editMenu.add(undoItem);
         menuBar.add(editMenu);
         JMenu shapeMenu = new JMenu("Shape");
         houseItem = new JMenuItem("House");
         houseItem.addActionListener(this);
         shapeMenu.add(houseItem);
         tvItem = new JMenuItem("Television");
         tvItem.addActionListener(this);
         shapeMenu.add(tvItem);
         starItem = new JMenuItem("Star");
         starItem.addActionListener(this);
         shapeMenu.add(starItem);
         menuBar.add(shapeMenu);
    JMenu optionMenu = new JMenu("Option");
    JMenu lineMenu = new JMenu("Line");
         optionMenu.add(lineMenu);
              //normalItem = new JMenuItem("Normal");
              //normalItem.addActionListener(this);
              //lineMenu.add(normalItem);
              boldItem = new JMenuItem("Bold");
              boldItem.addActionListener(this);
              lineMenu.add(boldItem);
              dottedItem = new JMenuItem("Dotted");
              dottedItem.addActionListener(this);
         lineMenu.add(dottedItem);
         sprayItem = new JMenuItem("Spray");
         sprayItem.addActionListener(this);
         lineMenu.add(sprayItem);
         JMenu colourMenu = new JMenu("Colour");
         optionMenu.add(colourMenu);
              blackItem = new JMenuItem("Black");
              blackItem.addActionListener(this);
              colourMenu.add(blackItem);
              blueItem = new JMenuItem("Blue");
              blueItem.addActionListener(this);
              colourMenu.add(blueItem);
              redItem = new JMenuItem("Red");
              redItem.addActionListener(this);
         colourMenu.add(redItem);
         yellowItem = new JMenuItem("Yellow");
         yellowItem.addActionListener(this);
         colourMenu.add(yellowItem);
         greenItem = new JMenuItem("Green");
                   greenItem.addActionListener(this);
         colourMenu.add(greenItem);
         menuBar.add(optionMenu);
    JPanel p = new JPanel();
    ImageIcon scribbleIcon = new ImageIcon("Scribble.gif");
    scribbleButton = new JButton("Scribble", scribbleIcon);
    scribbleButton.setMnemonic(KeyEvent.VK_S); //add Alt-S to Undo short-cut
    scribbleButton.setToolTipText("Click this button and you can draw free hand lines.");
    p.add(scribbleButton);
    //scribbleButton = addJButton("Scribble", p);
    p.add(Box.createHorizontalStrut(20));
    ImageIcon undoIcon = new ImageIcon("Undo.gif");
    undoButton = new JButton("Undo", undoIcon);
    undoButton.setMnemonic(KeyEvent.VK_U); //add Alt-U to Undo short-cut
    undoButton.setToolTipText("Undo the last step");
    p.add(undoButton);
    //undoButton.addActionListener(this);
    p.add(Box.createHorizontalStrut(20));
    ImageIcon newIcon = new ImageIcon("New.gif");
    newButton = new JButton("New", newIcon);
    newButton.setMnemonic(KeyEvent.VK_N); //add Alt-N to New short-cut
    newButton.setToolTipText("Make a new Drawing");
    p.add(newButton);
    p.add(Box.createHorizontalStrut(20));
    ImageIcon quitIcon = new ImageIcon("Door.gif"); //add icon to button
    quitButton = new JButton("Quit", quitIcon);
    quitButton.setMnemonic(KeyEvent.VK_Q); //add Alt-Q to exit short-cut
    quitButton.setToolTipText("Click to Exit");
    p.add(quitButton);
    undoButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    scribblePanel.undo();}});
    scribbleButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    scribblePanel.repaint();}});
    newButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    scribblePanel.repaint();}});
    quitButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    System.exit(0);}});
    contentPane.add(p, "South");
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createVerticalStrut(10));
    ImageIcon boldIcon = new ImageIcon("Bold.gif"); //add icon to button
    boldButton = new JButton("Bold", boldIcon);
    p.add(boldButton);
    p.add(Box.createVerticalStrut(10));
    ImageIcon dottedIcon = new ImageIcon("Dotted.gif"); //add icon to button
    dottedButton = new JButton("Dotted", dottedIcon);
    p.add(dottedButton);
    p.add(Box.createVerticalStrut(10));
    ImageIcon sprayIcon = new ImageIcon("Spray.gif"); //add icon to button
    sprayButton = new JButton("Spray", sprayIcon);
    p.add(sprayButton);
    /*     ButtonGroup groupA = new ButtonGroup();
         p.add(Box.createVerticalStrut(20));
         orNormal = addJRadioButton("Normal", true, groupA, p);
         p.add(Box.createVerticalStrut(20));
         orBold = addJRadioButton("Bold", false, groupA, p);
         p.add(Box.createVerticalStrut(20));
         orDotted = addJRadioButton("Dotted", false, groupA, p);
         p.add(Box.createVerticalStrut(20));
         orSpray = addJRadioButton("Spray", false, groupA, p);*/
    contentPane.add(p, "East");
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createVerticalStrut(10));
    ImageIcon dIcon = new ImageIcon("Black.gif"); //add icon to button
    blackButton = new JButton("Black", dIcon);
    p.add(blackButton);
    p.add(Box.createVerticalStrut(10));
    ImageIcon eIcon = new ImageIcon("Blue.gif"); //add icon to button
    blueButton = new JButton("Blue", eIcon);
    p.add(blueButton);
    p.add(Box.createVerticalStrut(10));
    ImageIcon fIcon = new ImageIcon("Red.gif"); //add icon to button
    redButton = new JButton("Red", fIcon);
    p.add(redButton);
    p.add(Box.createVerticalStrut(10));
    ImageIcon gIcon = new ImageIcon("Yellow.gif"); //add icon to button
    yellowButton = new JButton("Yellow", gIcon);
    p.add(yellowButton);
    p.add(Box.createVerticalStrut(10));
    ImageIcon hIcon = new ImageIcon("Green.gif"); //add icon to button
    greenButton = new JButton("Green", hIcon);
    p.add(greenButton);
    p.add(Box.createVerticalStrut(30));
    ImageIcon houseIcon = new ImageIcon("house.gif");
    houseButton = new JButton("House", houseIcon);
    houseButton.setToolTipText("Click to add a house in the picture!");
    p.add(houseButton);
    //houseButton = addJButton("House", p);
    p.add(Box.createVerticalStrut(10));
    ImageIcon tvIcon = new ImageIcon("tv.gif");
    tvButton = new JButton("Television", tvIcon);
    tvButton.setToolTipText("Click to add a Television in the picture!");
    p.add(tvButton);
    //tvButton = addJButton("Television", p);
    p.add(Box.createVerticalStrut(10));
    ImageIcon starIcon = new ImageIcon("star.gif");
    starButton = new JButton("Star", starIcon);
    starButton.setToolTipText("Click to add stars in the picture!");
    p.add(starButton);
    //starButton = addJButton("Star", p);
    contentPane.add(p, "West");
    scribblePanel = new ScribblePanel();
    contentPane.add(scribblePanel, "Center");
    private JButton addJButton(String text, Container container) {
    JButton button = new JButton(text);
    container.add(button);
    return button;
    private JRadioButton addJRadioButton(String text, boolean on, ButtonGroup group, Container container) {
    JRadioButton button = new JRadioButton(text, on);
    group.add(button);
    container.add(button);
    return button;
    public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();
    if (source instanceof JMenuItem) {
    String arg = e.getActionCommand();
    if (arg.equals("Undo"))
    scribblePanel.undo();
    else if (arg.equals("New"))
    scribblePanel.repaint();
    else if (arg.equals("Quit"))
    System.exit(0);
    }

    The code posted just sends any data it receives back to the person who sent it. To get it to work there, you probably should flush after the println. I believe your mother taught you always to flush. It seems you have forgotten.

  • Help needed with a chat program

    Hi everyone! i'm busy with a client/server chat program. I'm really stuck because i can't seem to get the messages from one client to show on the other client's screen.
    If one client sends a message to another client, the server receives the message, but the second client does not receive the message.
    Here is the server code that sends messages to the clients:
    BufferedReader incomeReader = null;
    PrintWriter outWriter = null;
    try {
         incomeReader = new BufferedReader(new InputStreamReader (incomingSocket.getInputStream()));
    outWriter = new PrintWriter(incomingSocket.getOutputStream(),true);
    }catch (Exception e) {
              System.out.println("error handling a client: " + e);
    System.exit(-1);
    line = incomeReader.readLine();
    textArea.append(line + "\n");               
    outWriter.println(line);
    The server is suppose to put the message it receives on the text area on the server screen, and then send the message to all clients connected to it.
    I hope somebody will be able to help me...

    The code posted just sends any data it receives back to the person who sent it. To get it to work there, you probably should flush after the println. I believe your mother taught you always to flush. It seems you have forgotten.

  • Help needed on where install program places UPK Library

    I installed UPK Developer (Version 11.1) on my laptop in order to get familiar with it before an upcoming project. However, I cannot get past the Add Profile dialog box as I don't know where the Install program placed the Library on my computer. Any help would be appreciated. Thanks.

    Do you remember if you installed UPK as a single user or multi-user configuration? The multi-user setup requires the pathname to a library on an external server when you launch UPK. You might want to reinstall UPK and make sure you chose the single user option. I'm not 100% sure, but it sounds like that might be the issue.

  • Help needed on a chat program..............

    Somebody please help me. I can't seem to get my client/server program to work well. The problem is that when a client sends a message to another client, the other client doesn't receive that message. Instead, the server and the client that sent the message are the ones that receive the message.
    Here is the server code that processes the messages:
    BufferedReader incomeReader = null;
    PrintWriter outWriter = null;
    try {
         incomeReader = new BufferedReader(new InputStreamReader(incomingSocket.getInputStream()));
    outWriter = new PrintWriter(incomingSocket.getOutputStream(),true);
    }catch (Exception e) {
              System.out.println("error handling a client: " + e);
    System.exit(-1);
    line = incomeReader.readLine();
    outWriter.println(line);
    outWriter.flush();
    Well, i hope somebody will be able to help....

    incomeReader = new BufferedReader(new InputStreamReader(incomingSocket.getInputStream()));
    outWriter = new PrintWriter(incomingSocket.getOutputStream(),true);Quite what you programmed. "incomingSocket" sends the message and gets it back.

  • Help needed, new to java programming

    hi,
    I have craeted a Frame with some check boxes and button called "button1".
    Can anyone tell me how can i count the number of CHECKED check boxes so that when i press the button1 in my code it should display the result as number of checked check boxes divided by total number of check boxes. It should display the result in a textfield here RESULT textfield in my code
    Thanks in advance ...i am sending the code i have written so far....
    public class Frame extends java.awt.Frame {
        /** Creates new form Frame */
        public Frame() {
            initComponents();
            setSize(600, 600);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {
            buttonGroup1 = new javax.swing.ButtonGroup();
            checkbox1 = new java.awt.Checkbox();
            checkbox2 = new java.awt.Checkbox();
            checkbox3 = new java.awt.Checkbox();
            button1 = new java.awt.Button();
            textField1 = new java.awt.TextField();
            setLayout(null);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            checkbox1.setLabel("checkbox1");
            add(checkbox1);
            checkbox1.setBounds(160, 50, 84, 20);
            checkbox2.setLabel("checkbox2");
            add(checkbox2);
            checkbox2.setBounds(160, 70, 84, 20);
            checkbox3.setLabel("checkbox3");
            add(checkbox3);
            checkbox3.setBounds(160, 90, 84, 20);
            button1.setLabel("button1");
            button1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    button1ActionPerformed(evt);
            add(button1);
            button1.setBounds(150, 180, 57, 24);
            textField1.setText("Result");
            textField1.setName("Result");
            add(textField1);
            textField1.setBounds(260, 180, 44, 20);
            pack();
        private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
            // Add your handling code here:
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            new Frame().show();
        // Variables declaration - do not modify
        private java.awt.Button button1;
        private javax.swing.ButtonGroup buttonGroup1;
        private java.awt.Checkbox checkbox1;
        private java.awt.Checkbox checkbox2;
        private java.awt.Checkbox checkbox3;
        private java.awt.TextField textField1;
        // End of variables declaration
    }

    Two problems in the code you repost-ed:
    1. It lacks import statements.
    2. There is an extraneous } at the end of the button1ActionPerformed method.
    Correct them and it'll work fine. Posting the full source code:
    import java.awt.Component;
    import java.awt.Checkbox;
    public class Frame extends java.awt.Frame
         /** Creates new form Frame */
         public Frame()
              initComponents();
          * This method is called from within the constructor to initialize the form.
          * WARNING: Do NOT modify this code. The content of this method is always
          * regenerated by the Form Editor.
         private void initComponents()
              checkbox1 = new java.awt.Checkbox();
              checkbox2 = new java.awt.Checkbox();
              checkbox3 = new java.awt.Checkbox();
              button1 = new java.awt.Button();
              textField1 = new java.awt.TextField();
              setLayout( null );
              addWindowListener( new java.awt.event.WindowAdapter()
                   public void windowClosing( java.awt.event.WindowEvent evt )
                        exitForm( evt );
              checkbox1.setLabel( "checkbox1" );
              add( checkbox1 );
              checkbox1.setBounds( 120, 40, 84, 20 );
              checkbox2.setLabel( "checkbox2" );
              add( checkbox2 );
              checkbox2.setBounds( 120, 60, 84, 20 );
              checkbox3.setLabel( "checkbox3" );
              add( checkbox3 );
              checkbox3.setBounds( 120, 80, 84, 20 );
              button1.setLabel( "button1" );
              button1.addActionListener( new java.awt.event.ActionListener()
                   public void actionPerformed( java.awt.event.ActionEvent evt )
                        button1ActionPerformed( evt );
              add( button1 );
              button1.setBounds( 50, 170, 57, 24 );
              textField1.setText( "textField1" );
              add( textField1 );
              textField1.setBounds( 240, 170, 60, 20 );
              pack();
         private void button1ActionPerformed( java.awt.event.ActionEvent evt )
              // Add your handling code here:
              Component[] components = getComponents();
              int numOfCheckBoxes = 0;
              int numChecked = 0;
              for ( int i = 0; i < components.length; i++ )
                   if ( components[i] instanceof Checkbox )
                        numOfCheckBoxes++;
                        Checkbox checkBox = (Checkbox) components;
                        if ( checkBox.getState() )
                             numChecked++;
              double ratio = (double) numChecked / (double) numOfCheckBoxes;
              textField1.setText( Double.toString( ratio ) );
         /** Exit the Application */
         private void exitForm( java.awt.event.WindowEvent evt )
              System.exit( 0 );
         * @param args the command line arguments
         public static void main( String args[] )
              new Frame().show();
         // Variables declaration - do not modify
         private java.awt.Button button1;
         private java.awt.Checkbox checkbox1;
         private java.awt.Checkbox checkbox2;
         private java.awt.Checkbox checkbox3;
         private java.awt.TextField textField1;
         // End of variables declaration
    I can see from the code that the GUI was generated by a tool. Since you're new to Java programming, I'd recommend ditching the tool and writing everything by hand, otherwise you're not learning much. It's just like when you're learning proofs in Maths, where you start with first principles before making use of the proofs on their own.
    Also, it'll help tremendously if you could spend some time going through the Java Tutorial (http://java.sun.com/docs/books/tutorial/). It's free, and I find it very useful.
    Hth.

  • Help needed to trace a program ...

    Hi,
    I am trying to reach the program which actually generates the PO from ME21N/ME22N. Could you please help me trace or let me know the program name ??
    Once PO is created and if I have the print option set in the "Messages", the PO is printed to the printer. I want to trace after the point, the PO is saved in the table. i.e. from the time PO output is assembled for printing. also i want to know if its in .txt format ??
    thanks

    Hi Rad Sha,
    your program should be run in background, if you want to look that, you have to activate the background debuging.
    To do that, start a ME22N/ME21N, put /hs (in the field for the transaction). Save your PO, that will go in debuging. Use the button Setting, select the background debugging and press save.
    After this you could press the key F8.
    You will have a new window that will appear, in debug mode. This window correspond of the background.
    Rgd
    Frédéric

Maybe you are looking for

  • P55 GD80 and i5 650

    hey everyone .... I just picked on this system board (P55 GD80 and i5 650) off eBay,  after set up on the system, I when to install windows 7 at first it did not see my USB key (used to install windows 7) due to the fact I don't have a CD-ROM. After

  • Downloading never ends??

    I bought a movie from itunes earlier today but as soon as it finishes downloading, it starts all over again. When I connect my ipod to the computer, nothing happens. I bought my video ipod yesterday in order to watch videos but it's not working, and

  • Compressing large files

    How do I compress a large file 25mb to send via email. I have stuffit, but no clue how to use it! Rose

  • Landline Not Working, Can't report fault.

    Got up this morning and had to make an important phonecall only to find we had no dial tone, our broadband was also off but that problem seems to have been fixed. Our landline on the other hand hasn't and i can't report the fault as we have to do a l

  • How do I control the volume so all my songs are the same loudness

    On my older IPOD, one song plays soft, then the next is too loud.  How can I control the volume so they are all the same loudness?