Authority Check in Class Interface CMD_EI_API

I am using the class CMD_EL_API in order to create new customer.
The class is working very well, but there is a problem.
Not all the users that are going to utilize this aplicacion can have access to XD01 and XD02 and the class check the authorization on these transactions. 
Error:
         You are not authorized to use Transaction  XD01.
Already it was given them access to all the objects of the XD01 and XD02 but continues marking the same error. 
It wold be able someone to indicate me that can be done.
Thank you
Blanca Segovia

Hi
This is a small program to start with this method. I hope you serve
report  zcreate_cliente.
data: wa_company_code_st type cmds_ei_company,
wa_company_code type cmds_ei_cmd_company,
wa_customer type cmds_ei_extern,
wa_customers type cmds_ei_main,
wa_address type bapiad1vl,
wa_addressx type bapiad1vlx,
wa_central_data type cmds_ei_vmd_central_data,
wa_central_datax type cmds_ei_vmd_central_data_xflag,
wa_error type cvis_message.
constants c_update type c value 'M'.
start-of-selection.
  free: wa_customer, wa_company_code_st, wa_customer.
  wa_company_code_st-task = c_update.
  wa_company_code_st-data_key-bukrs = 'A105'.
  wa_address-name = 'Nombre Cliente'.
  wa_address-country = 'MX'.
  wa_address-langu = 'E'.
  wa_address-time_zone = 'UTC-6'.
  wa_customer-central_data-address-postal-data = wa_address.
  wa_customer-central_data-address-postal-datax = wa_addressx.
  wa_customer-central_data-central-data-ktokd = '0200'.
  wa_customer-central_data-central-datax-ktokd = 'X'.
  append wa_company_code_st to wa_company_code-company.
  wa_customer-header-object_instance-kunnr = '0300002832'.
  wa_customer-header-object_task = c_update.
  wa_customer-company_data = wa_company_code.
  append wa_customer to wa_customers-customers.
  call method cmd_ei_api=>maintain_bapi
  exporting
  is_master_data = wa_customers
  importing
   es_message_correct = wa_error.
  if wa_error-is_error is initial.
    commit work.
  endif.
Regards,
Blanca Segovia

Similar Messages

  • Authority check at field level in sales order

    Dear all, our business requirement is the following:
    only some users should be able to see the prices (including netwr, netpr,...) in the sales order depending on the authority check performed on the sales group field.
    This means that for an order of sales group 'A':
    a user of sales group 'A' can see the prices and change the order, a user of sales group 'B' cannnot see the prices but can change the order, a user of sales group 'C' can display the order but cannnot see the prices.
    I ask you if such a scenario can be realized in SAP.
    We currently run SAP ECC 5.0.
    thx all !
    bye Roberto

    Hi agree with Jan and Auke,
    To my knowledge it is object V_KONH_VKO which you are looking for. See the documentation in SU24 - SD class.
    But whether or not that will influence the visibility / editability of the screen in VA02 etc when turned the check on in SU24, I am not sure.
    If not, search the forum for topics relating to "transaction variants", "variant transactions" and "screen variants" to see whether those solutions will fulfill the requirement.
    Cheers,
    Julius

  • ALV GRID and AUTHORITY-CHECK

    Hi all !!! 
    I'm using the ALV Grid control with checkboxes and I want to control if the actual user have the appropriate authorization to check/uncheck them.
    In the AUTHORITY-CHECK call, I want to make the authorization test on the "DEPARTMENT" of the user (from Table USER_ADDR or SU01).
    For example :
    DEPARTMENT AA1 --> check/uncheck OK
    DEPARTMENT AA2 --> check/uncheck NOT OK
    DEPARTMENT AA3 --> check/uncheck OK
    ... etc.
    How can I do ? Create an new authorization object/field ?
    PS : it's the first time I'm using AUTHORITY-CHECK..

    Much of the data in an R/3 system has to be protected so that unauthorized users cannot access it. Therefore the appropriate authorization is required before a user can carry out certain actions in the system. When you log on to the R/3 system, the system checks in the user master record to see which transactions you are authorized to use. An authorization check is implemented for every sensitive transaction.
    If you wish to protect a transaction that you have programmed yourself, then you must implement an authorization check. 
    This means you have to allocate an authorization object in the definition of the transaction.
    For example:
    program an AUTHORITY-CHECK.
    AUTHORITY-CHECK OBJECT <authorization object> 
       ID <authority field 1> FIELD <field value 1>. 
       ID <authority field 2> FIELD <field value 2>. 
       ID <authority-field n> FIELD <field value n>. 
    The OBJECT parameter specifies the authorization object.
    The ID parameter specifies an authorization field (in the authorization object).
    The FIELD parameter specifies a value for the authorization field.
    The authorization object and its fields have to be suitable for the transaction. In most cases you will be able to use the existing authorization objects to protect your data. But new developments may require that you define new authorization objects and fields.
    Example ;
    REPORT  EXAMPLE MESSAGE-ID Z1.
    TABLES: USR02.
    PARAMETERS: LOCK AS CHECKBOX, LISTLOCK AS CHECKBOX.
    DATA: UFLAGVAL TYPE I, LOCKSTRING(8) TYPE C.
    ---- Authorization check -
    AUTHORITY-CHECK OBJECT 'ZPROG_RUN' ID 'PROGRAM' FIELD SY-CPROG.
    IF SY-SUBRC <> 0.
      IF SY-SUBRC = 4.
        MESSAGE E000 WITH SY-CPROG. "some message about authorization check failure
      ELSE.
        MESSAGE E005 WITH SY-SUBRC. "some message about authorization check failure
      ENDIF.
    ENDIF.
    IF LISTLOCK = 'X'.
      WRITE:/ 'List all locked users: '.
      SELECT * FROM USR02 WHERE UFLAG = 64.
        WRITE: / USR02-BNAME.
      ENDSELECT.
      EXIT.
    ENDIF.
    IF LOCK = 'X'.
      UFLAGVAL = 64.                       "lock all users
      LOCKSTRING = 'locked'.
    ELSE.
      UFLAGVAL = 0.                        "unlock all users
      LOCKSTRING = 'unlocked'.
    ENDIF.
    SELECT * FROM USR02 WHERE BNAME <> 'SAP*' AND BNAME <> SY-UNAME.
      IF USR02-UFLAG <> 0 AND USR02-UFLAG <> 64.
        WRITE: 'User', USR02-BNAME, 'untouched; please handle manually.'.
        CONTINUE.
      ENDIF.
    check that user has authority to make these changes
      AUTHORITY-CHECK OBJECT 'S_USER_GRP'
          ID 'CLASS' FIELD USR02-CLASS
          ID 'ACTVT' FIELD '05'.
      IF SY-SUBRC <> 0.
        IF SY-SUBRC = 4.
          WRITE: /'You are not authorized to lock/unlock user ',
            USR02-BNAME, USR02-CLASS.
        ELSE.
          WRITE: /'Authorization error checking user ',
                 USR02-BNAME, USR02-CLASS, '(return code', SY-SUBRC, ').'.
        ENDIF.
      ELSE.                                "has authority
        UPDATE USR02 SET UFLAG = UFLAGVAL WHERE BNAME = USR02-BNAME.
        WRITE: / 'User', USR02-BNAME, LOCKSTRING, '.'.
      ENDIF.

  • Help! Class, interface, or enum expected, don't know where the error is

    hey all, I am doing a project for school but I keep getting a compiler error and I don't know why. Here is the code that keeps getting the error:
    import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
    import java.util.*;
    * Green Survivor
    * @author
    * @version
    public class Green extends Survivor
    * Constructor that simply calls Survivor's no-argument constructor.
    public Green()
    super();
    * Does whatever a Survivor does
    public void act()
    getNextMove();
    updateLife();
    * Update a Survivor's life based on its neighbors.
    public void updateLife()
    //Get a list of all neighbors that are in a square directly next
    //to us that are of type Survivor. Traverse the list. For every
    //neighbor of type Green, add one to life. For any other Survivor,
    //subtract two from life.
    ArrayList<Object> update = new ArrayList<Object>();
    update.add(getOneObjectAtOffset(1, 0, Survivor.class));
    update.add(getOneObjectAtOffset(-1, 0, Survivor.class));
    update.add(getOneObjectAtOffset(1, 1, Survivor.class));
    update.add(getOneObjectAtOffset(0, 1, Survivor.class));
    update.add(getOneObjectAtOffset(0, -1, Survivor.class));
    update.add(getOneObjectAtOffset(-1, -1, Survivor.class));
    update.add(getOneObjectAtOffset(1, -1, Survivor.class));
    update.add(getOneObjectAtOffset(-1, 1, Survivor.class));
    for(int i = 0; i < update.size(); i++)
    if(update.get(i) == Green.class)
    changeLife(1);
    else
    changeLife(-2);
    //If green is outnumbered by blue by more than 500, subtract 5 from life.
    if(green + 500 < blue)
    changeLife(-5);
    //If green is outnumbered by red by more than 500, subtract 5 from life.
    if(green + 500 < red)
    changeLife(-5);
    * Put a new object of type Green into the world at coordinates x and y.
    * Then increment green's static counter accordingly.
    public void createNew(int x, int y)
    int one = x;
    int two = y;
    new Green();
    setLocation(one, two);
    green = green + 1;
    * Green pieces should just choose an available move at random. If there
    * are no available moves, return -1.
    public int getNextMove()
    if(canMove(1) || canMove(2) || canMove(3) || canMove(0))
    int counter = (int) (Math.random() * 4);
    if(canMove(counter))
    move(counter);
    else
    counter = (int) (Math.random() * 4);
    if(canMove(counter))
    move(counter);
    else
    counter = (int) (Math.random() * 4);
    if(canMove(counter))
    move(counter);
    else
    counter = (int) (Math.random() * 4);
    if(canMove(counter))
    move(counter);
    else
    return -1;
    It is the subclass of a class that has all the methods used here (it wouldn't allow me to add that too as it said it was too many characters, I will post it if need be)
    Thanks in advance!

    [http://www.greenfoot.org/|http://www.greenfoot.org/]
    It's what we are supposed to use for class.
    I've tried to get a more complete error message because then maybe I could figure out whats wrong but that's all that comes up. and it highlights the last bracket. At first I thought it meant the brackets were off but I've triple checked that and I added an extra one in to try that out too and it changed nothing. I've even tried removing certain chunks of code to see if I could isolate the problem and the same error came up no matter what I did.
    add- using the compiler in greenfoot.
    Edited by: lysistokill on Jun 1, 2010 5:47 PM

  • Class, interface, or enum expected?

    Ok I keep getting that error. Here is my java file that it is in.
    package server.main.project12.skills;
    import java.io.*;
    import server.main.project12.*;
    public class fireMaking {
    public int xpgained = 1;//Change this and the fire xp will be times by that, so 40 time 1 = 40, 40
    times 100 = 4000.
        public void WalkTo(int x, int y) { 
            newWalkCmdSteps = (Math.abs((x+y)));
            if(newWalkCmdSteps % 1 != 0)
                newWalkCmdSteps /= 1;
            if(++newWalkCmdSteps > walkingQueueSize) {
                println("Warning: WalkTo("+packetType+") command contains too many steps
    ("+newWalkCmdSteps+").");
                newWalkCmdSteps = 0;
            int firstStepX = absX;
            int tmpFSX = firstStepX;
            firstStepX -= mapRegionX*8;
            for(i = 1; i < newWalkCmdSteps; i++) {
                newWalkCmdX[i] = x;
                newWalkCmdY[i] = y;
                tmpNWCX[i] = newWalkCmdX;
    tmpNWCY[i] = newWalkCmdY[i];
    newWalkCmdX[0] = newWalkCmdY[0] = tmpNWCX[0] = tmpNWCY[0] = 0;
    int firstStepY = absY;
    int tmpFSY = firstStepY;
    firstStepY -= mapRegionY*8;
    newWalkCmdIsRunning = ((inStream.readSignedByteC() == 1) && playerEnergy > 0);
    for(i = 0; i < newWalkCmdSteps; i++) {
    newWalkCmdX[i] += firstStepX;
    newWalkCmdY[i] += firstStepY;
    public int firetimer = 0;
    public int firetimers = 0;
    public int firetimers1 = 0;
    public int firetimers2 = 0;
    public int firetimers3 = 0;
    public int firetimers4 = 0;
    public int firetimers5 = 0;
    public int firetimers6 = 0;
    public int firetimers7 = 0;
    public int firetimers8 = 0;
    public int firetimers9 = 0;
    public int firetimers10 = 0;
    public int firetimers11 = 0;
    public int firetimers12 = 0;
    public int firetimers13 = 0;
    public int firetimers14 = 0;
    public int firetimers15 = 0;
    public int firetimers16 = 0;
    public int firetimers17 = 0;
    public int firetimers18 = 0;
    public int firetimers19 = 0;
    public int previousX = 0;
    public int previousY = 0;
    public int previousX1 = 0;
    public int previousY1 = 0;
    public int previousX2 = 0;
    public int previousY2 = 0;
    public int previousX3 = 0;
    public int previousY3 = 0;
    public int previousX4 = 0;
    public int previousY4 = 0;
    public int previousX5 = 0;
    public int previousY5 = 0;
    public int previousX6 = 0;
    public int previousY6 = 0;
    public int previousX7 = 0;
    public int previousY7 = 0;
    public int previousX8 = 0;
    public int previousY8 = 0;
    public int previousX9 = 0;
    public int previousY9 = 0;
    public int previousX10 = 0;
    public int previousY10 = 0;
    public int previousX11 = 0;
    public int previousY11 = 0;
    public int previousX12 = 0;
    public int previousY12 = 0;
    public int previousX13 = 0;
    public int previousY13 = 0;
    public int previousX14 = 0;
    public int previousY14 = 0;
    public int previousX15 = 0;
    public int previousY15 = 0;
    public int previousX16 = 0;
    public int previousY16 = 0;
    public int previousX17 = 0;
    public int previousY17 = 0;
    public int previousX18 = 0;
    public int previousY18 = 0;
    public int previousX19 = 0;
    public int previousY19 = 0;
    public int logID = 0;
    public boolean process() {
    //FIRE MAKING TIMERS
    if(firetimer > 0)
    firetimer -= 1;
    if(firetimers > 0)
    firetimers -= 1;
    if(firetimers1 > 0)
    firetimers1 -= 1;
    if(firetimers3 > 0)
    firetimers3 -= 1;
    if(firetimers2 > 0)
    firetimers2 -= 1;
    if(firetimers4 > 0)
    firetimers4 -= 1;
    if(firetimers5 > 0)
    firetimers5 -= 1;
    if(firetimers6 > 0)
    firetimers6 -= 1;
    if(firetimers7 > 0)
    firetimers7 -= 1;
    if(firetimers8 > 0)
    firetimers8 -= 1;
    if(firetimers9 > 0)
    firetimers9 -= 1;
    if(firetimers10 > 0)
    firetimers10 -= 1;
    if(firetimers11 > 0)
    firetimers11 -= 1;
    if(firetimers13 > 0)
    firetimers13 -= 1;
    if(firetimers12 > 0)
    firetimers12 -= 1;
    if(firetimers14 > 0)
    firetimers14 -= 1;
    if(firetimers15 > 0)
    firetimers15 -= 1;
    if(firetimers16 > 0)
    firetimers16 -= 1;
    if(firetimers17 > 0)
    firetimers17 -= 1;
    if(firetimers18 > 0)
    firetimers18 -= 1;
    if(firetimers19 > 0)
    firetimers19 -= 1;
    if(firetimers == 1)
    ItemHandler.addItem(592, previousX, previousY, 1, playerId, false);
    ReplaceObject2(previousX, previousY, 6951, 0, 10);
    previousX = 0;
    previousY = 0;
    if(firetimers1 == 1)
    ItemHandler.addItem(592, previousX1, previousY1, 1, playerId, false);
    ReplaceObject2(previousX1, previousY1, 6951, 0, 10);
    previousX1 = 0;
    previousY1 = 0;
    if(firetimers2 == 1)
    ItemHandler.addItem(592, previousX2, previousY1, 1, playerId, false);
    ReplaceObject2(previousX2, previousY2, 6951, 0, 10);
    previousX2 = 0;
    previousY2 = 0;
    if(firetimers3 == 1)
    ItemHandler.addItem(592, previousX3, previousY3, 1, playerId, false);
    ReplaceObject2(previousX3, previousY3, 6951, 0, 10);
    previousX3 = 0;
    previousY3 = 0;
    if(firetimers4 == 1)
    ItemHandler.addItem(592, previousX4, previousY4, 1, playerId, false);
    ReplaceObject2(previousX4, previousY4, 6951, 0, 10);
    previousX4 = 0;
    previousY4 = 0;
    if(firetimers5 == 1)
    ItemHandler.addItem(592, previousX5, previousY5, 1, playerId, false);
    ReplaceObject2(previousX5, previousY5, 6951, 0, 10);
    previousX5 = 0;
    previousY5 = 0;
    if(firetimers9 == 1)
    ItemHandler.addItem(592, previousX9, previousY9, 1, playerId, false);
    ReplaceObject2(previousX9, previousY9, 6951, 0, 10);
    previousX9 = 0;
    previousY9 = 0;
    if(firetimers8 == 1)
    ItemHandler.addItem(592, previousX8, previousY8, 1, playerId, false);
    ReplaceObject2(previousX8, previousY8, 6951, 0, 10);
    previousX8 = 0;
    previousY8 = 0;
    if(firetimers7 == 1)
    ItemHandler.addItem(592, previousX7, previousY7, 1, playerId, false);
    ReplaceObject2(previousX7, previousY7, 6951, 0, 10);
    previousX7 = 0;
    previousY7 = 0;
    if(firetimers6 == 1)
    ItemHandler.addItem(592, previousX6, previousY6, 1, playerId, false);
    ReplaceObject2(previousX6, previousY6, 6951, 0, 10);
    previousX6 = 0;
    previousY6 = 0;
    if(firetimers10== 1)
    ItemHandler.addItem(592, previousX10, previousY10, 1, playerId, false);
    ReplaceObject2(previousX10, previousY10, 6951, 0, 10);
    previousX10 = 0;
    previousY10 = 0;
    if(firetimers11 == 1)
    ItemHandler.addItem(592, previousX11, previousY11, 1, playerId, false);
    ReplaceObject2(previousX11, previousY11, 6951, 0, 10);
    previousX11 = 0;
    previousY11 = 0;
    if(firetimers12 == 1)
    ItemHandler.addItem(592, previousX12, previousY12, 1, playerId, false);
    ReplaceObject2(previousX12, previousY12, 6951, 0, 10);
    previousX12 = 0;
    previousY12 = 0;
    if(firetimers13 == 1)
    ItemHandler.addItem(592, previousX13, previousY13, 1, playerId, false);
    ReplaceObject2(previousX13, previousY13, 6951, 0, 10);
    previousX13 = 0;
    previousY13 = 0;
    if(firetimers14 == 1)
    ItemHandler.addItem(592, previousX14, previousY14, 1, playerId, false);
    ReplaceObject2(previousX14, previousY14, 6951, 0, 10);
    previousX14 = 0;
    previousY14 = 0;
    if(firetimers15 == 1)
    ItemHandler.addItem(592, previousX15, previousY15, 1, playerId, false);
    ReplaceObject2(previousX15, previousY15, 6951, 0, 10);
    previousX15 = 0;
    previousY15 = 0;
    if(firetimers19 == 1)
    ItemHandler.addItem(592, previousX19, previousY19, 1, playerId, false);
    ReplaceObject2(previousX19, previousY19, 6951, 0, 10);
    previousX19 = 0;
    previousY19 = 0;
    if(firetimers18 == 1)
    ItemHandler.addItem(592, previousX18, previousY18, 1, playerId, false);
    ReplaceObject2(previousX18, previousY18, 6951, 0, 10);
    previousX18 = 0;
    previousY18 = 0;
    if(firetimers17 == 1)
    ItemHandler.addItem(592, previousX17, previousY17, 1, playerId, false);
    ReplaceObject2(previousX17, previousY17, 6951, 0, 10);
    previousX17 = 0;
    previousY17 = 0;
    if(firetimers16 == 1)
    ItemHandler.addItem(592, previousX16, previousY16, 1, playerId, false);
    ReplaceObject2(previousX16, previousY16, 6951, 0, 10);
    previousX16 = 0;
    previousY16 = 0;
    if(firetimer == 1)
    if(logID == 1)
    addSkillXP((40*xpgained), 11);
    removeGroundItem(absX, absY, 1511);
    logID = 0;
    if(logID == 2)
    addSkillXP((60*xpgained), 11);
    removeGroundItem(absX, absY, 1521);
    logID = 0;
    if(logID == 3)
    addSkillXP((90*xpgained), 11);
    removeGroundItem(absX, absY, 1519);
    logID = 0;
    if(logID == 4)
    addSkillXP((135*xpgained), 11);
    removeGroundItem(absX, absY, 1517);
    logID = 0;
    if(logID == 5)
    addSkillXP((202*xpgained), 11);
    removeGroundItem(absX, absY, 1515);
    logID = 0;
    if(logID == 6)
    addSkillXP((303*xpgained), 11);
    removeGroundItem(absX, absY, 1513);
    logID = 0;
    WalkTo(-1, 0);
    sendMessage("The fire catches, and the logs begin to burn.");
    Object(absX, absY, 2732, 0, 10);
    firetimer = 0;
    updateRequired = true;
    appearanceUpdateRequired = true;
    if(previousX == 0 && previousY == 0)
    previousX = absX;
    previousY = absY;
    firetimers = 60; //DO NOT CHANGE THIS
    viewTo(previousX, previousY);
    else
    if(previousX1 == 0 && previousY1 == 0)
    previousX1 = absX;
    previousY1 = absY;
    firetimers1 = 60;
    viewTo(previousX1, previousY1);
    else
    if(previousX2 == 0 && previousY2 == 0)
    previousX2 = absX;
    previousY2 = absY;
    firetimers2 = 60;
    viewTo(previousX2, previousY2);
    else
    if(previousX3 == 0 && previousY3 == 0)
    previousX3 = absX;
    previousY3 = absY;
    firetimers3 = 60;
    viewTo(previousX3, previousY3);
    else
    if(previousX4 == 0 && previousY4 == 0)
    previousX4 = absX;
    previousY4 = absY;
    firetimers4 = 60;
    viewTo(previousX4, previousY4);
    else
    if(previousX5 == 0 && previousY5 == 0)
    previousX5 = absX;
    previousY5 = absY;
    firetimers5 = 60;
    viewTo(previousX5, previousY5);
    else
    if(previousX6 == 0 && previousY6 == 0)
    previousX6 = absX;
    previousY6 = absY;
    firetimers6 = 60;
    viewTo(previousX6, previousY6);
    else
    if(previousX7 == 0 && previousY7 == 0)
    previousX7 = absX;
    previousY7 = absY;
    firetimers7 = 60;
    viewTo(previousX7, previousY7);
    else
    if(previousX8 == 0 && previousY8 == 0)
    previousX8 = absX;
    previousY8 = absY;
    firetimers8 = 60;
    viewTo(previousX8, previousY8);
    else
    if(previousX9 == 0 && previousY9 == 0)
    previousX9 = absX;
    previousY9 = absY;
    firetimers9 = 60;
    viewTo(previousX9, previousY9);
    else
    if(previousX10 == 0 && previousY10 == 0)
    previousX10 = absX;
    previousY10 = absY;
    firetimers10 = 60;
    viewTo(previousX10, previousY10);
    else
    if(previousX11 == 0 && previousY11 == 0)
    previousX11 = absX;
    previousY11 = absY;
    firetimers11 = 60;
    viewTo(previousX11, previousY11);
    else
    if(previousX12 == 0 && previousY12 == 0)
    previousX12 = absX;
    previousY12 = absY;
    firetimers12 = 60;
    viewTo(previousX12, previousY12);
    else
    if(previousX13 == 0 && previousY13 == 0)
    previousX13 = absX;
    previousY13 = absY;
    firetimers13 = 60;
    viewTo(previousX13, previousY13);
    else
    if(previousX14 == 0 && previousY14 == 0)
    previousX14 = absX;
    previousY14 = absY;
    firetimers14 = 60;
    viewTo(previousX14, previousY14);
    else
    if(previousX15 == 0 && previousY15 == 0)
    previousX15 = absX;
    previousY15 = absY;
    firetimers15 = 60;
    viewTo(previousX15, previousY15);
    else
    if(previousX16 == 0 && previousY16 == 0)
    previousX16 = absX;
    previousY16 = absY;
    firetimers16 = 60;
    viewTo(previousX16, previousY16);
    else
    if(previousX17 == 0 && previousY17 == 0)
    previousX17 = absX;
    previousY17 = absY;
    firetimers17 = 60;
    viewTo(previousX17, previousY17);
    else
    if(previousX18 == 0 && previousY18 == 0)
    previousX18 = absX;
    previousY18 = absY;
    firetimers18 = 60;
    viewTo(previousX18, previousY18);
    else
    if(previousX19 == 0 && previousY19 == 0)
    previousX19 = absX;
    previousY19 = absY;
    firetimers19 = 60;
    viewTo(previousX19, previousY19);
    }And this is what my compiler is showing.C:\Users\Matthew\Documents\server.main.project12>javac *.java
    Note: stream.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    C:\Users\Matthew\Documents\server.main.project12>javac ./skills/*.java
    .\skills\firemaking.java:594: class, interface, or enum expected
    ^
    1 error
    C:\Users\Matthew\Documents\server.main.project12>pause
    Press any key to continue . . .I really need help with this.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    This error is often caused by improper matching of braces { }.
    Solution: Check the matching opening and closing braces.
    Worse, the error could be totally invisible! Often, it is the first thing in the file, before package or import declarations
    In that situation, it could be caused by a code edited / formatted using a text editor not designed for programming such as Word, which introduces invisible characters in the code.
    Solution : In that case, cut and paste the code in a true code editor as Eclipse or NotePad which withdrawing the offending characters.
    This error occurs most often in the console (command line), almost never in an IDE.

  • PNP authority check

    Hi all,
    I have a problem with authority check in a report.
    I have to access to a field in an infotype and subtype.
    I have all authorizations for this subtype and infotype.
    I'm trying to retrieve this data from an employee, but this employee has informed another subtype in this infotype where I haven't permisions.
    As in the source code there aren't access to this subtype where I haven't permisions, I found that the systems make it's authority check before the START-OF-SELECTION in class CL_HRPAD00AUTH_CHECK_STD, method IF_EX_HRPAD00AUTH_CHECK~CHECK_AUTHORIZATION.
    The system takes the employee number, gets all its informed infotypes and subtypes and perform the authority check for my user, so I can't access to this employee information.
    I think this authority check is made by the use of PNP logical database.
    Is there any way to avoid this authority check?
    Regards,
    Angel Cepa

    Hi Angel Cepa,
    first of all: maybe you can use logical database PNPCE, because PNP is obsolet.
    Anyway, please refer to the documentation of PNPCE (transaction SE36), that may solve your problem.
    PNP/PNPCE knows two ways to check authority:
    1. If no authorization exists for even one individual data record of one of the infotypes used, processing of the personnel numbers is terminated by default (switch "PNP_SW_SKIP_PERNR" = Y)
    2. If you set this switch (at the INITIALIZATION or START-OF-SELECTION events) to N, no more personnel numbers (without authorization) are skipped. Only the data records for which no authorization exists are rejected (that is, not made available).
    So, simply set the switch, mentioned above, to "N" and you will have access to this employee (except the infotype-records, you don't have authority for).
    Regards
    CHRIS

  • AUTHORITY-CHECK for KUNNR

    Hi,
    I am new in core abap. For my report i have to do AUTHORITY-CHECK for kunnr. I am not finding any suitable object to use. kIndly suggest.
    Currently i am using the following code.
      UNPACK p_kunnr TO ws_werks.
      AUTHORITY-CHECK OBJECT 'M_MSEG_WWE'
               ID 'ACTVT' FIELD '01'
               ID 'WERKS' FIELD ws_werks.
    But this is giving dump in case KUNNR contains some alphabets because of type mismatch. Kindly suggest how can i achieve the same.
    Regards,
    Pankaj Aggarwal

    Don't use a WERKS authorization for KUNNR, did you foresee the problems that may will arise when you will manage the user authorisations and roles, this authorization is checked in many standard programs on WERKS fields.
    - SU20 - Create an authorization field with data element KUNNR and check table KNA1 (or use template KNDNR, look via SE16 at table AUTHX look for authorization fields using KNA1 as a control table)
    - SU21 - Create an authorization object in a Z-customer class which use this field and the ACTVT field (template W_AUFT_RMB)
    - Use the new object in your program
    - Give the object name to those who manage roles via PFCG
    Perform some search on subject like [Creating a Customer-Specific Authorization Object|http://help.sap.com/saphelp_ish471/helpdata/EN/9e/74ba3bd14a6a6ae10000000a114084/frameset.htm]
    Look also at some authorization objects like BRGRU which were intended to manage groups of customers.
    Regards,
    Raymond

  • Custom Authority Check across system

    Hi all
    I have got an authority check requirement I need help with. I have to restrict certain users --which have a specified role- to not be able to access certain profit/cost centers in any reporting activity.
    When these users run any report transaction, example" FBL3N; they do not see the profit/cost center line items (documents) which are not assigned to them.
    Anyone have a solution for this?
    Some thoughts i have;
    1) Create an authorization field and assign a check table with the values i wish to be shown. Create an authority check statement in an enhancement on EVERY tcode.
    2) Create the authorization object and assign to the user role.
    Looking forward for a reply.
    Points will be rewarded.
    Thanks

    Well did some working on it.  Created an authorization class,object and assigned it the PRCTR field.
    Then we assigned it at the organizational level- prctr from 201 to 201-
    Then we tried FB03, document list and then tried to view documents. Unfortunately it still shows all documents regardless of the profit center being other then 201.
    Am I missing something here?

  • WebDynpro Method from a Class Interface?

    Is possible to call a webdynpro method from a class interface that is register in the WDDOINIT of the same WEBDYNPRO component?
    I register my custom webdynpro screen into FPM_OIF_COMPONENT, now when I execute a FPM action my WebDynpro receives the action but ofcourse WDDOINIT doesn't get triggered again. I need to call my webdynpro code in the class interface so I can update my custom screen.
    SAP does that in their standard screen, Can I do that?
    Jason PV

    As Matt pointed out, your questions indicate that you should start from the basics, then as your knowledge enlarges, go and familarize with more advanced concepts of ABAP Objects. Once you feel a bit comfortable with that, go for BADIs and read a bit about that too.
    In my opinion the best start is to read some book, which covers most of ABAP OO concepts. Personally I would recommend [ABAP Objects: ABAP Programming in SAP NetWeaver|http://www.sap-press.com/product.cfm?account=&product=H1934] as I like this author and had his previous book. This would give you strong foundations of what is going on here. Eventually you will often want to refresh some concepts so you have everything you need in one spot (book).
    Of course if want to save some money, simply look for articles/blogs/wikis in SDN or search in Google. There are plenty of these.
    For start I suggest these series of videoblogs [Basic ABAP OO eLearnings|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3414800)ID1160600550DB10016261778120999663End?blog=/pub/wlg/15408]
    This will give you rough idea how the OO design should be done.
    Regards
    Marcin

  • Abstract Class & Interface

    Hi ,
    I have a fundamental doubt regarding Abstract Class & Interface!!!
    What is their real benefit...whether we implement an interface or extend an Abstract class we have to write the code for the abstract method in the concrete class.Then where the benefit remained....
    And it is said that Abstract class provide default behaviour...what is the actual meaning of that?
    Thanks & Regards
    Santosh

    In this section we will redesign our OneRowNim game to fit within a hierarchy of classes of two-player games. There are many games that characteristically involve two players: checkers, chess, tic-tac-toe, guessing games, and so forth. However, there are also many games that involve just one player: blackjack, solitaire, and others. There are also games that involve two or more players, such as many card games. Thus, our redesign of OneRowNim as part of a two-player game hierarchy will not be our last effort to design a hierarchy of game-playing classes. We will certainly redesign things as we learn new Java language constructs and as we try to extend our game library to other kinds of games.
    This case study will illustrate how we can apply inheritance and polymorphism, as well as other object-oriented design principles. The justification for revising OneRowNim at this point is to make it easier to design and develop other two-player games. As we have seen, one characteristic of class hierarchies is that more general attributes and methods are defined in top-level classes. As one proceeds down the hierarchy, the methods and attributes become more specialized. Creating a subclass is a matter of specializing a given class.
    8.6.1. Design Goals
    One of our design goals is to revise the OneRowNim game so that it fits into a hierarchy of two-player games. One way to do this is to generalize the OneRowNim game by creating a superclass that contains those attributes and methods that are common to all two-player games. The superclass will define the most general and generic elements of two-player games. All two-player games, including OneRowNim, will be defined as subclasses of this top-level superclass and will inherit and possibly override its public and protected variables and methods. Also, our top-level class will contain certain abstract methods, whose implementations will be given in OneRowNim and other subclasses.
    Generic superclass
    A second goal is to design a class hierarchy that makes it possible for computers to play the game, as well as human users. Thus, for a given two-player game, it should be possible for two humans to play each other, or for two computers to play each other, or for a human to play against a computer. This design goal will require that our design exhibit a certain amount of flexibility. As we shall see, this is a situation in which Java interfaces will come in handy.
    [Page 376]
    Another important goal is to design a two-player game hierarchy that can easily be used with a variety of different user interfaces, including command-line interfaces and GUIs. To handle this feature, we will develop Java interfaces to serve as interfaces between our two-player games and various user interfaces.
    8.6.2. Designing the TwoPlayerGame Class
    To begin revising the design of the OneRowNim game, we first need to design a top-level class, which we will call the TwoPlayerGame class. What variables and methods belong in this class? One way to answer this question is to generalize our current version of OneRowNim by moving any variables and methods that apply to all two-player games up to the TwoPlayerGame class. All subclasses of TwoPlayerGamewhich includes the OneRowNim classwould inherit these elements. Figure 8.18 shows the current design of OneRowNim.
    Figure 8.18. The current OneRowNim class.
    What variables and methods should we move up to the TwoPlayerGame class? Clearly, the class constants, PLAYER_ONE and PLAYER_TWO, apply to all two-player games. These should be moved up. On the other hand, the MAX_PICKUP and MAX_STICKS constants apply just to the OneRowNim game. They should remain in the OneRowNim class.
    The nSticks instance variable is a variable that only applies to the OneRowNim game but not to other two-player games. It should stay in the OneRowNim class. On the other hand, the onePlaysNext variable applies to all two-player games, so we will move it up to the TwoPlayerGame class.
    Because constructors are not inherited, all of the constructor methods will remain in the OneRowNim class. The instance methods, takeSticks() and getSticks(), are specific to OneRowNim, so they should remain there. However, the other methods, getPlayer(), gameOver(), getWinner(), and reportGameState(), are methods that would be useful to all two-player games. Therefore these methods should be moved up to the superclass. Of course, while these methods can be defined in the superclass, some of them can only be implemented in subclasses. For example, the reportGameState() method reports the current state of the game, so it has to be implemented in OneRowNim. Similarly, the getWinner() method defines how the winner of the game is determined, a definition that can only occur in the subclass. Every two-player game needs methods such as these. Therefore, we will define these methods as abstract methods in the superclass. The intention is that TwoPlayerGame subclasses will provide game-specific implementations for these methods.
    [Page 377]
    Constructors are not inherited
    Given these considerations, we come up with the design shown in Figure 8.19. The design shown in this figure is much more complex than the designs used in earlier chapters. However, the complexity comes from combining ideas already discussed in previous sections of this chapter, so don't be put off by it.
    Figure 8.19. TwoPlayerGame is the superclass for OneRowNim and other two-player games.
    To begin with, note that we have introduced two Java interfaces into our design in addition to the TwoPlayerGame superclass. As we will show, these interfaces lead to a more flexible design and one that can easily be extended to incorporate new two-player games. Let's take each element of this design separately.
    [Page 378]
    8.6.3. The TwoPlayerGame Superclass
    As we have stated, the purpose of the TwoPlayerGame class is to serve as the superclass for all two-player games. Therefore, it should define the variables and methods shared by two-player games.
    The PLAYER_ONE, PLAYER_TWO, and onePlaysNext variables and the getPlayer(), setPlayer(), and changePlayer() methods have been moved up from the OneRowNim class. Clearly, these variables and methods apply to all two-player games. Note that we have also added three new variables, nComputers, computer1, computer2, and their corresponding methods, getNComputers() and addComputerPlayer(). We will use these elements to give our games the capability to be played by computer programs. Because we want all of our two-player games to have this capability, we define these variables and methods in the superclass rather than in OneRowNim and subclasses of TwoPlayerGame.
    Note that the computer1 and computer2 variables are declared to be of type IPlayer. IPlayer is an interface containing a single method declaration, the makeAMove() method:
    public interface IPlayer {
    public String makeAMove(String prompt);
    Why do we use an interface here rather than some type of game-playing object? This is a good design question. Using an interface here makes our design more flexible and extensible because it frees us from having to know the names of the classes that implement the makeAMove() method. The variables computer1 and computer2 will be assigned objects that implement IPlayer via the addComputerPlayer() method.
    Game-dependent algorithms
    The algorithms used in the various implementations of makeAMove() are game-dependentthey depend on the particular game being played. It would be impossible to define a game playing object that would suffice for all two-player games. Instead, if we want an object that plays OneRowNim, we would define a OneRowNimPlayer and have it implement the IPlayer interface. Similarly, if we want an object that plays checkers, we would define a CheckersPlayer and have it implement the IPlayer interface. By using an interface here, our TwoPlayerGame hierarchy can deal with a wide range of differently named objects that play games, as long as they implement the IPlayer interface. Using the IPlayer interface adds flexibility to our game hierarchy and makes it easier to extend it to new, yet undefined, classes. We will discuss the details of how to design a game player in Section 8.6.7.
    The IPlayer interface
    Turning now to the methods defined in TwoPlayerGame, we have already seen implementations of getPlayer(), setPlayer(), and changePlayer() in the OneRowNim class. We will just move those implementations up to the superclass. The getNComputers() method is the assessor method for the nComputers variable, and its implementation is routine. The addComputerPlayer() method adds a computer player to the game. Its implementation is as follows:
    [Page 379]
    public void addComputerPlayer(IPlayer player) {
    if (nComputers == 0)
    computer2 = player;
    else if (nComputers == 1)
    computer1 = player;
    else
    return; // No more than 2 players
    ++nComputers;
    As we noted earlier, the classes that play the various TwoPlayerGames must implement the IPlayer interface. The parameter for this method is of type IPlayer. The algorithm we use checks the current value of nComputers. If it is 0, which means that this is the first IPlayer added to the game, the player is assigned to computer2. This allows the human user to be associated with PLAYERONE if this is a game between a computer and a human user.
    If nComputers equals 1, which means that we are adding a second IPlayer to the game, we assign that player to computer1. In either of these cases, we increment nComputers. Note what happens if nComputers is neither 1 nor 2. In that case, we simply return without adding the IPlayer to the game and without incrementing nComputers. This, in effect, limits the number of IPlayers to two. (A more sophisticated design would throw an exception to report an error. but we will leave that for a subsequent chapter.)
    The addComputerPlayer() method is used to initialize a game after it is first created. If this method is not called, the default assumption is that nComputers equals zero and that computer1 and computer2 are both null. Here's an example of how it could be used:
    OneRowNim nim = new OneRowNim(11); // 11 sticks
    nim.add(new NimPlayer(nim)); // 2 computer players
    nim.add(new NimPlayerBad(nim));
    Note that the NimPlayer() constructor takes a reference to the game as its argument. Clearly, our design should not assume that the names of the IPlayer objects would be known to the TwoPlayerGame superclass. This method allows the objects to be passed in at runtime. We will discuss the details of NimPlayerBad in Section 8.6.7.
    The getrules() method is a new method whose purpose is to return a string that describes the rules of the particular game. This method is implemented in the TwoPlayerGame class with the intention that it will be overridden in the various subclasses. For example, its implementation in TwoPlayerGame is:
    public String getRules() {
    return "The rules of this game are: ";
    Overriding a method
    [Page 380]
    and its redefinition in OneRowNim is:
    public String getRules() {
    return "\n*** The Rules of One Row Nim ***\n" +
    "(1) A number of sticks between 7 and " + MAX_STICKS +
    " is chosen.\n" +
    "(2) Two players alternate making moves.\n" +
    "(3) A move consists of subtracting between 1 and\n\t" +
    MAX_PICKUP +
    " sticks from the current number of sticks.\n" +
    "(4) A player who cannot leave a positive\n\t" +
    " number of sticks for the other player loses.\n";
    The idea is that each TwoPlayerGame subclass will take responsibility for specifying its own set of rules in a form that can be displayed to the user.
    You might recognize that defining geTRules() in the superclass and allowing it to be overridden in the subclasses is a form of polymorphism. It follows the design of the toString() method, which we discussed earlier. This design will allow us to use code that takes the following form:
    TwoPlayerGame game = new OneRowNim();
    System.out.println(game.getRules());
    Polymorphism
    In this example the call to getrules() is polymorphic. The dynamic-binding mechanism is used to invoke the getrules() method defined in the OneRowNim class.
    The remaining methods in TwoPlayerGame are defined abstractly. The gameOver() and getWinner() methods are both game-dependent methods. That is, the details of their implementations depend on the particular TwoPlayerGame subclass in which they are implemented.
    This is good example of how abstract methods should be used in designing a class hierarchy. We give abstract definitions in the superclass and leave the detailed implementations up to the individual subclasses. This allows the different subclasses to tailor the implementations to their particular needs, while allowing all subclasses to share a common signature for these tasks. This enables us to use polymorphism to create flexible, extensible class hierarchies.
    Figure 8.20 shows the complete implementation of the abstract TwoPlayerGame class. We have already discussed the most important details of its implementation.
    Figure 8.20. The TwoPlayerGame class
    (This item is displayed on page 381 in the print version)
    public abstract class TwoPlayerGame {
    public static final int PLAYER_ONE = 1;
    public static final int PLAYER_TWO = 2;
    protected boolean onePlaysNext = true;
    protected int nComputers = 0; // How many computers
    // Computers are IPlayers
    protected IPlayer computer1, computer2;
    public void setPlayer(int starter) {
    if (starter == PLAYER_TWO)
    onePlaysNext = false;
    else onePlaysNext = true;
    } // setPlayer()
    public int getPlayer() {
    if (onePlaysNext)
    return PLAYER_ONE;
    else return PLAYER_TWO;
    } // getPlayer()
    public void changePlayer() {
    onePlaysNext = !onePlaysNext;
    } // changePlayer()
    public int getNComputers() {
    return nComputers;
    } // getNComputers()
    public String getRules() {
    return "The rules of this game are: ";
    } // getRules()
    public void addComputerPlayer(IPlayer player) {
    if (nComputers == 0)
    computer2 = player;
    else if (nComputers == 1)
    computer1 = player;
    else
    return; // No more than 2 players
    ++nComputers;
    } // addComputerPlayer()
    public abstract boolean gameOver(); // Abstract Methods
    public abstract String getWinner();
    } // TwoPlayerGame class
    Effective Design: Abstract Methods
    Abstract methods allow you to give general definitions in the superclass and leave the implementation details to the different subclasses.
    [Page 381]
    8.6.4. The CLUIPlayableGame Interface
    We turn now to the two interfaces shown in Figure 8.19. Taken together, the purpose of these interfaces is to create a connection between any two-player game and a command-line user interface (CLUI). The interfaces provide method signatures for the methods that will implement the details of the interaction between a TwoPlayerGame and a UserInterface. Because the details of this interaction vary from game to game, it is best to leave the implementation of these methods to the games themselves.
    Note that CLUIPlayableGame extends the IGame interface. The IGame interface contains two methods that are used to define a standard form of communication between the CLUI and the game. The getGamePrompt() method defines the prompt used to signal the user for a move of some kindfor example, "How many sticks do you take (1, 2, or 3)?" And the reportGameState() method defines how the game will report its current statefor example, "There are 11 sticks remaining." CLUIPlayableGame adds the play() method to these two methods. As we will see shortly, the play() method contains the code that will control the playing of the game.
    [Page 382]
    Extending an interface
    The source code for these interfaces is very simple:
    public interface CLUIPlayableGame extends IGame {
    public abstract void play(UserInterface ui);
    public interface IGame {
    public String getGamePrompt();
    public String reportGameState();
    } // IGame
    Note that the CLUIPlayableGame interface extends the IGame interface. A CLUIPlayableGame is a game that can be played through a CLUI. The purpose of its play() method is to contain the game-dependent control loop that determines how the game is played via a user interface (UI). In pseudocode, a typical control loop for a game would look something like the following:
    Initialize the game.
    While the game is not over
    Report the current state of the game via the UI.
    Prompt the user (or the computer) to make a move via the UI.
    Get the user's move via the UI.
    Make the move.
    Change to the other player.
    The play loop sets up an interaction between the game and the UI. The UserInterface parameter allows the game to connect directly to a particular UI. To allow us to play our games through a variety of UIs, we define UserInterface as the following Java interface:
    public interface UserInterface {
    public String getUserInput();
    public void report(String s);
    public void prompt(String s);
    Any object that implements these three methods can serve as a UI for one of our TwoPlayerGames. This is another example of the flexibility of using interfaces in object-oriented design.
    To illustrate how we use UserInterface, let's attach it to our KeyboardReader class, thereby letting a KeyboardReader serve as a CLUI for TwoPlayerGames. We do this simply by implementing this interface in the KeyboardReader class, as follows:
    public class KeyboardReader implements UserInterface
    [Page 383]
    As it turns out, the three methods listed in UserInterface match three of the methods in the current version of KeyboardReader. This is no accident. The design of UserInterface was arrived at by identifying the minimal number of methods in KeyboardReader that were needed to interact with a TwoPlayerGame.
    Effective Design: Flexibility of Java Interfaces
    A Java interface provides a means of associating useful methods with a variety of different types of objects, leading to a more flexible object-oriented design.
    The benefit of defining the parameter more generally as a UserInterface instead of as a KeyboardReader is that we will eventually want to allow our games to be played via other kinds of command-line interfaces. For example, we might later define an Internet-based CLUI that could be used to play OneRowNim among users on the Internet. This kind of extensibilitythe ability to create new kinds of UIs and use them with TwoPlayerGamesis another important design feature of Java interfaces.
    Generality principle
    Effective Design: Extensibility and Java Interfaces
    Using interfaces to define useful method signatures increases the extensibility of a class hierarchy.
    As Figure 8.19 shows, OneRowNim implements the CLUIPlayableGame interface, which means it must supply implementations of all three abstract methods: play(), getGamePrompt(), and reportGameState().
    8.6.5. Object-Oriented Design: Interfaces or Abstract Classes?
    Why are these methods defined in interfaces? Couldn't we just as easily define them in the TwoPlayerGame class and use inheritance to extend them to the various game subclasses? After all, isn't the net result the same, namely, that OneRowNim must implement all three methods.
    These are very good design questions, exactly the kinds of questions one should ask when designing a class hierarchy of any sort. As we pointed out in the Animal example earlier in the chapter, you can get the same functionality from an abstract interface and an abstract superclass method. When should we put the abstract method in the superclass, and when does it belong in an interface? A very good discussion of these and related object-oriented design issues is available in Java Design, 2nd Edition, by Peter Coad and Mark Mayfield (Yourdan Press, 1999). Our discussion of these issues follows many of the guidelines suggested by Coad and Mayfield.
    Interfaces vs. abstract methods
    We have already seen that using Java interfaces increases the flexibility and extensibility of a design. Methods defined in an interface exist independently of a particular class hierarchy. By their very nature, interfaces can be attached to any class, and this makes them very flexible to use.
    Flexibility of interfaces
    Another useful guideline for answering this question is that the superclass should contain the basic common attributes and methods that define a certain type of object. It should not necessarily contain methods that define certain roles that the object plays. For example, the gameOver() and getWinner() methods are fundamental parts of the definition of a TwoPlayerGame. One cannot define a game without defining these methods. By contrast, methods such as play(), getGamePrompt(), and reportGameState() are important for playing the game but they do not contribute in the same way to the game's definition. Thus these methods are best put into an interface. Therefore, one important design guideline is:
    [Page 384]
    Effective Design: Abstract Methods
    Methods defined abstractly in a superclass should contribute in a fundamental way to the basic definition of that type of object, not merely to one of its roles or its functionality.
    8.6.6. The Revised OneRowNim Class
    Figure 8.21 provides a listing of the revised OneRowNim class, one that fits into the TwoPlayerGame class hierarchy. Our discussion in this section will focus on the features of the game that are new or revised.
    Figure 8.21. The revised OneRowNim class, Part I.
    (This item is displayed on page 385 in the print version)
    public class OneRowNim extends TwoPlayerGame implements CLUIPlayableGame {
    public static final int MAX_PICKUP = 3;
    public static final int MAX_STICKS = 11;
    private int nSticks = MAX_STICKS;
    public OneRowNim() { } // Constructors
    public OneRowNim(int sticks) {
    nSticks = sticks;
    } // OneRowNim()
    public OneRowNim(int sticks, int starter) {
    nSticks = sticks;
    setPlayer(starter);
    } // OneRowNim()
    public boolean takeSticks(int num) {
    if (num < 1 || num > MAX_PICKUP || num > nSticks)
    return false; // Error
    else // Valid move
    { nSticks = nSticks - num;
    return true;
    } // else
    } // takeSticks()
    public int getSticks() {
    return nSticks;
    } // getSticks()
    public String getRules() {
    return "\n*** The Rules of One Row Nim ***\n" +
    "(1) A number of sticks between 7 and " + MAX_STICKS +
    " is chosen.\n" +
    "(2) Two players alternate making moves.\n" +
    "(3) A move consists of subtracting between 1 and\n\t" +
    MAX_PICKUP + " sticks from the current number of sticks.\n" +
    "(4) A player who cannot leave a positive\n\t" +
    " number of sticks for the other player loses.\n";
    } // getRules()
    public boolean gameOver() {   /*** From TwoPlayerGame */
    return (nSticks <= 0);
    } // gameOver()
    public String getWinner() {        /*** From TwoPlayerGame */
    if (gameOver()) //{
    return "" + getPlayer() + " Nice game.";
    return "The game is not over yet."; // Game is not over
    } // getWinner()
    The gameOver() and getWinner() methods, which are nowinherited from the TwoPlayerGame superclass, are virtually the same as in the previous version. One small change is that getWinner() now returns a String instead of an int. This makes the method more generally useful as a way of identifying the winner for all TwoPlayerGames.
    Similarly, the getGamePrompt() and reportGameState() methods merely encapsulate functionality that was present in the earlier version of the game. In our earlier version the prompts to the user were generated directly by the main program. By encapsulating this information in an inherited method, we make it more generally useful to all TwoPlayerGames.
    Inheritance and generality
    The major change to OneRowNim comes in the play() method, which controls the playing of OneRowNim (Fig. 8.22). Because this version of the game incorporates computer players, the play loop is a bit more complex than in earlier versions of the game. The basic idea is still the same: The method loops until the game is over. On each iteration of the loop, one or the other of the two players, PLAYER_ONE or PLAYER_TWO, takes a turn making a movethat is, deciding how many sticks to pick up. If the move is a legal move, then it becomes the other player's turn.
    Figure 8.22. The revised OneRowNim class, Part II.
    (This item is displayed on page 386 in the print version)
    /** From CLUIPlayableGame */
    public String getGamePrompt() {
    return "\nYou can pick up between 1 and " +
    Math.min(MAX_PICKUP,nSticks) + " : ";
    } // getGamePrompt()
    public String reportGameState() {
    if (!gameOver())
    return ("\nSticks left: " + getSticks() +
    " Who's turn: Player " + getPlayer());
    else
    return ("\nSticks left: " + getSticks() +
    " Game over! Winner is Player " + getWinner() +"\n");
    } // reportGameState()
    public void play(UserInterface ui) { // From CLUIPlayableGame interface
    int sticks = 0;
    ui.report(getRules());
    if (computer1 != null)
    ui.report("\nPlayer 1 is a " + computer1.toString());
    if (computer2 != null)
    ui.report("\nPlayer 2 is a " + computer2.toString());
    while(!gameOver()) {
    IPlayer computer = null; // Assume no computers
    ui.report(reportGameState());
    switch(getPlayer()) {
    case PLAYER_ONE: // Player 1's turn
    computer = computer1;
    break;
    case PLAYER_TWO: // Player 2's turn
    computer = computer2;
    break;
    } // cases
    if (computer != null) {                           // If computer's turn
    sticks = Integer.parseInt(computer.makeAMove(""));
    ui.report(computer.toString() + " takes " + sticks + " sticks.\n");
    } else {                                          // otherwise, user's turn
    ui.prompt(getGamePrompt());
    sticks =
    Integer.parseInt(ui.getUserInput()); // Get user's move
    if (takeSticks(sticks)) // If a legal move
    changePlayer();
    } // while
    ui.report(reportGameState()); // The game is now over
    } // play()
    } // OneRowNim class
    Let's look now at how the code decides whether it is a computer's turn to move or a human player's turn. Note that at the beginning of the while loop, it sets the computer variable to null. It then assigns computer a value of either computer1 or computer2, depending on whose turn it is. But recall that one or both of these variables may be null, depending on how many computers are playing the game. If there are no computers playing the game, then both variables will be null. If only one computer is playing, then computer1 will be null. This is determined during initialization of the game, when the addComputerPlayer() is called. (See above.)
    In the code following the switch statement, if computer is not null, then we call computer.makeAMove(). As we know, the makeAMove() method is part of the IPlayer interface. The makeAMove() method takes a String parameter that is meant to serve as a prompt, and returns a String that is meant to represent the IPlayer's move:
    public interface IPlayer {
    public String makeAMove(String prompt);
    [Page 385]
    In OneRowNim the "move" is an integer, representing the number of sticks the player picks. Therefore, in play() OneRowNim has to convert the String into an int, which represents the number of sticks the IPlayer picks up.
    On the other hand, if computer is null, this means that it is a human user's turn to play. In this case, play() calls ui.getUserInput(), employing the user interface to input a value from the keyboard. The user's input must also be converted from String to int. Once the value of sticks is set, either from the user or from the IPlayer, the play() method calls takeSticks(). If the move is legal, then it changes whose turn it is, and the loop repeats.
    [Page 386]
    There are a couple of important points about the design of the play() method. First, the play() method has to know what to do with the input it receives from the user or the IPlayer. This is game-dependent knowledge. The user is inputting the number of sticks to take in OneRowNim. For a tic-tac-toe game, the "move" might represent a square on the tic-tac-toe board. This suggests that play() is a method that should be implemented in OneRowNim, as it is here, because OneRowNim encapsulates the knowledge of how to play the One-Row Nim game.
    Encapsulation of game-dependent knowledge
    [Page                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

  • How to create Authority check object

    Hello Gurus,
    How to create Authority-check object 'ZABC'
                                                             ID 'TABLE' FIELD 'ZTABLE'.
    Please tell me detailed procedure.
    Thanks in advance.
    Best Regards,
    zubera

    Dear Zubera,
    Creating Authorization Fields
    In authorization objects, authorization fields represent the values to be tested during authorization checks.
    To create authorization fields, choose Tools --> ABAP Workbench --> Development --> Other tools --> Authorization objects ® Fields.
    To create a authorization field:
    1. Choose Create authorization field.
    2. On the next screen, enter the name of the field. Field names    must be unique and must begin with the letter Y or Z.
    3. Assign a data element from the ABAP Dictionary to the field.
    4. If desired, enter a check table for the possible entries. For    more information about check tables.
    For more information about AUTHORITY-CHECK, see the keyword documentation of the ABAP Editor.
    You can often use the fields defined by SAP in your own authorization objects. If you create a new authorization object, you do not need to define your own fields. For example, you can use the SAP field ACTVT in your own authorization objects to represent a wide variety of actions in the system.
    Assigning an Authorization Object to an Object Class
    Each authorization object must be assigned to an object class when it is created.
    Choose Tools --> ABAP Workbench --> Development --> Other tools --> Authorization objects --> Objects.
    You can also create authorization objects in the Object Navigator (SE80).
    Creating / Choosing Object Classes
    The system displays a list of existing object classes.
    Object classes are organized according to the components of the system.
    Before you can create a new object, you must define the object class for the component in which you are working. The objects are not overwritten when you install new releases.
    You can also define your own object classes. If you do so, select class names that begin with Y or Z to avoid conflicts with SAP names.
    Creating an Object
    Enter a unique object name and the fields that belong to the object. Object names must begin with the letter Y or Z in accordance with the naming convention for customer-specific objects.
    You can enter up to ten authorization fields in an object definition. You must also enter a description of the object and create documentation for it.
    Ensure that the object definition matches the AUTHORITY-CHECK calls that refer to the object.
    Do not change or delete authorization objects defined by SAP. This disables SAP programs that use the objects.
    You can regenerate the profile SAP_ALL after creating an authorization object.
    Best Regards,
    Rajesh
    Please reward points if found helpful.

  • Error in code, cannot figure it out. - class, interface, or enum expected

    IT is telling me i have an error in line 22 and it says class, interface, or enum expected
    import java.util.Scanner
    * @(#)Blahh.java
    * Blahh application
    * @author
    * @version 1.00 2010/1/29
    public class Blahh {
    public static void main(String[] args) {
         // TODO, add your application code
         System.out.println("Hello World!");
    // PURPOSE: An exercise in tracing a program and understanding
    // assignment statements and expressions.
    import java.util.Scanner
    Public class Trace
    public static void main (String[] args)
    int one, two, three;
    double what;
    Scanner scan = new Scanner(System.in);
    System.out.print ("Enter two integers: ");
    one = scan.nextInt();
    two = scan.nextInt();
    system.out.print("Enter a floating point number: ");
    what = scan.nextDouble();
    three = 4 * one + 5 * two;
    two = 2 * one;
    system.out.println ("one " + two + ":" + three);
    one = 46 / 5 * 2 + 19 % 4;
    three = one + two;
    what = (what + 2.5) / 2;
    System.out.println (what + " is what!");
    }}

    youngtron92 wrote:
    IT is telling me i have an error in line 22 and it says class, interface, or enum expected
    import java.util.Scanner
    * @(#)Blahh.java
    * Blahh application
    * @author
    * @version 1.00 2010/1/29
    public class Blahh {
    public static void main(String[] args) {
         // TODO, add your application code
         System.out.println("Hello World!");
    // PURPOSE: An exercise in tracing a program and understanding
    // assignment statements and expressions.
    import java.util.Scanner
    Public class Trace
    public static void main (String[] args)
    int one, two, three;
    double what;
    Scanner scan = new Scanner(System.in);
    System.out.print ("Enter two integers: ");
    one = scan.nextInt();
    two = scan.nextInt();
    system.out.print("Enter a floating point number: ");
    what = scan.nextDouble();
    three = 4 * one + 5 * two;
    two = 2 * one;
    system.out.println ("one " + two + ":" + three);
    one = 46 / 5 * 2 + 19 % 4;
    three = one + two;
    what = (what + 2.5) / 2;
    System.out.println (what + " is what!");
    }}Is that all a single source file? The import statement(s) need to be at the top, and each import has to be terminated by a semicolon.
    Also this is wrong. Case matters.
    Public class Trace

  • Hi ,info need on container creation,methods,class,interface....

    hi ppl,
              Can anybody give me information on what is and how to create
    container creation,methods,class,interface....with programs.

    >
    priyank dev wrote:
    > hi ppl,
    >           Can anybody give me information on what is and how to create
    >  container creation,methods,class,interface....with programs.
    Hi Dev,
    Interface is just the skeleton of the class definition.
    If you want to have your own code for all or any of the methods that interface is havings then you can create an instance of that interface and implement those methods with you own code.
    That is the advantage of object oriented programming. And if you want to use the standard method or original method's functionality then you have call the method along with the class which implemented it like below
    class => method1
    For Imore information on interfaces Check this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    For creating classes you can follow this procedure.
    Go with abap dictionary->select database table->provide the table for dev classs eg. V_TDEVC-> go for display option-> select utilities->select contents option-> select create dev class,
    provide the name and short text,software component->create req.no.
    with this dev class will be created.
    Thanks
    Nitesh
    Edited by: Nitesh Kumar on Nov 18, 2008 10:56 AM

  • Tcode for see AUTHORITY-CHECK asignement for User ?

    Hi everybody
    1. Does somebody knows a TCode for see an Authorization Object directly, that is i know to see them using SU21, then selecting an Authorization Class and then i see the corresponding Auth.Objetcs.  But, is there a Tcode for see the Auth.Objects without see first the Auth.Classes ?
    2, Is there a Tcode for see the Auth.Objects and values assigned for a user , that is, a Tcode for evaluate if an AUTHORITY-CHECK is going to be passed by an specific user-object-activity ?
    For example, i have the Auth.Object  'M_MATE_WRK' wich uses the Plant (WERKS) object.  Is there a Tcode wich allow me to know if a user has asigned this Auth.Object for specified Plant (WERKS) Value, and wich activities does the user has permited ?
    Thanks..
    Frank

    Hello Frank
    Call transaction <b>SUIM</b> (User Information System) and check the available reports there. I am sure you will find a report fulfilling your requirement.
    Regards
      Uwe

  • Authority Check Object

    Hello Freinds,
    If there is a field from custamize table for exa.(Zmara-werks )then can we use standard authority check object? or should we create custamize authority object.
    Please guide me...........
    Thanks,
    Amar

    Hi ,
           To Find Authorization Object for a particular field, use TCode SU21. Click on Find button and enter the filed name to know the Authorization Object.
    If suitable combination of required fields is not found in Authorization objects, new objects need to be created. Use TCode SU21 to create new authorization objects. Click on Create Button and enter new object class name and press save button.

Maybe you are looking for

  • Whats the difference between the two XMP packet tags

    Hi, I opened a file Bluesquare.indd(from XMP SDK sampke) and I found two XMP packets inside the file. One packet with tag and another one with tag When I tried to extract the xmp using getXMP() method from XMPFiles then, I got the packet with tag So

  • In PSE 11 how to import photos to the organizer from the computer files and folders

    While using the restore function in PSE 11 (Windows 8), using a catalog backup from PSE 8 (Windows XP), a number of images could not be restored. To try to link to the images in their actual  location, I tried the following: 1. I used the File Get fu

  • Cisco VTA and QoS

    When a video call is placed with VTA, both the audio and video streams are marked with DSCP AF41 (instead of the voice usually being marked as DSCP EF). Ideally, does this traffic also need to go into a priority queue?

  • Apple tv airplay and sound

    Is it possible to use airplay on TV and have the sound on our device ?

  • Pdf form file conversion

    How can I convert an existing pdf fillable form to MSWord format?  Adobe's standard pdf file conversion service does not accept fillable pdf forms.