Dynamic creating SAPBobsCOM objects using reflection

Hi All,
I'm writing a tool (C#) for SBO for exporting object (oItems, oBanks etc.) to XML files. And I have a problem how to dynamically create object by it's string description. I'm trying to create it using System.Reflection, but cant't find right way to create it.
It must be like that, but it doesn't work:
           Type  sboObject = System.Type.GetType("SAPbobsCOM.Items, Interop.SAPbobsCOM", true, true);
           object ibaseObject = Activator.CreateInstance(sboObject);
Any ideas?)

Hi
I've writen this code for instantiating DI API objects using .NET reflection
        private object getObjectBo(int tipo) //tipo: integer representing the object type
            object o = null;
            try
                Type tipoComp = kernel.Company.GetType(); //Type SAPbobsCOM.Company
                MethodInfo info = tipoComp.GetMethod("GetBusinessObject");
                object[] parametros = new object[1]; //Parameters of GetBusinessObject
                object tipoObj = Enum.ToObject(typeof(SAPbobsCOM.BoObjectTypes), tipo);
                parametros[0] = tipoObj;
                o = info.Invoke(kernel.Company, parametros);  //Calling GetBusinessObject           
            catch (Exception ex)
                kernel.Application.MessageBox(ex.Message, 0, "", "", "");
            return o;
The object returned is COM object (not managed code) then we can't use .NET reflection directly for exploring its methods and attributes .. I think we should use C++ and IDispatch interface, but i don't know how do this yet.
Hope it helps.
Regards

Similar Messages

  • How to create an array using reflection.

    How to create an array using reflection.
    I want to achive something like this,Object o;
    o = (Object)(new TestClass[10]);but by use of reflection.
    To create a single object is simple:Object o;
    o = Class.forName("TestClass").newInstance();But how do I create an array of objects, when the class of objects is known only by name? (Can't use Object[] because even though an Object[] array can be filled with "TestClass" elements only, it Cannot be casted to a TestClass[] array)
    Anybody knows?":-)
    Ragnvald Barth
    Software enigneer

    Found it!
    the java.lang.reflect.Array class solves it!
    Yes !!!

  • Create another object using the same container generated by a split...

    Hi SapGears!
    I'm facing a problem about creating an object using a splited container.
    I split the container A in containers A1 and A2 and create alv in A1 and html in A1.
    After that, i need to create a toolbar buttons using the class cl_gui_toolbar in A2 without need to recreate all again.
    I Try to call method free( ) and recreate the object, but the container A2 appears in blank.
    any help will be very nice!!!

    I would try different solution. Split A2 into two new rows B1 and B2. In B1 set your toolbar, in B2 your alv. By default set B1 cell hidden
    "suppress splitter bar
    CALL METHOD gr_splitter_cont->set_row_sash
        EXPORTING
          id    = 1
          type  = gr_splitter_cont->type_movable
          value = gr_splitter_cont->false.
    "show only alv in entire cell
      CALL METHOD gr_splitter_cont->set_row_height( id = 1 height = 1000 ).
    Now when you request for toolbar display only that cell
        CALL METHOD gr_splitter_cont->set_row_height( id = 1 height = 0 ).
    A kind of workaround but you will avoid much troubles.
    Regards
    Marcin

  • Creating objects using reflection

    Hi,
    I need to construct a new instance using reflection and passing parameters. If the parameters are of primitive type ex. int, how can I pass them in the Class[] type of object

    Integer.TYPE, etc. are Class objects that represent the types of the primitives.

  • Dynamic Creation of Objects using Tree Control

    I am able to Create Dynamic Objets using List control in
    flex,but not able to create objects using TreeControl,currently iam
    using switch case to do that iam embedding source code please help
    me how to do that
    <?xml version="1.0" encoding="utf-8"?>
    <!--This Application Deals With How to Create Objects
    Dynamically -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:XML id="treeDP">
    <node label="Controls">
    <node label="Button"/>
    <node label="ComboBox"/>
    <node label="ColorPicker"/>
    <node label="Hslider"/>
    <node label="Vslider"/>
    <node label="Checkbox"/>
    </node>
    </mx:XML>
    <mx:Script>
    <![CDATA[
    import mx.core.UIComponentGlobals;
    import mx.containers.HBox;
    import mx.controls.*;
    import mx.controls.VSlider;
    import mx.controls.Button;
    import mx.controls.Alert;
    import mx.core.UIComponent;
    import mx.controls.Image;
    import mx.managers.DragManager;
    import mx.events.DragEvent;
    import mx.controls.Tree;
    import mx.core.DragSource
    import mx.core.IFlexDisplayObject;
    /*This function accepts the item as on when it is dragged
    from tree Component */
    private function ondragEnter(event:DragEvent) : void
    if (event.dragSource.hasFormat("treeItems"))
    DragManager.acceptDragDrop(Canvas(event.currentTarget));
    DragManager.showFeedback(DragManager.COPY);
    return;
    else{
    DragManager.acceptDragDrop(Canvas(event.currentTarget));
    return;
    /*This Function creates objects as the items are Dragged
    from the TreeComponent
    And Creates Objects as and When They Are Dropped on the
    Container */
    private function ondragDrop(event:DragEvent) : void
    if (event.dragSource.hasFormat("treeItems"))
    var items:Array =event.dragSource.dataForFormat("treeItems")
    as Array;
    for (var i:int = items.length - 1; i >= 0; i--)
    switch(items
    [email protected]())
    case "Button":
    var b:Button=new Button();
    b.x = event.localX;
    b.y = event.localY;
    b.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
    myCanvas.addChild(b);
    break;
    case "ComboBox":
    var cb:ComboBox=new ComboBox();
    myCanvas.addChild(cb);
    cb.x = event.localX;
    cb.y = event.localY;
    cb.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
    break;
    case "ColorPicker":
    var cp:ColorPicker=new ColorPicker();
    myCanvas.addChild(cp);
    cp.x = event.localX;
    cp.y = event.localY;
    cp.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
    break;
    case "Vslider":
    var vs:VSlider=new VSlider();
    myCanvas.addChild(vs);
    vs.x = event.localX;
    vs.y = event.localY;
    vs.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
    break;
    case "Hslider":
    var hs:HSlider=new HSlider();
    myCanvas.addChild(hs);
    hs.x = event.localX;
    hs.y = event.localY;
    hs.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
    break;
    case "Checkbox":
    var check:CheckBox=new CheckBox();
    myCanvas.addChild(check);
    check.x = event.localX;
    check.y = event.localY;
    check.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
    break;
    else {
    var Component:UIComponent =
    event.dragSource.dataForFormat("items") as UIComponent ;
    Component.x = event.localX;
    Component.y = event.localY;
    Component.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
    myCanvas.addChild(Component);
    /*How to move the Objects within the Container */
    public function mouseMoveHandler(event:MouseEvent):void{
    var
    dragInitiator:UIComponent=UIComponent(event.currentTarget);
    var ds:DragSource = new DragSource();
    ds.addData(dragInitiator,"items")
    DragManager.doDrag(dragInitiator, ds, event);
    ]]>
    </mx:Script>
    <mx:Tree dataProvider="{treeDP}" labelField="@label"
    dragEnabled="true" width="313" left="0" bottom="-193" top="0"/>
    <mx:Canvas id="myCanvas" dragEnter="ondragEnter(event)"
    dragDrop="ondragDrop(event)" backgroundColor="#DDDDDD"
    borderStyle="solid" left="321" right="-452" top="0"
    bottom="-194"/>
    </mx:Application>
    iwant to optimize the code in the place of switch case
    TextText

    Assuming your objects are known and what you need are simply
    variable names created by the program, try using objects as
    associative arrays:
    var asArray:Object = new Object();
    for (var n:int = 0; n < 10; n++) {
    asArray["obj" + n] = new WHAT_EVER();

  • Events from dynamically created CNiGraph object

    Hi,
    My application requires me to create a variable number of CNiGraph objects at runtime. I'm plotting data from a file and I don't know in advance how many variables there will be. So, I'm dynamically creating the graph objects in the OnInitDialog() method of my CView derived class. The thing I'm stuck on is how to get the various messages from the graph when it is created dynamically like this. I can't use Class Wizard for the message maps because the number is variable. I suppose I could create a bunch of static message maps (more than I think I would ever need), but is there a cleaner way to do this? I'm using Visual C++ 6.0.
    Thanks, Bob

    Ok, I figured it out. You need to change the event sink map to use the ON_EVENT_RANGE instead of ON_EVENT. The help for ON_EVENT_RANGE tells you all you need to know.

  • Not able to create an object using dbms_metadata.put function

    Hi,
    I have the metadata of an object in one of my database table as xml. I failed to recreate the object in the other schema using metadata api. I developed a stored function to do the above job. My function doesn't throw any error meanwhile it doesn't create the object.
    My code snippet is
    CREATE OR REPLACE PROCEDURE DDI.move_table(
    table_name in VARCHAR2,
    from_schema in VARCHAR2,
    to_schema in VARCHAR2 )
    AUTHID CURRENT_USER
    IS
    -- Define local variables.
    h1 NUMBER; -- handle returned by OPEN
    h2 NUMBER; -- handle returned by OPENW
    th1 NUMBER; -- handle returned by ADD_TRANSFORM for MODIFY
    th2 NUMBER; -- handle returned by ADD_TRANSFORM for DDL
    xml XMLTYPE; -- XML document
    errs sys.ku$_SubmitResults := sys.ku$_SubmitResults();
    err sys.ku$_SubmitResult;
    result BOOLEAN;
    BEGIN
    SELECT REPOS INTO xml from ddi.ddi_repos_t where obj_id = '1801';
    -- Specify the object type using OPENW (instead of OPEN).
    h2 := DBMS_METADATA.OPENW('TABLE');
    -- First, add the MODIFY transform.
    th1 := DBMS_METADATA.ADD_TRANSFORM(h2,'MODIFY');
    -- Specify the desired modification: remap the schema name.
    DBMS_METADATA.SET_REMAP_PARAM(th1,'REMAP_SCHEMA',from_schema,to_schema);
    -- Now add the DDL transform so that the modified XML can be
    -- transformed into creation DDL.
    th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'DDL');
    -- Call PUT to re-create the object.
    result := DBMS_METADATA.PUT(h2,xml,0,errs);
    DBMS_METADATA.CLOSE(h2);
    IF NOT result THEN
    -- Process the error information.
    FOR i IN errs.FIRST..errs.LAST LOOP
    err := errs(i);
    FOR j IN err.errorLines.FIRST..err.errorLines.LAST LOOP
    dbms_output.put_line(err.errorLines(j).errorText);
    END LOOP;
    END LOOP;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    RAISE_APPLICATION_ERROR(-20510,'No xml is available as metadata');
    END;
    Could you tell me where is the probelm?
    The schema where i created and execute my function having dba privilege also.
    Regards,
    Madhavi.

    Hi Madhavi,
    The below code works for me:
    SQL> conn sys as sysdba
    Connected.
    SQL> select count(*) from dba_objects where object_name = 'DEPT' and owner = 'OE';
      COUNT(*)                                                                     
             0                                                                     
    SQL> CREATE OR REPLACE PROCEDURE move_table(
      2  table_name in VARCHAR2,
      3  from_schema in VARCHAR2,
      4  to_schema in VARCHAR2 )
      5  AUTHID CURRENT_USER
      6  IS
      7  -- Define local variables.
      8  h1 NUMBER; -- handle returned by OPEN
      9  h2 NUMBER; -- handle returned by OPENW
    10  th1 NUMBER; -- handle returned by ADD_TRANSFORM for MODIFY
    11  th2 NUMBER; -- handle returned by ADD_TRANSFORM for DDL
    12  xml clob; -- XML document
    13  errs sys.ku$_SubmitResults := sys.ku$_SubmitResults();
    14  err sys.ku$_SubmitResult;
    15  result BOOLEAN;
    16  BEGIN
    17 
    18  select DBMS_METADATA.GET_XML('TABLE','DEPT','SCOTT') into xml from dual;
    19 
    20  -- Specify the object type using OPENW (instead of OPEN).
    21  h2 := DBMS_METADATA.OPENW('TABLE');
    22 
    23  -- First, add the MODIFY transform.
    24  th1 := DBMS_METADATA.ADD_TRANSFORM(h2,'MODIFY');
    25 
    26  -- Specify the desired modification: remap the schema name.
    27  DBMS_METADATA.SET_REMAP_PARAM(th1,'REMAP_SCHEMA',from_schema,to_schema);
    28 
    29  -- Now add the DDL transform so that the modified XML can be
    30  -- transformed into creation DDL.
    31  th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'DDL');
    32 
    33  -- Call PUT to re-create the object.
    34  result := DBMS_METADATA.PUT(h2,xml,0,errs);
    35 
    36  DBMS_METADATA.CLOSE(h2);
    37  IF NOT result THEN
    38 
    39  -- Process the error information.
    40  FOR i IN errs.FIRST..errs.LAST LOOP
    41  err := errs(i);
    42  FOR j IN err.errorLines.FIRST..err.errorLines.LAST LOOP
    43  dbms_output.put_line(err.errorLines(j).errorText);
    44  END LOOP;
    45  END LOOP;
    46  END IF;
    47  EXCEPTION
    48  WHEN NO_DATA_FOUND THEN
    49  RAISE_APPLICATION_ERROR(-20510,'No xml is available as metadata');
    50  END;
    51  /
    Procedure created.
    SQL> exec move_table('DEPT','SCOTT','OE');
    PL/SQL procedure successfully completed.
    SQL> select count(*) from dba_objects where object_name = 'DEPT' and owner = 'OE';
      COUNT(*)                                                                     
             1                                                                     
    SQL> spool off;The xml returned by the get_xml function contains the tablespace name and storage parameters of the schema in which the object is present.
    Check these parameters for both your schemas.

  • Dynamically create Value Objects from XML file

    Hi
    I want to create a value object from Xml file dynamically,like in the xml file i have the name of the variable and the datatype of the variable.is it possible do that,if so how.

    Read about apache's Digester tool. This is part of the Jakartha project. This tool helps in creating java objects from the XML files. I am not sure, if that is what u r looking for.

  • Can you create 3D object using Repousse w/ front and back Inflation w/o seam?

    Greetings. I have created a 3d object using repousse in Photoshop (CS5 extended). The original 2d image is circular. I used the Magic Wand Tool to select the 2d image, then 3D/Repousse/Current Selection to create, selecting the inflate (rounded) Repousse Shape Preset with the Depth of 0. It creates the object as expected, except the front-and-back seam has minor irregularities leaving the object with an uneven seam (see image below). The original 2d image was created in Illustrator using the eliptical tool, so it is as regular as possible. I want it to be seamless. The image below shows the rotated object and the very distinct seam.
    Any ideas on how to get rid of, or avoid, that seam?  Thanks much.

    What you could try is downloading the report to the client pc using WEBUTIL_FILETRANSFER.URL_TO_CLIENT, then open the locally save file using something like:
    CLIENT_HOST('cmd /c rundll32.exe url.dll,FileProtocolHandler "localfilename"');

  • Can't able to create callable object using UI pattern in CAF

    Hello
    I made one interface using object Selection UI pattern for one of my entity services. Now i am trying to make a callable object using this and i also have been successfully created it. But when I test this callable object, I got these error messages.
    1. Could not load execution container: Cannot access object class loader for deployable object sap.com/cafcoregpuivisibleco~container.
    2. Could not load execution container: ComponentUsage(container): Active component must exist when getting interface controller. (Hint: Have you forgotten to create it with createComponent()? Should the lifecycle control of the component usage be "createOnDemand"?
    Please tell me the problem

    Hi Saurabh,
    It seems you found a bug. The problem is that runtime library reference to sap.com/cafruntimeuicouplingapilib library from sap.com/cafcoregpuivisibleco~container dc is misspelled.
    So, I don't know whether or not according CSN is already created but I can propose you a solution.
    1. Unpack the cafcoregpuivisibleco~container archive from CAFKM0X_0.sca sca.
    2. Unpack sap.comcafcoregpuivisiblecocontainer.wda archive.
    3. Open the PORTAL-INF\portalapp.xml file and change the following entry of library reference:
    <property name="LibrariesReference" value="sap.com/cafruntimeuicopulingapilib" />
    to
    <property name="LibrariesReference"    value="sap.com/cafruntimeuicouplingapilib"/>And pack
    it pack it again in correct order(for ex.:
    jar.exe -Mcvf sap.comcafcoregpuivisiblecocontainer.wda .
    jar.exe -Mcvf sap.comcafcoregpuivisiblecocontainer.sda .
    And finally deploy it to your server instance and enjoy.
    Best regards,
    Aliaksei

  • Problem creating Cipher object using getInstance

    Hi all, Can anyone please help me with this? I am using jdk1.4 which has jce. I have put jce.jar jars in classpath. When I create Cipher object like
    Cipher itsocipher1 = Cipher.getInstance("DES");
    it compiles fine but when I exicute it get following error java.lang.NoSuchMethodError at javax.crypto.SunJCE_d.a(DashoA6275) at javax.crypto.SunJCE_d.a(DashoA6275) at javax.crypto.SunJCE_d.verify(DashoA6275) at javax.crypto.SunJCE_b.f(DashoA6275) at javax.crypto.SunJCE_b.<clinit>(DashoA6275) at javax.crypto.Cipher.getInstance(DashoA6275) at EncryptDecrypt.main(EncryptDecrypt.java:26) Please Guide. Thanks.

    Copy the jce provider's jar file ( if using SunJCE, then copy sunjce_provider.jar file) to jre's lib/ext directory.
    You can also see in the java.policy file where the jvm is looking for the jar files.
    grant codeBase "file:${java.home}/lib/ext/*" {
    permission java.security.AllPermission;
    };

  • How to create an object using sql*plus?

    Hi,
    I have tried to create an object , but after pressing enter key I could not get SQL command prompt or errors. How to come out from this? Could you help me to find what's wrong.
    SQL> create type course as object(
    2 course_no number(4),
    3 title varchar(35),
    4 credits number(1));
    5
    6
    7
    8
    Thanks.

    Put a slash "/" at the end of the command:
    CREATE TYPE course AS OBJECT (
       course_no   NUMBER (4),
       title       VARCHAR (35),
       credits     NUMBER (1)
    /

  • Is there a way to create an object using Trapcode Form and then use that object as a particle in Trapcode Particular?

    I made some objects in Cinema 4D and I tried to import them into After Effects CC 2014.  I get an error saying 'Cannot find Adobe Premiere Pro Dynamic Link'.  So I tried it in AE CC and that worked.  However, I want to create a form object and then use that as a particle for Trapcode Particular.  Is this even possible?
    Thank you for any help!

    There are also size limitations or rather suggestions for particle size. If I were creating an animated 3D shape using Form or C4D and wanted to use it as a particle I would keep the size of the particle about 1/6 to 1/8 of the comp size. You would create a new comp for your particle, animate it, then nest the particle comp in your main comp, turn off visibility, and then use it as a particle in Particular.

  • Dynamically Creating Sub Folders using ECMA

    Hi,
    I have a requirement to create a a folder and then  a sub folder in that and set its Name and Title dynamically. I am able to crate the folder however not the sub folder. Please suggest any technical way.
    Thanks,
    Debasis Roy

    No worries - I located another thread that provided the answer.  I rather think it may be better for me - with the number of folders and sub-folders I have in my Pictures Library - to use the tree facility under Folders in Organizer. 

  • Comparing dynamic fields of objects using equals and hashCode methods

    To compare the different objects of the same class with their contents like jobTitleId, classificationId, deptId & classificationId was to be done and do some manipulations later using Set and Map. I was able to do that by simply overriding the equals and hashCode methods of Object class and was able to fetch the information (like in the following Map).
        Map<LocationData, List<LocationData>>
    The following is the class I used (its been shown to you so that it can be referred for my problem statement):
    LocationData class
        package com.astreait.bulkloader;
        public class LocationData {    
            String locId, deptId, jobTitleId, classificationId;
            @Override  
            public boolean equals(Object obj) {        
                LocationData ld = (LocationData)obj;       
                return this.deptId.equals(ld.deptId) && this.jobTitleId.equals(ld.jobTitleId) && this.classificationId.equals(ld.classificationId) &&
        this.locId.equals(ld.locId);   
            @Override  
            public int hashCode() {        
                return deptId.hashCode() + jobTitleId.hashCode() + classificationId.hashCode() +locId.hashCode();  
    Problem:
    I'm already known to which all fields of this object I need to make the comparison.
    i.e I'm bound to use the variables named classificationId, deptId, jobTitleId & locId etc.
    Need:
    I need to customize this logic such that the fields Names (classificationId, deptId, jobTitleId & locId etc) can be pulled dynamically along with their values. So, as far as my understanding I made use of 2 classes (TableClass and ColWithData) such that the List of ColWithData is there in TableClass object.
    I'm thinking what if I override the same two methods `equals() & hashCode();`
    such that the same can be achieved.
        TableClass class #1
        class TableClass{
            List<ColWithData> cwdList;
            @Override
            public boolean equals(Object obj) {
                boolean returnVal = false;
                        // I need to have the logic to be defined such that
                        // all of the dynamic fields can be compared
                return returnVal;
            @Override
            public int hashCode() {
                int returnVal = 0;
                        // I need to have the logic to be defined such that
                        // all of the dynamic fields can be found for their individual hashCodes
                return returnVal;
    ColWithData class #2
        class ColWithData{
            String col; // here the jobTitleId, classificationId, deptId, locId or any other more fields info can come.
            String data; // The corresponding data or value for each jobTitleId, classificationId, deptId, locId or any other more fields.
    Please let me know if I'm proceeding in the right direction or I should make some any other approach. If it is ok to use the current approach then what should be performed in the equals and hashCode methods?
    Finally I need to make the map as: (Its not the concern how I will make, but can be considered as my desired result from this logic)
        Map<TableClass, List<TableClass>> finalMap;

    Hello,
    What is the relation with the Oracle Forms tool ?
    Francois

Maybe you are looking for

  • Error when personalizing page with new item created in VO extension

    I have created a VO extension successfully and now have an issue when creating the new item through personalization. I am pretty sure I know what I've done wrong when creating the new item but I now can't get into the screen to make a change. I get t

  • BPM Scenario

    Hi,     I am trying out an BPM scenario for an N:1 mapping,in which i'll be sending N number of 2 different structure of messages.The source file got picked from the Source.The SXMB_MONI describes that the "Message being sent",but i couldn't get at t

  • In Oracle RAC environment which is OLTP database? load balancing advantage.

    In Oracle RAC environment which is a OLTP database? List the options for load balancing along with their advantages.

  • Advanced ASA PAT configuration...

    I have a unique requirement for my ASA PAT configuration... By default a Cisco router running IOS will utilize the SAME port when creating a dynamic PAT. i.e. the inside hosts request, generates a dynamic PAT, where the requests source port, is the p

  • Cannot see photos on device

    I'm very new to blackberry, When I take a photo nothing shows in the camera pictures folder in media! Yet the number of photos I am able to take decreases! I do not have an sd card installed just using the phones memory. Thanks in advance Dave Solved