Finding a model node in runtime

Hi, I'm presently migrating a old application to webdynpro.
In that application, I have a FieldDescriptor, which has the information of which table to search in order to find the info to be displayed.
Concretely I have:
A class called BapiInfoField. This class has an attribute which is the name of a table. I need to retrieve the node associated to that table.
To resolve this, I thought about making a mapping between the old table name and the new one compatible to webdynpro.
On the other hand, I don't know how to fetch an node at runtime in webdynpro. The only way I do usually, is by using the "wdContect.node*" way. I know how to fetch elements in a node dynamically, but not the node itself.
I also found a function called "getChildNode(String arg0, int arg1)" in the wdContext class. Unfortunately, the function is undocumented.
If there's no appropriate getter function in webdynpro for my problem, I'll resolve by making a mapping between the string of the old table name, and a Method Object linked to the proper "node*" method.
Anyone has any suggestions?
Thanks in advance,
Alexis

Brrr...
I do not understand your requirements completely, but can provide some hints regarding getting nodes information at runtime.
First, you are misinformed: getChildNode is documented. First parameter is node name, second is index of parent element of subnode (i.e. index within "this" node).
Next, there are 2 different situations: you need only meta-information or you need physical data.
For first case:
  void traverse(final IWDNodeInfo parent)
       for (final Iterator i = parent.iterateChildren(); i.hasNext(); )
            final IWDNodeInfo child = (IWDNodeInfo)i.next();
            traverse( child );
  traverse( wdContext.getNodeInfo() );
For second case:
  void traverse(final IWDNodeElement parent)
       final IWDNode     nParent   = parent.node();
       final IWDNodeInfo niParent  = nParent.getNodeInfo();
       final int         idxParent = parent.index();
       for (final Iterator i = niParent.iterateChildren(); i.hasNext(); )
            final IWDNodeInfo child = (IWDNodeInfo)i.next();
            traverse( nParent.getChildNode( child.getName(), idxParent ) );
  void traverse(final IWDNode parent)
       for (int i = parent.size() - 1; i>= 0; i--)
            final IWDNodeElement element = parent.getElementAt( i );
                /* Workaround for singleton nodes */
                /* parent.setLeadSelection( i ) */
            traverse( element ); 
  traverse( wdContext.currentContextElement() );
Second case is quite "interesting": first, it will fails for singleton nodes with cardinality 0..n or 1..n (see commented workaround); second, it quite resource-consuming, namely, invokes all supply functions and populating all elements during traverse.
Hope this will serve you as good starting point
VS

Similar Messages

  • Creation of new element in Model Node

    Dear All,
    I am facing one problem, I have two  model node. I want to copy one model node to other model node.while copying its giving error saying the you can bind the element, coz target node doesn't have valid parent.
    Pl don't suggest me work on Value node.
    Can i create a element in model node at run time.
    Thanks & Regards
    Manoj Sahoo

    Hi Manoj,
                   Model node properties :
    1.A context model node makes a model object look like any other context node.  I.E. it gives the model object an API that is very similar to a value node.
    2.  A model node is not considered valid until it is bound to a corresponding model object.  Therefore, a model node always inherits its metadata from the model object to which it is bound.
    3. The element collection in a model node does not hold the actual runtime data!   Instead, it holds a list of references to the relevant model object instances.
    If u check the 2nd property, u will find the cause of ur exception. As u have already told, don't suggest to use value nodes, i don't have any other comment.
    regards
    Sumit

  • How to bindi a UI element to 2 model nodes different in the same view

    I want to know how I can bind a set of inputfields, in a form view, to 2 different model nodes ?
    <u>example:</u>
    Im working with 2 adaptional RFC, both working, in my Custom Context.
    Ztest_Search
    Ztest_Update
    In my ResultView I have 2 Model nodes (one for each RFC) I show a set of inputfields in a form view, binded to the Ztest_Search_output of Ztest_Search. This works.
    now I want to update the changes, but I can't find the ways of binding the same inputfields to my other Model node (Ztest_Update) in the context of ResultView.
    Note: If I create a duplicate set of inputfields , one for Ztest_Search binded to the Ztest_Update_output and the other to the Ztest_Update_Input Works. But I wanna avoid this duplicated set of inputfields.
    Thx

    Rodrigo,
    If I understood correctly, your problem is to get the data from the input fields which are bound to a
    model node, Ztest_Search_output and set it to the model node of another RFC, Ztest_Update.
    This can be done by getting the suitable values from the model attributes of Ztest_Search_output
    and setting it to Ztest_Update.
    <b>/**
    * valueOne, valueTwo are the name of the model   
    * attributes that are bound to the Input fields.
    */</b>
    String firstValue = wdContext.currentZtest_Search_outputElement
         ().get<valueOne>;
    String secondValue = wdContext.currentZtest_Search_outputElement
         ().get<valueTwo>;
    Ztest_Update_Input update = new Ztest_Update_Input();
    wdContext.nodeZtest_Update_Input().bind(update);
    <b>/*
    *<b>Zstructure is the structure of the model node under
    *Ztest_Update_Input to which the values have to be 
    *updated.</b>
    */</b>
    ZStructure structure = new ZStruture();
    structure.setValueOne(valueOne);
    structure.setValueTwo(valueTwo);
    update.addZStructure(structure);
    try
       update.execute();     
    catch (Exception ex)
       wdComponentAPI.getMessageManager().reportException(ex.getMessage(), false);                     
    wdContext.nodeZtest_Update_Output().invalidate();
    Bala

  • How to set value to Model Node of cardinality 0..N

    hi
    I am looking for a way to set value to a model node of cardinality 0..N
    i imported a WSDL into my applicaion , which has the following Node Structure.
    Context
    --- ModelNode_Request
          ---ModelNode2_Input
          ---ModleNode3_Roles  [ cardinality 0..n singleton 1..1]
               ****Model_Attribute RoleID     <<<<<<<<<<<<
               ****Model_Attribute SysID      <<<<<<<<<<<<
      ---ModelNode_Response
    i tried with the below code  but effort went in vain.
    i tried following ways to set the value but , i get Nullpointer expection error.
         wdContext.nodeRequest__SubmitRequest().nodeRequestDetails().nodeRoles().
              currentRolesElement().setRoleId("BASIC");
         wdContext.nodeRequest__SubmitRequest().nodeRequestDetails().nodeRoles().
              currentRolesElement().setSysId("R3_220");
    i aslo looked into the forum  https://www.sdn.sap.com/irj/scn/thread?messageID=2035342 but couldnt find any solid solution.
    It would be great if some one can throw some snippets on the same.
    Thanks
    Edited by: RR on Dec 22, 2008 5:48 PM

    Hi RR,
    As far as i know u can set model nodes and values nodes are different. whats shown in the link is for values node. u should do differently for model node..
        Since this is a model node...u first need to create an object of the node type. then create an arraylist for that and then add values..
    try this..
    // Create an object for structures in the node to be used
    Yweb_Po_Items objPOItems = null; // where Yweb_Po_Items is the structure of the node...
    // Create an abstractlist for structures in the RFC node to be used, if u are planning to give single or multiple rows (in node/table) as input to the RFC
    AbstractList POObjAbsList = new Yweb_Po_Items.Yweb_Po_Items_List();
    objPOItems = new Yweb_Po_Items();
    //    /set first set of values
    objPOItems.setColumn1(u201Cabcu201D); // here hard codede for example
    objPOItems.setColumn2(u201Cabcfghu201D);
    // add the object to the abstract list
    POObjAbsList.add(objPOItems);
    //    /set second set of values
    objPOItems.setColumn1(u201Cnewabcu201D);
    objPOItems.setColumn2(u201Cnewabcfghu201D);
    // add the object to the abstract list again
    POObjAbsList.add(objPOItems); // now u got 2 records
    // now set the abstractlist to the node in the RFC
    objGoodsReceiptPO.setPo_Items_In(POObjAbsList);
    Hope this information is useful...
    Thanks
    Md. Yusuf

  • Setting max length of the field when using Context Model Node

    I have created a model using Import Adaptive Web Service model option (a web service was a wrapper around SAP BAPI function module).
    There were no dictionary types created in the Local dictionary as a result of import.
    I have mapped the context of the controller to the model node.
    One of the fields in the model is name     CUSTOMER_NUMBER type string;
    Corresponding element in the wsdl of the web service is
    <xsd:element name="CUSTOMER_NUMBER" type="tns:char10" />
    I have created a view with the input filed mapped to the CUSTOMER_NUMBER field of the model node.
    When I type more than 10 chars into the field and hit the search button, I get a com.sap.dictionary.runtime.Ddcheck exception that the length of the field should be less than 10 chars.
    How can I set the max length of the field in design time to prevent runtime exception?
    Thanks,
    Julia

    Thank you for your reply.
    Java trim function will trim the white spaces only, not the characters.
    I can code check length functionality before calling execute function (the function that call the web service).
    I can also create a dictionary structure based on the model structure; create a context value node based on the dictionary structure and use WDCopyService API to move the data between value node and model node.
    I was looking for the best practice...
    When importing model based on Adaptive RFC, the dictionary structures are imported together with the model. This does not happen for Adaptive web service - hence there is a need to add coding for simple checks.
    Julia

  • Value Nodes vs. Model Nodes

    Hi,
    why model nodes have to be initialized via Service Controller and needs to be bound to a model class instance and value nodes don't need that?
    Thank you,
    Pietro

    Hi Pietro,
    A model node is similar to value node in respect to it's API.
    The main diff are:-
    Value node
    1.It maintains it's own elemnet collection,each element holding the actual runtime data.
    2.While creating new element for a value node ,the node can create element object using metadata stored within it.
    3.the children of a value node only be value nodes or value atrributes.It can't be a mix value and model nodes or attribute if the 
       parent is a value node.
    Model Node
    1.The element collection maintains by a model node is simply a collection of reference to model object instances.
    2.Actual runtime data is stored in model object, not in model node's element collection.
    Hope this will help you. if you want more check this.
    http://help.sap.com/saphelp_webas630/helpdata/en/b8/cd96edb9c8794aa362e6e8b4236a1f/frameset.htm
    Thanks & Regards,
    Bhargava.

  • How to find a nearest node in a spatial network?

    hi, friends,
    Are there any similar function as sdo_topp_map.get_nearest_work() in oracle network package?
    Now I only have a location rather than a node, are there any methods to find the nearest node in the network? so I could continue use SDO_NET_MEM.NETWORK_MANAGER.SHORTEST_PATH_DIJKSTRA() to ge the shortest path.
    Thanks!

    The network model network analysis comes since 11.1 or 11.2 with support for dynamic segmentation, meaning that the path analysis does not need to start or end at an explicit node, but can start or end anywhere on a link.
    This gives you 2 options either as you requested, search the closest node, if that is still what you are after
    Or
    From your point, find the nearest link, and the "projected" location of your point to that link. While doing so, you should get a measure (percentage factor between 0 and 1) which expresses the relative position on the link from the start point.
    For option 1. use the proposed solution from Farid
    For option 2. apply the same SDO_NN approach, but do that for the link table (finding the nearest link first), rather then the nearest node.
    Then you can get the measure using either:
    - http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_lrs_ref.htm#i85426
    SDO_LRS.FIND_MEASURE
    Or
    - http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11831/sdo_net_ref.htm#autoId55
    SDO_NET.GET_PERCENTAGE
    Or
    - http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11829/oracle/spatial/network/Link.html#computeDistanceRatio_double__double_
    computeDistanceRatio(double x, double y)
    With that measure you can apply the shortest path using the link Id and the additional measure factor as the start parameters:
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11829/oracle/spatial/network/NetworkManager.html#shortestPath_oracle_spatial_network_Network__int__double__int__oracle_spatial_network_NetworkConstraint_
    shortestPath(Network network, int startLinkID, double startPercentage, int endNodeID, NetworkConstraint constraint)
    Again, it all depends on what your use case is. I hope this helps.
    Luc

  • How to populate a Value Attribute of a Value Node inside Model Node

    Hello
    I have my context like this.
      Context
    ..          - ModelNode
    ....                      - Model Attr1
    ....                      - Model Attr2
    ....                      - Model Attr3
    ....                      - Model Attr4
    ....                      - Value Node
    ......                                  |
    ......                                   - Value Attr1
    Model Node is of Cardinality 0..N
    Value Node is of Cardinality 1..1
    I want to create multiple records in my Model Node and one record for every Model Node in Value Node.
    How to do this?
    All good suggestions are welcome.
    Regards,
    Shubham

    Hi Shubham,
    With your context structure the code will be
    for(int i = wdContext.nodeModelNode().size()-1 ; i>=0 ; i--)
        IPublic<comp name>.IModelNodeElement ele =   wdContext.nodeModelNode().getModelNodeElementAt(i);
        IPublic<comp name>.IValNodeElement valEle = wdContext.nodeModelNode().nodeValNode().createValNodeElement();
        valele.setValAttr("");
        ele.nodeValNode().addElement( valEle);
    Your val node should be non singleton (singleton property = false)
    Regards,
    Jaydeep

  • Need help to read model node input field attribute present in view - first time developer.

    Hello Experts,
    I am new to CRM Web UI development.
    Presently, I am trying to develop a Guided Activity Page having 2 views.
    First view has the field Business Partner Number, I have added model Node BuilHeader and the attribute BP_NUMBER while creation of the view.
    The Second View consists of 2 fields from the Model Node BuilHeader, namely First Name and Last Name.
    The requirement is to enter the BP Number on the first screen then click on the NEXT button from the Guided Activity buttons, on navigating to the Second View, the Names should auto-populate.
    I have Created both views and the GP page, the GP navigation is also happening. Initially the fields were showing Not Bound text in value, so I commented the line in GET_I and GET methods to enable the field and remove the Not Bound text. I have created a custom controller with BuilHeader
    I have tried doing this but facing the below problems :
    1) When I enter the BP number on the first view and press Enter, the value disappears. How to solve this ?
    2) Does clicking on the NEXT button on the GP Navigation trigger a Server Roundtrip ?
    3) How to read the context node value of BP Number entered on the first view and populate the Name fields on the second view.
    Please help.........

    you can take reference from from below code as in above case we use BuilHeaderAdvancedSearch search object, to get current entity.
    data:    query        TYPE REF TO cl_crm_bol_dquery_service,.
      query ?= me->typed_context->BuilHeaderAdvancedSearch->collection_wrapper->get_current( ).
    Do not remove code from getter setter of fields , it will not clear.
    Check with http://scn.sap.com/thread/3391203 , for basic understanding of UI.
    Regards,
    Harish Kumar

  • How can I create an element in the model node?

    Hi, Experts,
    I create a model node that name is containerNode in the contxt. Cadinility is: 1..n
    I write the code in the method:
      private String getDataForOutputTable( IWDNode wageTypePayslip, IWDNode containerNode ){
           String betrgSumStr = "";
         int index = 0;
         Vector containerVector = new Vector();
         int size = wageTypePayslip.size();
         IWDNodeElement element = containerNode.createElement();// The system report error when I run the application.
         BigDecimal betrgSum = new BigDecimal( 0 );
    I try to create a element in the containerNode, But the system report error when I run the application.
    java.lang.IllegalArgumentException: model object must not be null
         at com.sap.tc.webdynpro.progmodel.context.ModelNodeElement.<init>(ModelNodeElement.java:66)
         at besuretech.com.wdp.IPrivatePayDataDispView$IOContainerElement.<init>(IPrivatePayDataDispView.java:1537)
         at besuretech.com.wdp.IPrivatePayDataDispView$IContextNode.doCreateElement(IPrivatePayDataDispView.java:88)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.createElement(NodeInfo.java:884)
         at com.sap.tc.webdynpro.progmodel.context.Node.createElementInternal(Node.java:1351)
         at com.sap.tc.webdynpro.progmodel.context.Node.createElement(Node.java:1370)
         at besuretech.com.PayDataDispView.getDataForOutputTable(PayDataDispView.java:251)
         at besuretech.com.PayDataDispView.getAllData(PayDataDispView.java:196)
         at besuretech.com.PayDataDispView.onPlugPayListViewIn(PayDataDispView.java:154)
         at besuretech.com.wdp.InternalPayDataDispView.wdInvokeEventHandler(InternalPayDataDispView.java:391)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.navigate(ClientApplication.java:826)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.navigate(ClientComponent.java:881)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doNavigation(WindowPhaseModel.java:498)
    How can I create an element in the model node ?
    Best regards,
    tao

    Hi,
    You need to execute the model before creating the element.
    Regards
    Ayyapparaj

  • How can I create a model node in SAP Records Management

    Product: SAP Records Management
    Hi,
    I would like to create a model node in a record tree.
    I found in the function modul BAPI_RECORD_ADDELEMENT no entry for the creation of a model node. Only the instance and the structure node can create by this function modul.
    So, does anyone know a solution to create a model note?
    Regards,
    Thomas Fanninger

    Hi Thomas,
    it is not possible with the BAPI due to the piece of coding:
    case  myElementType.
            when glob_const_elem_type_instance.
              myRecordElement->Type_Set( if_srm_sp_record_element=>type_instance ).
              myRecordInstanceElement ?= myRecordElement.
              loop at element_sp_poid into myElementSpPoidWa.
                mySpPoidWa-id = myElementSpPoidWa-name.
                mySpPoidWa-value = myElementSpPoidWa-value.
                insert mySpPoidWa into table myElementSpPoidTab.
              endloop.
              myElementSpsId = sps_id.
              myElementPoid = myClientService->poid_get_instance( im_rms_id  = myRmsId
                im_sps_id  = myElementSpsId  im_sp_poid = myElementSpPoidTab ).
              myService->check_sp_connection( myElementPoid ).
              myRecordInstanceElement->poid_set( myElementPoid ).
            when glob_const_elem_type_folder.
              myRecordElement->Type_Set( if_srm_sp_record_element=>type_folder ).
            when others.
              perform set_error using '852' return.
              return.
          endcase.
    But you can do that by using directly the Records API. How to use this is demonstrated in the report 'SRM_RECORD_API_HOWTO'. Search there for the subroutine 'fillrecordelement'. There a record element for insert is created and its type is set. You can set the type there to 'IF_SRM_SP_RECORD_ELEMENT~TYPE_MODEL'. Of course your POID then may not be an instance POID.
    Best regards,
    Thomas

  • How do I find the model number of a MacBook

    A friend of mine has a MacBook that won't start up. How do I find the model number of her MacBook? A number like MBXXXLL/A or MAXXXLL/A.

    HI,
    Do you meant he serial number? If so, click the Apple Menu  then click: About This Mac. You will see Mac O S X. Under that click where you see: Version 10.x.x, then click one more time to see the serial number.
    You can also view this information by launching the System Profiler (Applications/Utilties)
    On the left under Contents select Hardware. The serial number will be displayed on the right.
    Just out of curiosity, how is knowing the serial number going to help trouble shoot this MacBook ??
    Carolyn

  • How to add a new element to a model node in the view controller?

    View Context
        myNode
             attri1
             attri2
    myNode is a web service model node. How to add a new element to this node?
    Regards,
    Hui
    Edited by: Hui Wang on Feb 15, 2008 12:05 PM

    Sudhir Gorantla wrote:>
    > Hi,
    >
    > myNode
    > attri1
    > attri2
    >
    > IMyNodeElement ele=wdContext.myNode().createMyNodeElement();
    >
    > ele.setAttri1("");
    > ele.setAttri2("");
    >
    > wdContext.nodeMyNode().addElement(ele);
    >
    > Regards,
    > Sudhir
    Hi we need a model as an input parameter when creating a element for a model node. How to get the instance of the model?
    Regards,
    Hui

  • How to get the data from the model node like a table ?

    I want to get the data from the model node  once a record ,and the node  is bound to a internal table in the RFM which I called in the R/3 system. Who can give me some advice to achive it?Thank you!!

    Hi,
    To get the data from the node:
    wdContext.node[your node name].current[node name]_InputElement().get[specific element in the node];
    or you van use:
    wdContext.current[your node]Element().get[your element in the node];
    examples:
    wdContext.nodeZ_Mepro_Po_Detail_Stock_Distri_Input().currentZ_Mepro_Po_Detail_Stock_Distri_InputElement().getUcpd_Flag();
    wdContext.currentT_Delv_ReqsElement().getShelflife();
    regards,

  • Error while sorting the model node table

    hi
    if(firstTime)
                     view.nowCreateAllCustomExtensionFields();
               IWDTable tab= (IWDTable)view.getElement("tbl_car");
               wdContext.currentContextElement().setCarTableSorter(new TableSorter(tab,wdThis.wdGetCarTableSorterAction(),null)); 
    i have written the above code in domodifyview()  {}
    and   tbl_car is the id of the my table. and the table is of type
    model node .
    wdContext.currentContextElement().getCarTableSorter().sort(wdEvent,wdContext.nodeIt_Car_Data());
    created a sort action  for the table , present in the  table
    properties and  iam getting a error under sort()  saying
    method sort(iwdcustomevent,iwdnode,string)  is  of type 
    tablesorter and  not  applicable for  
      (wdcustomevent,iprivateview.nodename) 
    can any one help me ?

    replace
    if(firstTime)
    view.nowCreateAllCustomExtensionFields();
    IWDTable tab= (IWDTable)view.getElement("tbl_car");
    wdContext.currentContextElement().setCarTableSorter(new TableSorter(tab,wdThis.wdGetCarTableSorterAction(),null));
    by
    if(firstTime)
    view.nowCreateAllCustomExtensionFields();
    IWDTable tab= (IWDTable)view.getElement("tbl_car");
    wdContext.currentContextElement().setCarTableSorter(new TableSorter(tab,wdThis.wdGetCarTableSorterAction(),new HashTable()));
    nikhil

Maybe you are looking for