Access to class-attribute by Interface-reference

Hi OO-Gurus,
I use an implementation of BADI ME_PROCESS_REQ_CUST to fill and handle user-defined fields in the MM-Purchase-Requisition, method IF_EX_ME_PROCESS_REQ_CUST~OPEN.
There I  use a reference variable which refers to an interface (type ref to IF_PURCHASE_REQUISITION_ITEM) to access the item-object. My problem is that I need to have access to the class-attribute my_state. The corresponding class lcl_req_item is defined locally (LMEREQF01). So I can’t use  a reference variable with reference to this class (so widening cast using the interface-reference is not possible) .. Does anyone know a trick how to access the class-attribute anyway?
Coding:
  data:  l_item_list       TYPE MMPUR_REQUISITION_ITEMS,
           l_item             TYPE MMPUR_REQUISITION_ITEM,
           l_item_akt       TYPE mereq_item,
           l_item_ref        TYPE ref to IF_PURCHASE_REQUISITION_ITEM. 
  l_item_list = im_header->get_items().
  loop at l_item_list into l_item.
    l_item_akt = l_item-item->get_data( ).
    l_item_ref = l_item-item.
  endloop.
(Debugging the code, I manage by doubleclicking the fieldcontent of l_item_ref (e.g ) to show the content of the class-attribute my_state. This works only if the field “Interface” in the Debugger is empty because then I see the attributes of the class. If the field Interface is filled with “IF_PURCHASE_REQUISITION_ITEM”, there aren’t any attributes shown.)
Thanks in advance for your kind help!!
Nicole

Hello Nicole
The following sample coding shows you how to solve your problem. Please do not ask me how I came across this solution.
However, if you are studying it carefully you may stumble across a most beautiful property of field-symbols as I did.
METHOD if_ex_me_process_req_cust~open.
  DATA: l_item_list TYPE mmpur_requisition_items,
  l_item TYPE mmpur_requisition_item,
  l_item_akt TYPE mereq_item,
  l_item_ref TYPE REF TO if_purchase_requisition_item.
  DATA:
    ld_attr         TYPE string,
    lo_obj          TYPE REF TO object.
  FIELD-SYMBOLS:
    <lo_lcl>        TYPE ANY,
    <ls_item>       TYPE mereq_item,
    <ls_itemx>      TYPE mereq_itemx.
  l_item_list = im_header->get_items( ).
  LOOP AT l_item_list INTO l_item.
    l_item_akt = l_item-item->get_data( ).
    l_item_ref = l_item-item.
    lo_obj     ?= l_item-item.  " casting to root object !!!!!
    ld_attr = 'MY_STATE'.
    ASSIGN lo_obj->(ld_attr) TO <lo_lcl>.
    ld_attr = 'MY_STATE->ITEM'.
    ASSIGN lo_obj->(ld_attr) TO <ls_item>.
"    ASSIGN l_item_ref->(ld_attr) TO <ls_item>.  " does not work...
    ld_attr = 'MY_STATE->ITEMX'.
    ASSIGN lo_obj->(ld_attr) TO <ls_itemx>.
  ENDLOOP.
  " NOTE: data definition of local class lcl_req_item_state (fg MEREQ)
**    DATA:  item           TYPE mereq_item,
**           itemx          TYPE mereq_itemx,
**           header         TYPE REF TO lcl_req_header,
**           ref_item       TYPE REF TO lcl_req_item,
**           acct_container TYPE REF TO lcl_acct_container,
**           source         TYPE REF TO cl_source_of_supply_mm,
**           release_state  TYPE REF TO cl_release_state_mm,
**           text_manager   TYPE REF TO lcl_text_manager,
**           bom            TYPE REF TO lcl_bom,
**           funds_mgt_active TYPE mmpur_bool VALUE mmpur_no,
**           aktyp          TYPE aktyp,
**           no_auth        TYPE mmpur_bool VALUE mmpur_no,
**           release_op     type mmpur_bool value mmpur_no,
**           persistent     TYPE mmpur_bool VALUE mmpur_no,
**           checked        TYPE mmpur_bool VALUE mmpur_no,
**           manual_configuration TYPE mmpur_bool,
**           input_buffer_changed TYPE mmpur_bool VALUE mmpur_no,
**           changed        TYPE mmpur_bool,
**           broken_rules   TYPE lty_mask,
**           referenced_rules TYPE lty_mask,
**           chp_changes    TYPE mmchp_chp_list,
**           dcm_manager    TYPE REF TO if_revision_manager_dcm,
**           "DCM Retrofit
**           rel_state_after_release TYPE REF TO cl_release_state_mm,
**           "DCM Retrofit
**           chdoc_container TYPE REF TO lcl_chdoc_container,
**           "DCM Retrofit
**           service_changed TYPE mmpur_bool,
**           "DCM Retrofit
**           determinants   TYPE lty_item_determinants.
ENDMETHOD.
Regards
  Uwe

Similar Messages

  • Access to class attributs by coding in its mother class method definition

    Hi all,
    How can I retrieve information about a class attributs by coding?
    And is it possible to access to the attributs of the Child class from the Mother class?
    REPORT  ztest_method.
    ******      CLASS mother DEFINITION
    CLASS mother DEFINITION.
      PUBLIC SECTION.
        METHODS: get_data.
    ENDCLASS.                    "mother DEFINITION
    ******      CLASS child DEFINITION
    CLASS child DEFINITION inheriting from mother.
    ENDCLASS.                    "child DEFINITION
    *******      CLASS mother IMPLEMENTATION
    CLASS mother IMPLEMENTATION.
      METHOD get_data.
    ***Can I access to child class attributs here?
      ENDMETHOD.                    "get_data
    ENDCLASS.                    "mother IMPLEMENTATION
    DATA oref TYPE REF TO CHILD.
    DATA: method TYPE string.
    DATA: cla_name(20).
    START-OF-SELECTION.
      CREATE OBJECT oref .
      CALL METHOD oref->method).  "Here I want to access to this class's attribut without redefine it

    Hi,
    a very easy way is to define an attribute TYPE REF TO DATA in the super class and write generic access methods which work with it by dereferencing it and assigning a field symbol. This might even save you the effort of creating a class hierarchy, because one class may be able to handle all the data objects whose types are only known at run-time.
    In the below example, the only specific thing about the sub class is the constructor in which the data object is created and typed:
    REPORT  ztesta.
    *       CLASS lcl_mother DEFINITION
    CLASS lcl_mother DEFINITION.
      PUBLIC SECTION.
        METHODS get_data EXPORTING es_data TYPE any.
        METHODS set_data IMPORTING is_data TYPE any.
      PROTECTED SECTION.
        DATA mr_data TYPE REF TO data.
    ENDCLASS.                    "lcl_mother DEFINITION
    *       CLASS lcl_child1 DEFINITION
    CLASS lcl_child1 DEFINITION INHERITING FROM lcl_mother.
      PUBLIC SECTION.
        METHODS constructor.
    ENDCLASS.                    "lcl_child1 DEFINITION
    DATA:
      lr_child      TYPE REF TO lcl_mother,
      ls_but000_in  TYPE        but000,
      ls_but000_out type        but000.
    START-OF-SELECTION.
      CREATE OBJECT lr_child TYPE lcl_child1.
      ls_but000_in-partner = '0000004711'.
      lr_child->set_data( ls_but000_in ).
      lr_child->get_data( IMPORTING es_data = ls_but000_out ).
      write: / ls_but000_out-partner.
    *       CLASS lcl_mother IMPLEMENTATION
    CLASS lcl_mother IMPLEMENTATION.
      METHOD get_data.
        FIELD-SYMBOLS:
          <fs_data> TYPE ANY.
        ASSIGN mr_data->* TO <fs_data>.
        MOVE-CORRESPONDING <fs_data> TO es_data.
      ENDMETHOD.                    "get_data
      METHOD set_data.
        FIELD-SYMBOLS:
          <fs_data> TYPE ANY.
        ASSIGN mr_data->* TO <fs_data>.
        MOVE-CORRESPONDING is_data TO <fs_data>.
      ENDMETHOD.                    "set_data
    ENDCLASS.                    "lcl_mother IMPLEMENTATION
    *       CLASS lcl_child1 IMPLEMENTATION
    CLASS lcl_child1 IMPLEMENTATION.
      METHOD constructor.
        super->constructor( ).
        CREATE DATA mr_data TYPE but000.
      ENDMETHOD.                    "constructor
    ENDCLASS.                    "lcl_child1 IMPLEMENTATION
    Another variant would be to define an attribute MV_DATA which is typed individually in each sub class and program dynamically against it in the super class using field symbols.
    *& Report  ZTESTA
    REPORT  ztesta.
    *       CLASS lcl_mother DEFINITION
    CLASS lcl_mother DEFINITION.
      PUBLIC SECTION.
        METHODS get_data EXPORTING es_data TYPE any.
        METHODS set_data IMPORTING is_data TYPE any.
    ENDCLASS.                    "lcl_mother DEFINITION
    *       CLASS lcl_child1 DEFINITION
    CLASS lcl_child1 DEFINITION INHERITING FROM lcl_mother.
      PUBLIC SECTION.
        DATA: ms_data TYPE but000.
        METHODS constructor.
    ENDCLASS.                    "lcl_child1 DEFINITION
    *       CLASS lcl_child2 DEFINITION
    CLASS lcl_child2 DEFINITION INHERITING FROM lcl_mother.
      PUBLIC SECTION.
        DATA: ms_data TYPE t000.
        METHODS constructor.
    ENDCLASS.                    "lcl_child1 DEFINITION
    DATA:
      lr_child1     TYPE REF TO lcl_mother,
      lr_child2     TYPE REF TO lcl_mother,
      ls_but000     TYPE        but000,
      ls_t000       TYPE        t000.
    START-OF-SELECTION.
      CREATE OBJECT lr_child1 TYPE lcl_child1.
      lr_child1->get_data( IMPORTING es_data = ls_but000 ).
      WRITE: / ls_but000-partner.
      CREATE OBJECT lr_child2 TYPE lcl_child2.
      lr_child2->get_data( IMPORTING es_data = ls_t000 ).
      WRITE: / ls_t000-mwaer.
    *       CLASS lcl_mother IMPLEMENTATION
    CLASS lcl_mother IMPLEMENTATION.
      METHOD get_data.
        FIELD-SYMBOLS:
          <fs_data> TYPE ANY.
        ASSIGN ('MS_DATA') TO <fs_data>.
        es_data = <fs_data>.
      ENDMETHOD.                    "get_data
      METHOD set_data.
        FIELD-SYMBOLS:
          <fs_data> TYPE ANY.
        ASSIGN ('MS_DATA') TO <fs_data>.
        <fs_data> = is_data.
      ENDMETHOD.                    "set_data
    ENDCLASS.                    "lcl_mother IMPLEMENTATION
    *       CLASS lcl_child1 IMPLEMENTATION
    CLASS lcl_child1 IMPLEMENTATION.
      METHOD constructor.
        super->constructor( ).
        SELECT SINGLE * FROM but000 INTO ms_data.
      ENDMETHOD.                    "constructor
    ENDCLASS.                    "lcl_child1 IMPLEMENTATION
    *       CLASS lcl_child2 IMPLEMENTATION
    CLASS lcl_child2 IMPLEMENTATION.
      METHOD constructor.
        super->constructor( ).
        SELECT SINGLE * FROM t000 INTO ms_data.
      ENDMETHOD.                    "constructor
    ENDCLASS.                    "lcl_child2 IMPLEMENTATION
    I hope this helps!
    Regards,
    Thorsten

  • Accessing impl class attribute

    Hi Experts,
    if i declare one variable in controller class of a view and how can access the variable in contex naode .

    Hi srinivas.yangal,
    You can access the View implementation Class Attributes in Context.
    1] Go to Context Node Implementation Class
    2] Create a attribute GV_VIEW_CONTROLLER in Impl class of Context Node.
    DATA : GV_VIEW_CONTROLLER TYPE REF TO CL_BSP_WD_VIEW_CONTROLLER .
    3] Go to INIT method of Context Node.
    4] Assign instance LV_VIEW_CONTROLLER to GV_VIEW_CONTROLLER of Context Node Impl. Class.
    GV_VIEW_CONTROLLER = LV_VIEW_CONTROLLER.
    Then you can access your Instance attributes defined in View Impl. class inside the context node through GV_VIEW_CONTROLLER attribute as follows.
    ABC = GV_VIEW_CONTROLLER->XYZ.
    Reward points if useful.
    Kind Regards,
    Dhananjay.
    Edited by: Dhananjay SAP CRM on Nov 24, 2011 12:56 PM

  • Error accessing constnt public attribute of a class in an overwrite method.

    Hi Gurus,
    I am facing an error while accessing a constant public attribute while using it in the overwrite-exit of a methods.
    The constant which is declared as public in the attribute section of the class is not available in the overwrite-exit of the method.
    Please suggest me how to access the public attributes in the overwtire exits of the methods.
    Thanks.

    Hi Ramneek,
    Let me explain you the entire scenario:
    Actually we are trying to ehance the SAP standard class : CL_FITV_POWL_FEEDER_TRIPS in ECC 6.0 EHP 5 .
    We tried to create and overwrite-exit of the method "IF_POWL_FEEDER~GET_ACTIONS".
    Overwrite-exit of a method is just like a method which will be called instead of the standard method : IF_POWL_FEEDER~GET_ACTIONS.
    But the problem which we are facing here is that the Attributes which are defined in the class CL_FITV_POWL_FEEDER_TRIPS,  are getting accessed from the overwrite-exit method.
    Becuase of this we are not able to implement our custom logic.

  • Access of undefined method/property through reference with a static type Class

    I get the following error: (it's not word for word but you get the idea)
    Error: Access of undefined method getStatus through reference with a static type Class.
    Here's what's happening in the code. I'm trying to create a User class that is instantiated at the start of my app. I want the User class to have properties like mainStatus, with helper methods like setStatus etc. Pretty simple.
    so on my HardDisk I have my flash_working folder with all my flash projects. I created my class file/package under the directory com.mypackage
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function User()
                trace("User Created!");
                mainStatus = 0;
            public function setStatus(status:int):void
             mainStatus = status;
        public function getStatus():int
            return mainStatus;
    Ok, so far so good.
    now I created a new .fla file under the root of /flash_working/. The class file is in /com/mypackage/User.as
    in my .fla file I have:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = User.getStatus();
    trace(i);
    That's all the code I have. Could someone please explain why it's giving me that error?
    If I try to access the public var mainStatus through user.mainStatus that gives a similar error saying:
    Error: Access of undefined property mainStatus through reference with a static type Class.
    Thanks for any help!
    jef3189

    the public getStatus() function that you created needs to be referred to through an instance of the class.
    So:
    import com.mypackage.User;
    var myUser:User = new User();
    var i = myUser.getStatus();
    trace(i);
    Also, an aside. You can create a getter/setter for status, to avoid having to do the function as such.
    package com.mypackage
        import flash.display.*;
        public class User extends Sprite
            public var mainStatus:int;
            public function get status():int
                return mainStatus;
            public function set status(value:int):void
                 mainStatus = value as int;
              public function User()
                trace("User Created!");
                mainStatus = 0;
    And then, you can call it as:
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.status);
    EDIT
    I just noticed that you made the variable public as well, which means you can access it without getter/setter or function.
    import com.mypackage.User;
    var myUser:User = new User();
    trace(myUser.mainStatus);

  • Array as class attribute?

    I'm currently in the process of learning Objective-C and Cocoa, however I've run into an issue with some of my code.
    I want to have an array that other objects will be able to access from my main class, so I set it to be an attribute of that class in the interface: NSObject section of my class header with the following line of code:
    NSMutableArray *qArray;
    The main issue I'm getting with this is that although the array can be accessed properly, I'm not sure how to initialise it. I used the following code that seemed to work, but only when called from the same IBAction, if sent from another control or menu then it would crash to the debugger:
    qArray = [NSMutableArray array];
    I'm guessing that qArray is being destroyed after the IBAction is finished, but how would I initialise it otherwise?

    The message +array is called a "convenience method", it returns an auto-released instance of the class, here it's an NSArray. So you have two solution, one one hand you simply use the alloc/init methods :
    qArray = [[NSArray allocWithZone: [self zone]] init]; // you can use the simple +alloc method if you want.
    Or you can retain the object returned by +array, like that :
    qArray = [[NSArray array] retain];
    In both cases, you need at the end to send the object a -release or -autorelease message :
    [qArray release];
    NB : the brackets might be not displayed in that message.

  • Client can't access Serializable classes on Server

    Hi there, i have created a very simple client server model and had it running fine. I then added a new serializable class to the server and return it in a new method. Now when i try to run that method on the client side it complains it cannot find my new serializable class ("no class def found exception: rmi/server/ServerObject.class"). This is how it's setup at the moment:
    Server
    -ServerFront extends Remote
    -Server implements ServerFront
    -ServerObject implements Serializable
    The server binds itself to the registry as such:
    ServerFront engine = new Server();
    String name = "Server";
    ServerFront stub = (ServerFront)UnicastRemoteObject.exportObject(engine, 0);
    Registry registry = LocateRegistry.getRegistry();
    registry.rebind(name, stub);The ServerObject class looks like this:
    public class ServerObject implements Serializable
        private static final long serialVersionUID = 10L;
        //methods
    }The ServerFront interface has a method as such:
    ServerObject getServerObject () throws RemoteException;    Client
    -Client
    The client gets a reference to the server as follows:
    String name = "Server";
    Registry registry = LocateRegistry.getRegistry("127.0.0.1");
    server = (ServerFront)registry.lookup(name);Then tries to run the getServerObject() method:
    ServerObject = server.getServerObject();I run the client and server from jar files using the following commands:
    start java -Djava.rmi.server.codebase="http://www.xenwars.com/Server.jar" -Djava.security.policy=security.policy -jar Server.jar
    java -Djava.security.policy=security.policy -jar Client.jar"security.policy" allows all access, and the codebase URL points to my webserver where i uploaded an identical copy of the Server jar file that i'm trying to run.
    So... i've read all the Sun documentation and such and i'm massively confused why my client isn't simply downloading the serializable class as it's supposed to. Any help is massively appreciated, thanks :D
    Edited by: Aldarn on Feb 8, 2009 10:03 AM
    Edited by: Aldarn on Feb 8, 2009 10:05 AM

    By a mirrored interface i mean i just created an interface based off my existing serializable classes, i.e. copied the method constructors into an interface class and made the serializable class implement that interface.
    I think that must have been the problem then, that i wasn't giving the client an interface to the serializable classes on the server that it was attempting to download. I thought by using RMI on a serializable class it would just download that class when it needs it and so wouldn't need an interface pre-defining it.
    Thanks for the help! I'm now working on a system with 3 servers and one client, where two servers have various methods implemented and the third one acts as a bridge between the other two servers and the client - so the client only has to deal with one server. It's working fine but it's pretty annoying having to mirror all the methods from both servers' interface classes in the server that acts as a bridge's interface class - is there any way that the bridge server can inherit the other two servers interfaces into its own so i don't need to make loads of duplicate "shell" methods like this:
    // second server
    public ArrayList<Thing> getAllThings ()
        return things;
    // bridge server
    private SecondServerFront secondServer; // reference loaded in constructor
    public ArrayList<Thing> getAllThings () throws RemoteException
        return secondServer.getAllThings();
    }  

  • Problem with Dynamically accessing EJB Class objects in WL 7.0 SP1

    I am trying to build a component which has the ability to instantiate and execute
    an known EJB method on the fly.
    I have managed to build the component but when I try and execute it I get a ClassNotFoundException.
    I know that the EJB I am trying to invoke is deployed and available on the server,
    as I can see it in the console, I also seen to have been able to get the remote
    interface of the object, my problem occurs when I try and access the class object
    so I can perform a create on the object and then execute my method
    The code I have written is below:
    private Object getRemoteObject(Context pCtx, String pJNDIName, String pHomeBean)
    throws Exception {
         String homeCreate = "create";
         Class []homeCreateParam = { };
         Object []homeCreateParamValues = {};           
    try {  
    //This call seems to work and doesn't throw an exception     
    Object home = pCtx.lookup(pJNDIName);
    //However this call throws a java.lang.ClassNotFoundException
    Class homeBean = Class.forName(pHomeBean);
    Method homeCreateMethod = homeBean.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    } catch (NamingException ne) {             
    logStandardErrorMessage("The client was unable to lookup the EJBHome.
    Please make sure ");
    logStandardErrorMessage("that you have deployed the ejb with the JNDI
    name "+pJNDIName+" on the WebLogic server ");
    throw ne;
    } catch (Exception e) {
    logStandardErrorMessage(e.toString());
    throw e;     
    Any advice would be really appreciated, I'm fast running out of ideas, I suspect
    it has something to do with the class loader but I'm not sure how to resolve it
    Regards
    Jo Corless

    Hello Joanne,
    Congratulations! I'm very happy that you've managed to fix your problem. It's
    always essential to understand how to package applications when deploying on BEA
    WebLogic. Usually, by throwing everything into an EAR file solves just about all
    the class loader problems. :-) Let us know if you have any further problems that
    we can assist you with.
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Joanne Corless" <[email protected]> wrote:
    >
    >
    I've fixed it!!!!!!!!
    Thanks to everyone who gave me help!!!!
    The class loader was the culprit which is what I suspected all along.
    As soon
    as I put the 2 jar files I was using into an EAR file the problem went
    away!!!!!
    Thanks again
    Jo Corless
    "Ryan LeCompte" <[email protected]> wrote:
    Hello Joanne,
    As Mr. Woollen mentioned, I also believe it's a problem with the class
    loader.
    You need to be careful how you arrange your EJBs, because WebLogic has
    a specific
    method in which it loads classes in an EAR, JAR, and WAR file(s). Please
    refer
    to http://dev2dev.bea.com/articles/musser.jsp for more information about
    BEA WebLogic
    class loading mechanisms and caveats. Also, try printing out the various
    methods
    that are available on the object that was returned to you via reflection.
    For
    example, use the getMethods() method, which returns an array of Method
    objects
    that you can subsequently cycle through and print out the various method
    names.
    This way you can discover if the class found/returned to you is indeed
    the one
    you intend to locate.
    Hope this helps,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    Rob Woollen <[email protected]> wrote:
    I believe the issue is the home interface class for this EJB is not
    available in the class loader which is doing the reflection.
    If you do:
    getClass().getClassLoader().loadClass(homeInterfaceClassName)
    I suspect it will fail. Reflection still requires that the class be
    loadable.
    -- Rob
    Joanne Corless wrote:
    Hi Slava,
    If I make my code look like you describe below I get a compliationerror telling
    me that
    home.getMethod() is not recognised (no such method)
    If I change it slightly and use
    Method homeCreateMethod =
    home.getClass().getMethod(homeCreate,homeCreateParam);
    The code will compile OK but when executed it still throws a NoSuchMethodException
    Any ideas ?
    Thanks for your help so far
    Regards
    Jo Corless
    Your code should look like
    Object home = pCtx.lookup(pJNDIName);
    Method homeCreateMethod =
    home.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    Regards,
    Slava Imeshev
    "Joanne Corless" <[email protected]> wrote in message
    news:[email protected]...
    Hi Ryan,
    I also wanted to mention that if you do a "header search" in this
    particular
    newsgroup
    with the search query as "reflection", you will see many previousmessages
    regarding
    reflection and EJBs. I believe you could learn a lot from thedifficulties
    that
    others have faced and solved.I tried that and although there was a number of similar cases noneof them
    actually
    seem to fix my issue. Thanks for the suggestion though
    Are the EJBs that you are trying to access accessible via your
    system
    classpath?
    Try to avoid having them accessible via the main system classpath,and
    only bundle
    them in your appropriate EJB jar files (contained in an EAR file,for
    example).Maybe I should have laid the problem out a little clearer.
    I have a number of EJB's bundled up in a JAR file which is hot deployedto
    the
    server. Within this first JAR file is an EJB (SSB) component that
    needs
    to
    be
    able to invoke a known method on another EJB. This second EJB may
    or
    may
    not be
    within the first JAR file but it also will be hot deployed.
    The component trying to invoke the method on the 2nd EJB has to
    be
    able to
    create
    an instance of the 2nd EJB without actually knowing anything bar
    a
    JNDI
    Name which
    is passed in at runtime.
    I can get as far as doing the
    Object home = pCtx.lookup(pJNDIName);
    This returned a class with the name
    "com.csc.edc.projects.allders.httppostoffice.postman.PostmanBean_mp8qy2_Home
    Impl_WLStub"
    My problem seems to occur when I try and invoke the create method
    Method homeCreate = home.getClass().getMethod("create", new Class[0]);
    My code throws a java.lang.NoSuchMethodException at this point so
    I
    am
    unable
    to progress to the next step of :
    Object bean = homeCreate.invoke(home, null);
    So I can return the instantiated bean back to the calling client.
    Why am I getting the NoSuchMethodException, is is because I am gettinga
    stub
    back rather than the home interface and if so how do I get the truehome
    interface
    from the bean
    Thanks in advance
    Jo Corless

  • Field-symbols as class attribute

    Hi Fellas,
    Is there a way we can define a field-symbols as a class attribute ? My requirement is that i am dynamically constructing a structure at runtime in my model class and binding the component of this structure to my view fields. I am able to create the structure which is basically ref to cl_abap_structdescr and the problem is when i am binding to the model attribute, i need this to be a structure so that i can address the components as "//model/structure.component".
    Please let me know how we can define a field-symbol as a class attribute.
    Cheers,
    Ram.

    Hi Ram,
    Field-Symbol as class attribute is not possible. Your way to do this by REF TO DATA is the correct way for that.
    By default data binding is only possible like this:
    Simple field attribute
    value=”//<model>/<field name>”
    Structure attribute
    value=”//<model>/<structure name>.<field name>”
    Table attribute
    value=”//<model>/<table name>[<line index].<field name>”
    If you want to bind to your data reference you have to implement your own getter and setter methods. Read this <a href="http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm">http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm</a> for further information. In addition to that, you have to implement your own GET_M_S_xxx to return metadata of your structure. By doing all this it is possible to implement a completely dynamic data binding. In the view it looks like the regular Structure attribute: value=”//<model>/<data-ref name>.<field name>”
    Regards,
    Thilo

  • Load Jar and access a class in jar at run time

    I need help from you.
    How to load a Jar and access a class in the jar at run time?
    When i try the following code it works fine while running in Java (Jdk1.5).If iam running the same code in servlet,ClassCastException occurs.
    Error Message : ClassCastExcption : jartest1 cannot be cast to Thing
    test.jar contains jartest.class and Thing.class
    jartest1.java
    try{
    File file =new File("test.jar");
    String lcStr ="jartest";
    URL jfile = new URL("jar", "", "file:" + file.getAbsolutePath() +"!/");
    URLClassLoader cl = URLClassLoader.newInstance(new URL[] { jfile });
    Class loadedClass = cl.loadClass(lcStr);
    Thing t=(Thing)loadedClass.newInstance();
    t.execute();
    catch(Exception e)
    System.err.println(e);
    Thing.java
    public interface Thing
    void execute();
    jartest.java
    public class jartest implements Thing
    public void exceute()
    System.out.println("Welcome");
    Thanks and Regards
    V.Senthil Kumar
    Edited by: senthilv_sun on Dec 16, 2008 8:30 PM

    senthilv_sun wrote:
    I need help from you.
    How to load a Jar and access a class in the jar at run time?
    When i try the following code it works fine while running in Java (Jdk1.5).If iam running the same code in servlet,ClassCastException occurs.
    Error Message : ClassCastExcption : jartest1 cannot be cast to ThingPresumably we can only hope that that is a transciption error. It always helps to use copy and past actual errors and code rather than manually typing them.
    test.jar contains jartest.class and Thing.classWrong.
    The interface class and plugable class must not be in the same jar.
    A plugable interface requires two components
    - Interface (generic sense)
    - Functional components.
    The Interface must be independant (own jar) so that it is available to the framework (user of plugin) and to the functional components. And the plugable component must not be on the java class path.
    This also means that we know for certain that the plugable component is also on the system class path. That is a bad idea as well.
    Given that it is pretty pointless to even speculate as to why this error is showing up. Create the correct jar layout. Test using the command line. Then test using servlets. Insure that the plugable jar is NOT on the java classpath for both tests.

  • Accessing Java Classes from Forms

    Is is possible to access a Java class from Forms? I have been
    creating an Active X control that returns a Java object, and from
    that I can call methods on that object, but I would really like
    to do that without having and Active X control in the mix. Any
    suggestions?
    null

    Oracle Developer Team wrote:
    : Robert Nocera (guest) wrote:
    : : Oracle Developer Team wrote:
    : : : hey robert -
    : : : Developer 6.0 provides this ability for web deployment.
    You
    : : can
    : : : insert your own custom Java components into your
    application
    : : and
    : : : they will appear in the application when it is run via the
    : web.
    : : : If you look at the documentation for 6.0, there are a few
    : : : section son Pluggable Java Components and JavaBeans that
    : : : describes what is provided and how you use the interfaces
    : and
    : : : classes we provide.
    : : : A whitepaper on this topic will be posted to the OTN
    : shortly,
    : : as
    : : : well as some samples that illustrate how to go about doing
    : it.
    : : : cheers!
    : : : -Oracle Developer Team-
    : : Thanks for the quick response. Is there any way to access
    : those
    : : classes without being in a web deployment. That's probably
    : not
    : : totally out of the question, but what we had in mind was
    : adding
    : : some Java Functionality (actually connectictivity to some
    EJBs
    : : that we have) to existing forms. Currently there forms are
    : not
    : : deployed in a "web" environment and are just run from the
    : forms
    : : runtime engine.
    : : -Rob
    : hey again robert -
    : there's no easy way (yet!) to call out from forms runtime
    : process to a Java application.
    : We've played around some with creating an ORA_FFI interface to
    : JNI and then wrappering this with PL/SQL code. We've been able
    : to make calling into an EJB running in 8i from a forms runtime
    : work using this approach.
    : Let me know if this is of interest to you and I can post the
    : stuff we've currently got. It's no more than a simple demo and
    : is not complete. It requires quite a bit of manual coding on
    : the PL/SQL side since the interface emulates JNI (FindClass,
    : GetMethodID, CallMethodID, etc.).
    : cheers!
    : -the Oracle Developer Team-
    I'd be interested in this ORA_FFI doc you've been playing with.
    Would you please email it to me or post it.
    null

  • In onLoad JavaScript, I'm getting "Error: Permission denied to access property 'classes'" when I access Components.classes; how do I enable that permission?

    I need to emulate several ActiveX functions in my client's web application. I have located several Mozilla web pages that describe how to do the things I need, and I have attempted to implement those instructions. However, I can't seem to get past the first line of code. In my web page, I am calling a JavaScript function using the onLoad attribute of the <body> tag. I am using the Navigator object to determine that the browser is Firefox. I then attempt to access the extension classes using the following code on lines 51 and 52 of the Download.js file:
    var C = Components;
    var CC = C.classes;
    The Web Console gives me these two messages:
    [13:51:55.621] The Components object is deprecated. It will soon be removed. @ http://distribution:781/NewDDI/DownLoad.js:51
    [13:51:55.621] Error: Permission denied to access property 'classes' @ http://distribution:781/NewDDI/DownLoad.js:52
    How do I enable adequate permission to be able to access the Components classes?

    I think Components is available only in extensions (or otherwise privileged code) and not in ordinary web pages.

  • Field symbols as Class Attributes

    Hello Gurus,
    Is anybody able to say to me if it is possible to declare field symbols as class attributes? As I can understand until now, this is not possible and we need to use some attribute with the "TYPE REF TO Data" to get the information we need. Correct?
    Thanks,
    Daniel.

    Ok, let me see if someone can give me some idea on how to improve my method:
    Method: PREPARE_PTOOL_DATA
    Parameters specification:
    Parameter        Type     Typing     Reference Type
    PF_ANALYSIS        Importing     Type     /SYM/SC_PT_ID_ANALYSIS_D
    PF_ANAL_DESC        Importing     Type     /SYM/SC_NM_DESC_ANALYSIS
    PF_LOGIC        Importing     Type     CHAR01
    PF_MATERIAL        Importing     Type     MATNR
    PF_MAKTX        Importing     Type     MAKTX
    PT_DATA_COMPA        Exporting     Type     /SYM/SC_TAB_PT_RESULT_CP
    PT_CALC_ANALY        Exporting     Type     /SYM/SC_TAB_PT_RESULT_CA
    PT_DATA_MATERIAL1 Changing     Type     /SYM/SC_TAB_PROC_ALLERG_RESULT
    PT_DATA_MATERIAL2     Changing     Type     /SYM/SC_TAB_PROC_ALLERG_RESULT
    Source code:
    From the /SYM/SC_CL_PROCESS_ALLERG_GEN class
    Old version (but it is working)
    METHOD prepare_ptool_data.
      DATA: ls_data_material1   TYPE /sym/sc_s_proc_allerg_result,
            ls_data_material2   TYPE /sym/sc_s_proc_allerg_result,
            lf_index_material1  TYPE sy-tabix,
            lf_index_material2  TYPE sy-tabix,
            ls_result_cp        TYPE /sym/sc_pt_result_cp,
            ls_result_ca        TYPE /sym/sc_pt_result_ca.
    Prepare data for Data Comparison step
      IF pt_data_compa IS REQUESTED.
        LOOP AT pt_data_material1 INTO ls_data_material1.
          lf_index_material1 = sy-tabix.
          CLEAR ls_result_cp.
          MOVE pf_analysis   TO ls_result_cp-analysis.
          MOVE pf_anal_desc  TO ls_result_cp-desc_analysis.
          MOVE ls_data_material1-algbe TO ls_result_cp-desc_property.
    If Logic 'A', move the text from ls_data_material1 to original
    material status
          IF pf_logic EQ c_logic_a.
            MOVE ls_data_material1-agsbe TO ls_result_cp-val_orig_matnr.
    If Logic 'B', move the text from ls_data_material1 to "toy"
    material status
          ELSEIF pf_logic EQ c_logic_b.
            MOVE ls_data_material1-agsbe TO ls_result_cp-val_toy_matnr.
          ENDIF.  " IF pf_logic EQ c_logic_a.
    Read the lt_data_toy by the Allergen ID (ALGEN)
          CLEAR ls_data_material2.
          READ TABLE pt_data_material2 INTO ls_data_material2
                WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
          IF sy-subrc EQ 0.
            lf_index_material2 = sy-tabix.
    If Logic 'A', move the text from ls_data_material2 to "toy°
    material status
            IF pf_logic EQ c_logic_a.
              MOVE ls_data_material2-agsbe TO ls_result_cp-val_toy_matnr.
    If Logic 'B', move the text from ls_data_material2 to original
    material status
            ELSEIF pf_logic EQ c_logic_b.
              MOVE ls_data_material2-agsbe TO ls_result_cp-val_orig_matnr.
            ENDIF.  " IF pf_logic EQ c_a.
    Delete record from lt_data_toy, index lf_index_toy
            DELETE pt_data_material2 INDEX lf_index_material2.
          ENDIF.  " IF sy-subrc EQ 0.
          APPEND ls_result_cp TO pt_data_compa.
    Delete record from lt_data_orig, index lf_index_orig
          DELETE pt_data_material1 INDEX lf_index_material1.
        ENDLOOP.  " LOOP AT lt_data_material1 INTO ls_data_material1.
      ENDIF.  " IF pt_data_compa IS REQUESTED.
    Prepare data for Calculation Analysis step
      IF pt_calc_analy IS REQUESTED.
        LOOP AT pt_data_material1 INTO ls_data_material1.
          lf_index_material1 = sy-tabix.
          CLEAR ls_result_ca.
          MOVE pf_material   TO ls_result_ca-matnr.
          MOVE pf_maktx      TO ls_result_ca-maktx.
          MOVE pf_analysis   TO ls_result_ca-analysis.
          MOVE pf_anal_desc  TO ls_result_ca-desc_analysis.
          MOVE ls_data_material1-algbe TO ls_result_ca-desc_property.
    If Logic 'A', move the text from ls_data_material1 to original
    material status
          IF pf_logic EQ c_logic_a.
            MOVE ls_data_material1-agsbe TO ls_result_ca-val_curr_stat.
    If Logic 'B', move the text from ls_data_material1 to "toy"
    material status
          ELSEIF pf_logic EQ c_logic_b.
            MOVE ls_data_material1-agsbe TO ls_result_ca-val_simul_stat.
          ENDIF.  " IF pf_logic EQ c_logic_a.
    Read the lt_data_toy by the Allergen ID (ALGEN)
          CLEAR ls_data_material2.
          READ TABLE pt_data_material2 INTO ls_data_material2
                WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
          IF sy-subrc EQ 0.
            lf_index_material2 = sy-tabix.
    If Logic 'A', move the text from ls_data_material2 to "toy°
    material status
            IF pf_logic EQ c_logic_a.
              MOVE ls_data_material2-agsbe TO ls_result_ca-val_simul_stat.
    If Logic 'B', move the text from ls_data_material2 to original
    material status
            ELSEIF pf_logic EQ c_logic_b.
              MOVE ls_data_material2-agsbe TO ls_result_ca-val_curr_stat.
            ENDIF.  " IF pf_logic EQ c_a.
    Delete record from lt_data_toy, index lf_index_toy
            DELETE pt_data_material2 INDEX lf_index_material2.
          ENDIF.  " IF sy-subrc EQ 0.
          APPEND ls_result_ca TO pt_calc_analy.
    Delete record from lt_data_orig, index lf_index_orig
          DELETE pt_data_material1 INDEX lf_index_material1.
        ENDLOOP.  " LOOP AT lt_data_material1 INTO ls_data_material1.
      ENDIF.  " IF pt_calc_analy IS REQUESTED.
    ENDMETHOD.
    As you can see, I am repeating almost the same code, just changing some items. I am not sure if I can use new parameters (ANY or ANY TABLE) but, my first idea to improve it was to use the field-symbols (and it works ok). The issue is that I have to repeat the assignment lines every same named method of the classes I am changing (I would like to do the assignment into a new method of the superclass). Do you think it is possible or should I give up and proceed with the assignments locally, for each same named method of each class?
    Thanks,
    Daniel.

  • Inner classes in my interface - ok, no k, indifferent?

    I have an interface and a set of ComparatorS which are only used for objects which implement the interface. So I put the ComparatorS in the interface like so (not actual code because it is for my job):
    public interface Abc {
      //Class loader should only do this once so they are basically singleton constants
      public static final Comparator C_1 = new C1();
      public static final Comparator C_2 = new C2();
      //... there is one more
      public String getSomething();
      public String getSomethingElse();
      //First Comparator inner class
      public class C1 implements Comparator {
         private C1(){ }
         //implements appropriate methods checking for instanceof Abc in the compareTo method
        //Compares something (using getSomething())
      /* Second Comparator inner class */
      public class C2 implements Comparator {
        //same thing
        //Compares somethingElse (using getSomethingElse())
    } //End interfaceUsage:
    Set s = new TreeSet(Abc.C_1);
    s.add(abc1);Because the Comparator implementations were specific to objects which implement the interface I felt that was the best way to make that fact clear. If they were over in a separate package it would be confusing that these are for the one interface. If they were in the same package as Abc it wouldn't fit (IMO) because they are more utility type classes.
    So it was either that or make them a singleton in their own class files or something like this and I found myself liking this.
    Any comments on pros/cons of doing it this way?

    I'm confused as to why it would make sense to put the
    Comparators 'in' the interface but not in the package
    with the interface. You can't put them 'in' the
    interface without putting them in the package. In
    reality, nesting them in the interface just creates
    classes in the interface's package.My whole deal is that after talking it out I see that it is bad for reuse to have something which could be so generic residing in a particular interface (and therefore deduced soon after that in the same package as my interface). Which made me decide not to have the inner classes because it IS in the same package at that point. But I am saying that is bad. As I tried to state before, for the same reason I now think it is bad to have the classes in the interface (not much i.e. no reuse outside of the interface) then it is bad to have it in the same package as the interface (unelegant reuse outside of the package). Because if the getSomething() is getName() that could be used as a comparator for many different objects in different packages. I don't want to limit. This stance was a progression, once I decided not in the interface, I then also decided not in the same package.
    Java is strongly typed. If the class isn't an
    instance of the class you are casting to (in this
    case the interface) it doesn't matter if it has a
    method with the same signature. The cast will fail.Yes, of course, but like generics, you are not limited to just one type (Object is the type of the parameter). So I can either use instanceof before casting (not the best way) or I could have private overloads of the compareTo() method, a new one for every type I support and each supported type which has a getName() could come from a couple different packages. Not that generics does it the same way but on top of being about to declare hierachies that a genericized object can deal with you can also have comma delimitted other objects. They don't have to be related by package or hierarchy in generics. So I don't think it would be so bad for my Comparator to be (if it fit that these different types all had the same method needed by my Comparator).
    >>
    Here's anothe reason not to do that. Let's say that
    someone is using the interface. They need to compare
    it to something else, if the Comparators are right
    there with the interface, they will be likely to find
    them. If they are in some other package, they'd have
    to know where to go look for them.If that is the case, where I was worried about easy to find then I would go back to using inner classes with each Comparator as a constant. If I was worried about ease of finding where these ComparatorS are over code reuse across packages.
    I mean, I think if I am going to tie the ComparatorS so close to a particular Type then I am going to add it as an inner class whether my type was an interface or a class. At least that is what I am thinking now.
    >
    This is what I am talking about. So many Java
    developers treat packages like filing cabinets. I
    put things that do this here and things that do that
    there. But this is actually not very useful and it
    hamstrings your designs.
    Java doesn't have a friend class syntax like C++. So
    there's no way to say this class over here has access
    to this but no one else does. These kinds of
    relationships are very desireable. Some classes will
    need to access things in another class that shouldn't
    be public. You can do this cleanly if they ae in the
    same package but not otherwise.But I am not talking about taking an abstract class putting it in pack1 an a subclass in pack2. I am talking about putting a utility class that could eventially work on 50 classes in a place that is playingfield neutral and not in the original type it deals with today only. I am dealing with public accessor methods on my objects.
    >
    For example. Let's say you want to create a Factory
    (I'm using Factory in a loose way here not
    necessarily a GoF Pattern) for a public class. You
    don't want every class to have access to contructor
    because it creates the Object without initializing
    all the necessary atttributes. The factory is
    specially crafted to do this with protected info and
    access rights. If you put the class and the factory
    together it;s a snap. You create a package-protected
    constructor, some package-protected methods and/or
    fields and do it. No class outside the package will
    be able to do these dangerous operations. How do you
    do this if you have a factory package and a data
    object package?That is a whole nother situation I think. In that case it is obvious. I thought my situation was a little less obvious because of the utility nature of the classes (ComparatorS) that I was dealing with.

  • Binding ABAP Class Attribute with BUS2038 in a Standard WF task

    Hi,
    I need help as mentioned in the subject line.
    In my standard task I am capturing event for BUS2038. In the General tab I have a ABAP class which has implemented IF_WORKFLOW. From BUS2038 I just need notification number.
    Since my source is a BO and my target is a class. How do I make this conversion and pass the data to my class?
    I know there are several solution but none have solved my concern.
    Thanks,
    Sridhar Karra.

    Hi,
    If you want to access teh attributes of the BOR inside a class emthod then you have to make use of teh MACROS.
    1. include INCLUDE CNTN01_SWC  in the class local macros section. and in the type groupsof the class include SWC0.
    2. Now if you know the key of the BOR instance then create a BOR object inside the class method as below
    DATA lo_object   TYPE SWC0_OBJECT.
    SWC0_CREATE_OBJECT lo_object '<BUSXXXX>' '<Key of the BOR>.
    the above line will create the instance of the bor inside the class method
    now inorder to access the attributes of the BOR  use the below code
    DATA lv_notif_no   TYPE  <type of the notification>.
    SWC0_GET_PROPERTY lo_object '<ATTRIBUTE NAME> lv_notif
    In this way you can access the BOR attributes inside a class method.
    Regards
    Pavan
    Edited by: Pavan Bhamidipati on Dec 15, 2011 11:01 PM

Maybe you are looking for

  • Corrupting the block to continue recovery in physical standby

    Hi, Just like to inquire how I will be able to corrupt the block to be able to continue the recovery in the physical standby. DB Version: 11.1.0.7 Database Type: Data Warehouse The setup we have is primary database and standby database, we are not us

  • Media via Macbook Mirroring not working!

    Up until now my Apple TV (Third Generation) has been working like a charm. However, a problem arose today when I was using the mirrroring option on my 2012 Macbook Pro. Mirroring was working fine up until I tried to play any sort of media, whether it

  • Content Activation Problem

    Hi, I have a problem in activation business content for some BI infoobjects. We have upgraded from BI 3.5 to 7.0. But some of the objects are not activated. So i was trying to reactivate them and following are my concerns. If i consider revised versi

  • Create Type NI_MultipleNumericLimitTest for local variable

    I am using  Multiple numeric test in my seq &  documenting in case of   Seq fail i.e when the  value is not in the limits I am using for-each-loop step type for this I want  a Local variable  of type  NI_MultipleNumericLimitTest      in my foreach (c

  • On my Mac, on my folder I don´t have the library folder as I should ???!!!!

    on my Mac, using the Finder, on my folder, I don´t have the library folder as I should. I think it is strange. When I go to the time machine, the Library folder it is there, but the folder has not the same colour as the other folders (it is light gre