Dynamic reverse context node mapping at runtime

Hi!
I have an application which uses another embedded component containing a ALV table which shows the data of a transparent table.
Everything works fine if i'm working with a static table with static attributes and map the context node of the application to the node in the embedded component. The context node in the embedded component is reversed mapped and gets its data from the application's context node.
Now i want to do it dynamically. Inside the application the user should choose the name of a table and I'm using RTTI functions to get it's technical informations. At runtime i'm adding dynamically attributes (i.e. fieldname, type, length) to a static context node called 'DATA'.
The ALV component of the embedded component is mapped to an interface context node named 'DATA' which uses reverse mapping to receive data from the applications context node 'DATA'.
What I need to know is how to create the mapping between application context node and interface context node of the embedded component at runtime after i have created the attributes of the node dynamically. Is that basically possible?
I've already tried to map the both nodes statically to see if the dynamically created attributes are mapped automatically then. The mapping seems to be fine at node level, but doesn't work for the later dynamically added attributes.
Could someone point me to informations if dynamic mapping context nodes is basically possible and how to do it?
Regards
Ralf-J.

Hi Lars!
Thanks for the link! The problem isn't to fill the context node dynamically. That's already working using RTTI etc.
It seems to me that the interface context node of the ALV in the embedded component doesn't recognize the dynamically added attributes. As i wrote the binding on node level (DATA->DATA), which i'm doing at design time, is working as expected, but the added attributes are only shown in the context node of the using component but not in the embedded.
I'm still thinking there must be a way to do a binding at runtime. On the other hand the comment of Glenn in the thread you've pointed me to, seems to suggest that the ALV itself might have problems with dynamically appended attributes.
Regards
Ralf-J.

Similar Messages

  • Dynamic reverse context mapping

    hi,
    can someone explain me how to use dynamic reverse context mapping in my web dynpro application?
    I have read in other sdn-threads that in IF_WD_CONTEXT_NODE_INFO the methods ADD_NEW_MAPPED_CHILD_NODE and SET_MAPPING_COMPLETE might be the solution.
    does anyone know where and how to use these methods? please explain me the priciple and which parameters I should use for example CONTEXT_PATH and MAPPED_CONTROLLER with the SET_MAPPING_COMPLETE method.

    Hi Thorsten,
    I don't think you can acheive Dynamic Reverse Context Mapping using the above mentioned methods.
    Please find the below scenario in which we can acheive Dynamic Reverse Context Mapping programatically.
    The situation is, with in my WD component I created a context in the component controller dynamically or statically. Now I want to map this node to another node of a comonent at run time.
    Here my WD component is the parent component and I am using a child component say SALV_WD_TABLE, which has a context DATA. Inorder to populate data in the ALV the DATA node must be supplied with the necessary contents either at run time or at design time.
    The run tiime mapping is as follows.
    DATA : lo_componentusage TYPW REF TO if_wd_component_usage,
               lo_interfacecontroller TYPE REF TO  IWCI_SALV_WD_TABLE.
    lo_componentusage = wd_this->wd_cpuse_ref_salv( ).
    if lo_componentusage ->HAS_ACTIVE_COMPONENT( ) is INITIAL.
           CALL METHOD LO_COMPONENTUSAGE->CREATE_COMPONENT
    endif.
    lo_interfacecontroller =   wd_this->wd_cpifc_ref_salv( ).
    CALL METHOD lo_interfacecontroller ->SET_DATA
    EXPORTING
        R_NODE_DATA       = lo_nd_flight_salv .
    lo_nd_flight_salv is a reference to the node in your WD component which contains the data to be displayed.
    Hope I could give you a clue...
    Cheers,
    Sankar

  • How to implement Dynamic Context Node Mapping between Components

    Hey genuis:
               I am looking for how to implement context mapping bwteen two components. I read some threads, and try to use external context mapping. The example works fine. However, my requirement is more than that.
    I have a context node in Component B, and the attributes in it are dynamically generated. Component A is the main component which use Component B's function. Both A and B work fine by theirselves. 
    When I assemble A and B (external mapping), the system gives me a exception:com.sap.tc.webdynpro.progmodel.context.ContextException: MappedNodeInfo(T8UploadCompInterface.data): cannot create nodes, no mapping defined yet.
    Please give me some suggestion?
    Any responses are appreciated.

    I miss this thread.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6fdae690-0201-0010-a580-d104b459cb44
    This is almost the right solution for my problem.

  • How to delete a dynamically created context node ?

    Hi
      I have created a context node dynamically and have added the check boxes to the node.
      But when i am refreshing the page it is giving me the following excepiton:
    com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(DwdReportView.Person): duplicate name for attribute attr1
    I am writing the following code in wdDoExit() method so that the node is invalidated  and all dynamically added nodes and attributes are destroyed from the metadata.
    The code  is :
         wdContext.getContext().reset(false);
    or
         wdContext.getContext().reset();
    or
                         wdContext.nodeName().invalidate();
    I have tried all the above mentioned code  snippets but it is still giving me the same exception.
    Please help me  resolve this issue.
    Thanks in advance.
    Regards
    Shaily

    Shally,
    A better forum to place your question is the forum.
    To your question: the wdDoExit() method is only called once i.e. when the view is destroyed from memory. Just like the wdDoInit() mehtod is called only once at initialisation of the view.
    Try refactoring your code, so that upon initialising of your context, the old version of it is removed.
    Hope this helps.
    Regards,
    Alain

  • How to access the structure of a dynamically created context node/element

    Hi All,
    in method wddoinit I have added a context node and some attributes
    lo_node = wd_context->get_child_node( name = wd_this->wdctx_instructors ).
      lo_node_info = lo_node->get_node_info( ).
      lo_node_info = lo_node_info->add_new_child_node( name                  = 'OCCUPANCY'
                                                       is_mandatory          = abap_true
                                                       is_multiple           = abap_false
                                                       is_multiple_selection = abap_false ).
          lo_node_info->add_attribute( ls_attr ).
    So far, I have node INSTRUCTORS (0...n) with a subnode OCCUPANCY (1...1)
    In the supply_method of INSTRUCTORS I would like to fill the instructors node and the OCCUPANCY subnode.
    The thing is I do not know the structure of the dynamicaly created subnode OCCUPANCY there. How can I get a description of this node (that, what in non-dynamic programming would be wd_this->element_occupancy...)??
    THANKS,
    Johannes

    ...I got this one solved by myself...
    I simply added this coding:
    lo_node_info = lo_node->get_node_info( ).
      lt_attributes = lo_node_info->get_attribute_names( ).
    This appers to be enough information to be good to gogo
    Thanks anyway.

  • Problem with a context node mapped

    hi all,      
    i have a problem in a WD application, when i execute a certain RFC, the model node in the controller mapped to that RFC (model), does not fill itself with the data that the RFC suppose to bring as a result. it seems to get lost in some point (the data). i check and all seems to be fine. I bind the node, then i execute it and later i invalidate it. It's not a role problem i've checked already, and the RFC in the backend when i run it, shows me data. Anyone knows what could this be?...       
    Regards, 
    Mariana

    Well my context structure its like this
    + Zbapi_XYZ
      + OutputY
        + ReturnY
        + Table_XYZ (custom structure)
          -attribute_1
          -attribute_n
      + Return_IN ( bapireturn structure)
          -attribute_1
          -attribute_n
      +Table_XYZ_IN (custom structure)
          -attribute_1
          -attribute_n
      - attribute1
    This is a model node, all the attribute are model attribute and both Table_XYZ_IN and Table_XYZ are from the same type of structure.
    The binding is implemented in WdDoInit Method as follow:
    Zbapi_Sd_Consulta_Doc_Serial_Input bapiSdConsultaDocSerial =
                   new Zbapi_Sd_Consulta_Doc_Serial_Input();
              wdContext.nodeZbapi_Sd_Consulta_Doc_Serial_Input().bind(
                   bapiSdConsultaDocSerial);
    and the execution of the RFC is in a custom method call
    public void ejecutarSdConsultaDocSerial( java.lang.String serial )
    inside it has the follow code:
    String nombreFuncion = "ejecutarSdConsultaDocSerial: ";
              String mensaje = "";
              boolean error = false;
              wdContext.currentZbapi_Sd_Consulta_Doc_Serial_InputElement().setPsernr(
                   serial);
              try {
                   wdContext
                        .currentZbapi_Sd_Consulta_Doc_Serial_InputElement()
                        .modelObject()
                        .execute();
                   //Invalidates the output context node
                   //wdContext.nodeOutputSD().invalidate();
                wdContext.nodeZbapi_Sd_Consulta_Doc_Serial_Input().invalidate();   
                   //En la variable "mensaje" se almacena todos los mensajes de error concatenados
                   for (int i = 0; i < wdContext.nodeReturnSD().size(); i = i + 1) {
                        IReturnSDElement retorno =
                             wdContext.nodeReturnSD().getReturnSDElementAt(i);
                        if (retorno.getType().equals("E")) {
                             error = true;
                             mensaje = mensaje + " " + retorno.getMessage();
                   if (error) {
                        wdContext
                             .currentEstatusBAPIElement()
                             .setEstatusSdConsultaDocSerial(
                             0);
                        wdContext.currentEstatusBAPIElement().setMensajeError(
                             nombreFuncion + mensaje);
                   } else {
                        wdContext
                             .currentEstatusBAPIElement()
                             .setEstatusSdConsultaDocSerial(
                             1);
              } catch (Exception ex) {
                   wdContext
                        .currentEstatusBAPIElement()
                        .setEstatusSdConsultaDocSerial(
                        0);
                   wdContext.currentEstatusBAPIElement().setMensajeError(
                        nombreFuncion + ex.getMessage());

  • Delete context node

    Hi all,
    how can I delete a dynamically created context node by runtime?
    I want to delete the node completly not just invalidate its elements list. Moreover I want to delete a certain node so the method reset() for the context is not useful here.
    Thanks in advance for all answers,
    Regards,
    Torben

    Hi Val,
    Thanks for the update.
    Regarding the reset method: I am trying to use the reset() method before I am recreating my dynamic context but I when I recreate my dynamic context I receive an error: "Cannot add element with duplicate ID "addText0" as if it still exists. Any idea why it's not being destryoed?
    Message was edited by:
            Roy Cohen

  • Dynamical reverse mapping

    Hi,
    I didn't manage to do the reverse mapping at runtime.
    I have 2 components.
    The context of them are described below:
    There is only one node in component 1 called "idioms"
    In the component 2 (that is the component used called POPUP) there is the node called "columns"
    I want to map idioms to columns at runtime. It is a reverse mapping.
    I have the code below:
    data: lo_node_info type ref to if_wd_context_node_info,
            lo_dyn_node_info type ref to if_wd_context_node_info,
            stru_mapping_info type wdr_context_mapping_info,
            tab_mapping_path type wdr_ctx_element_path_segments,
            wa_path type wdr_ctx_element_name.
      wa_path = 'COMPONENTCONTROLLER.COLUMNS'.
      insert wa_path into table tab_mapping_path.
      stru_mapping_info-component_usage = 'POPUP'.
      stru_mapping_info-controller = 'COMPONENTCONTROLLER'.
      stru_mapping_info-path = tab_mapping_path.
    lo_node_info = wd_context->get_node_info( ).
    * Map the context node dynamically
      call method lo_node_info->add_new_mapped_child_node
        exporting
          child_name   = 'IDIOMS'
          mapping_info = stru_mapping_info
        receiving
          child_node_info = lo_dyn_node_info.
    The mapping hasn't been done. Why?
    Thanks a lot.
    Regards,
    Jorge Luiz

    Hi David,
    Thanks for your helping.
    I have done what you said, but I am receinving the error below;
    Adapter error in &VIEW_ELEMENT_TYPE& "TABS" of view "YSWD_HR_TABLE_POPUP.MAIN": Context binding of property DATA_SOURCE cannot be resolved: Subnode MAIN.IDIOMA_POPUP does not exist
    I am passing the node IDIOMA_POPUP as a parameter of the set_data( ) method of the used component.
    TABS is the table that I want to populate.
    Regards,
    Jorge Luiz

  • Using Search Help with ALV and Dynamic context node

    The topic subject already describes my situation.
    I have to create, populate and remove context nodes at runtime, and bind them to an ALV, to let user display the data or modify the data. The nodes I create are always typed with a table name, but the table name is of course, dynamic.
    This is all working: what's not working is help for entries inside the ALV; since the table has foreign keys and domains with check tables or fixed values, I expected that search helps were detected and managed by the framework.
    Instead, no help search is displayed except the input help based on data-type of the one "Date" input fields.
    I think I have to work on the dynamic node creation, and not on the ALV itself, since the latter only takes the node/attributes information, but i could be wrong. I tried with both the two following codings:
      CALL METHOD lo_nd_info_root->add_new_child_node
        EXPORTING
          static_element_type          = vs_tabname
          name                         = 'SAMPLE_NODE_NAME'
    *    is_mandatory                 = abap_false
    *    is_mandatory_selection       = abap_false
         is_multiple                  = abap_true
         is_multiple_selection        = abap_false
    *    is_singleton                 = abap_false
          is_initialize_lead_selection = abap_false
          is_static                    = abap_false
        RECEIVING
          child_node_info              = lo_nd_info_data .
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
          parent_info = lo_nd_info_root
          node_name = 'SAMPLE_NODE_NAME'
          structure_name = vs_tabname
          is_multiple = abap_true ).
    The result is the same...is there any way to let the ALV know what search helps it has to use, and doesn't force me to manually build a VALUE_SET to be bound on the single attributes? There are many tables, with many fields, and maintaining this solution would be very costly.

    I have checked with method GET_ATTRIBUTE_VALUEHELP_TYPE of interface IF_WD_CONTEXT_NODE_INFO, on an attribute which i know to have a search help (Foreign key of a check table).
    The method returns 'N', that is the constant IF_WD_VALUE_HELP_HANDLER~CO_VH_TYPE_NO_HELP. So, the framework was not able to find a suitable search help.
    Using method GET_ATTRIBUTE_VALUE_HELP of the same interface, on the same attribute, returns me '111', which is constant C_VALUE_HELP_MODE-AUTOMATIC.
    Therefore, the WD framework knows it has to automatically detect a value help, but fails to find one.
    Also, this means in my opinion that the ALV and the dynamic external mapping are not the culprits: since node creation, no help is detected for any attribute but the date. Honestly, I don't have a clue on what's happening.

  • Adding dynamic attributes to static context node

    Hi All,
    I have defined a context node LINES with several attributes. This is done staticly during developmenttime.
    During run-time node LINES is extended with several attributes dynamicly. See below:
    10     HEADER_GUID               ->
    11     DETAIL_GUID               ->
    12     EXTERNAL_ID               ->
    13     OBJECT_TYPE               ->
    14     IN_OUT_PLAN               ->
    15     TRAFFIC_LIGHT_1               ->
    16     TRAFFIC_LIGHT_2               ->
    17     TRAFFIC_LIGHT_3               ->
    18     TRAFFIC_LIGHT_4               ->
    19     _LOCATION          \TYPE=STRING     ->
    20     _ZZTOPGROUPING     \TYPE=STRING     ->
    21     _STATUS          \TYPE=STRING     ->
    22     _100000200          \TYPE=STRING     ->
    19..22 are added dynamicly.
    I have an internal table that matches de new context. This <fs_tb_tree_new> I want to bind like:
    *&- bind table
      lr_node->bind_table( new_items =  <fs_tb_tree_new>
                           set_initial_elements = abap_true ).
    In <fs_tb_tree_new> the dynamicly added attrbutes contains values e.g. (the static attributes also have values via <fs_tb_tree_new>):
                         _LOCATION   _ZZTOPGROUPING  _STATUS              _100000200                   
    5     Africa     0002     Reporting Entity     0.000
    6     Russia, CIS     0003     Identify                          0.000
    An ALV presents the values of the attribute. But.... only the values of the static part are presented, not the dynamic attributes added during runtime.
    Please advise what I forget or do wrong .
    Thanks in advance.
    John

    I solved the issue:
    If you use a combination of static attributes added with dynanic attributes (during runtime) for dynamic ALV, I advise to create a new node and bind the values to this new created node:
    Cheers, John
    wd_this->extend_context( EXPORTING im_struc_descr =  lr_cl_abap_structdescr
                               IMPORTING ex_node = lr_node_alv ).
    Method:
    *&- Create new dynamic context LINES_DYN
    Node for alv-table
      lr_node_info = wd_context->get_node_info( ).
      CALL METHOD lr_node_info->add_new_child_node
        EXPORTING
          name                  = 'LINES_NEW'
          static_element_rtti   = im_struc_descr
          is_static             = abap_true
          is_multiple           = abap_true
          is_multiple_selection = abap_false
        RECEIVING
          child_node_info       = lr_subnode_info.
    lr_node = lr_subnode_info->get_parent( ).
      lr_node = wd_context->get_child_node( 'LINES_NEW' ).
      ex_node = lr_node.
    *&- bind table for alv
      lr_node_alv->bind_table( new_items =  <fs_tb_tree_new>
                               set_initial_elements = abap_true ).

  • Map context node  web dynpro to context DATA of  interface controller ALV

    Hi Experts,
    I have started creating simple ALV by following the example in the below mentioned link.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3439404a-0801-0010-dda5-8c14514d690d
    I have completed 95% development but stuck with last bit of
    Set data to ALV for display (via reverse context mapping).
    When Click on the Controller Usage button. The component controller of your Web Dynpro component DOES NOT appears on the right side of the screen.
    Therefore I can not  Map context node NODE_FLIGHTTAB of your Web Dynpro component to context DATA of the interface controller of the ALV component.
    Could you please shed me light on this.
    Your time and help much appreciated.
    Best Regards
    CB

    Hi Chandra,
    You need to add component controller first. Just go to the property tab of interface controller of the alv component and click on create button and then add the component controller. After that you'll be able to see the node in the context tab.
    Regards
    Arjun

  • To access a dynamic context node defined in a Used Component

    Hi Gurus,
    I need your help with something.
    I have a dynamic context node in ComponentA. I want it in Component B too.
    Component B uses Component A, but I am not able to get access to the context node.
    Is it possible to do this? Any suggestions how to proceed.
    PS: I am trying to do a dynamic mapping. The initial scenario was here, Set data into Model Node on Navigating from a View
    Thanks in advance,
    Anjana R.
    Message was edited by:
            Anjana Raghav

    Hi Gurus,
    Its working now. Earlier, the code was something like this....
    IWDNodeInfo compNode = wdThis.wdGet<i>Comp</i>Interface().wdGetAPI().getContext().getRootNodeInfo().getChild(nodeNm);
    viewNodeInfo.setMapping(compNode,true);
    and was trying to map it using
    iewNodeInfo.addMappedAttribute("order",".<i>Comp</i>."+ nodeNm + ".order");     
    Now, I am mapping like this.
    viewNodeInfo.addMappedAttribute("order","order");
    Thanks,
    Anjana R.

  • Adding dynamic context node

    Hello,
    I having problems with creating a dynamic context node.
    How can i add a new node to the context on runtime and not on design time.
    Best Regards,
    Smadar.

    Hi,
    IWDNodeInfo nodeinfo=wdContext.getNodeInfo();
    /* This will add a ValueNode */
    IWDNodeInfo customerNode=nodeinfo.addChild("Customer",null,true,true,true,false,false,true,null,null,null);
    /* This will add  a Attribute to the above Node */
    IWDAttributeInfo custAttr=customerNode.addAttribute("AttribName","com.sap.dictionary.string");
    Regards, Anilkumar

  • Element addition to context node at runtime.

    Hi all,
    I have a class array object in which all data comes at runtime.
    I created a node in context.
    i have to add the element to node. i ahve used that node as a datasource to table UI.
    EmpWrapper e[] = null;
    e = tmp1.Get(wdContext.currentContextElement().getDIVISION());
    // i am getting all data in e[]
            if (e.length != 0)
            for (int i=0;i<= e.length;i++){
    //how to add the e data to node EMP in context                       

    Hi Shefali,
    Here is the link to create dynamic context nodes and its attributes.
    https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/b3f6e990-0201-0010-c087-c865f2c738b3
    Regards,
    Abhimanyu L

  • Dynamic Context Node Copying question

    I am trying to dynamically copy some context nodes from my component controller to the view controller.  In the source context, I have a node whose "Multiple" property is set to true.
    I use the function addMappedChild to copy the attribute info, but the copied node always has "Multiple" set to false!! In the definition of addMappedChild there is no paramter for "Multiple".  How do I do this?
    Thanks
    Walter
    public IWDNodeInfo addMappedChild(java.lang.String name,
                                      java.lang.Class elementClass,
                                      boolean singleton,
                                      boolean mandatorySelection,
                                      boolean multipleSelection,
                                      java.lang.String mappedPath,
                                      boolean selectionMapped,
                                      boolean initializeLeadSelection)

    Are you making like dscribed here
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/dynamically creating, building, and mapping a context in web dynpro.pdf 
    page 14?
    Best Regards, Maxim r.

Maybe you are looking for