WDABAP: note of change of Lead Selection overall component

Hi,
I would like to build a similiar wd-application like wd-component 'wdt_master_detail'. There you will see a table with fly-data and below some details of the actual selected row of the table (by lead selection).
The difference is that I want to seperate the data retrieval in a model-component(z_model) and for the table / details two seperate wd-components(z_table / z_detail) which mapps the fly-data. The wd-application instantiate a wd-component (z_container) which includes in its view z_table and z_detail.
When the lead selection changes(by selecting a new row in the table of z_table) the details of z_detail should change to the details of the element with the lead selection. But this does not work! By node->get_lead_selection_index in z_detail I get only the inital lead-selection. node->get_lead_selection_index in z_table provides the right index.
I tried also following: z_table calls z_model->set_lead_selection and this method set the lead selection of the original node new. But this does not help.
Has someone an idee what I have to do that the component z_detail receive the information? Has the z_model to raise an event with the information of the new index? I hope not.
Thanks a lot!
Regards,
Marcel
added 1:
I have an assumption why it does not work:
Maybe z_table and z_detail instantiates two separate z_model.
So a solution would be that z_container instantiates z_model and provide this instance to z_table and z_detail but I have absolutly no idee whether and how this could be working... Please kindly help.
added 2:
I thinking further a little bit loud...
I have the idea that z_container mapps the context from z_model and set this these to input-node.
z_table and z_detail mapps from z_container. ok, if I would like to create many application then I have to create related components(z_comp_appl_xx) and these components includes z_container. This would be maybe the solution if there is a instance problem(see added1) but I have tested and the details screen gets NOT the lead selection
Message was edited by: Marcel Schreier

Hi Marcel,
to extend Thomas comments, here are some suggestions to turn it into code. Hope it helps.
option A)
assuming you name the usages in z_container "usage_z_model", "usage_Z_table", "usage_Z_detail":
in componentcontroller of z_container methode wddoinit() do the following:
DATA lr_model_usage    TYPE REF TO    if_wd_component_usage.
lr_model_usage =   wd_this->wd_cpuse_usage_z_model( ).
IF lr_model_usage->has_active_component( ) IS INITIAL.
  lr_model_usage->create_component( ).
ENDIF.
DATA lr_usage    TYPE REF TO    if_wd_component_usage.
lr_usage =   wd_this->wd_cpuse_usage_z_table( ).
IF lr_usage->has_active_component( ) IS INITIAL.
  lr_usage->create_component( model_usage = lr_model_usage ).
ENDIF.
lr_usage =   wd_this->wd_cpuse_usage_z_detail( ).
IF lr_usage->has_active_component( ) IS INITIAL.
  lr_usage->create_component( model_usage = lr_model_usage ).
ENDIF.
Following this way, it is required to name the usages of z_model in component z_table and z_detail "MODEL_USAGE".
option B)
in componentcontroller of z_table and z_detail create an interface-methode set_usage() with one parameter ir_usage type if_wd_component_usage
  DATA lr_usage  TYPE REF TO  if_wd_component_usage.
  lr_usage = wd_this->wd_cpuse_usage_z_model( ).
  lr_usage->enter_referencing_mode( ir_usage ).
in component z_container method wddoinit() do the following:
DATA lr_usage    TYPE REF TO    if_wd_component_usage.
DATA lr_if_ctr_z_table TYPE REF TO iwci_z_table.
DATA lr_if_ctr_z_detail TYPE REF TO iwci_z_detail.
DATA lr_model_usage    TYPE REF TO    if_wd_component_usage.
*-- create instance of z_model
lr_model_usage =   wd_this->wd_cpuse_usage_z_model( ).
IF lr_model_usage->has_active_component( ) IS INITIAL.
  lr_model_usage->create_component( ).
ENDIF.
*-- create instance of z_table
lr_usage =   wd_this->wd_cpuse_usage_z_table( ).
IF lr_usage->has_active_component( ) IS INITIAL.
  lr_usage->create_component( ).
ENDIF.
*-- set usage
lr_if_ctr_z_table =   wd_this->wd_cpifc_usgae_z_table( ).
lr_if_ctr_z_table->set_usage( model_usage = lr_usage).
*-- create instance of z_deatil
lr_usage =   wd_this->wd_cpuse_usage_z_detail( ).
IF lr_usage->has_active_component( ) IS INITIAL.
  lr_usage->create_component( model_usage = lr_model_usage ).
ENDIF.
*-- set usage
lr_if_ctr_z_detail =   wd_this->wd_cpifc_usage_z_detail( ).
lr_if_ctr_z_detail->set_usage( model_usage = lr_usage).
regards, Ulli

Similar Messages

  • Table - Automatic scroll on changing the lead selection

    Hi @ all,
    I´ve got two tables and I want to add an entry from tab1 to tab2 if it is not existing in tab2. In case of an existing entry in tab2, the lead selection will be set on the entry in tab2 to show the entry. My Problem is the behaviour of the scroll bar in tab2. I need something like automatic scrolling to the lead selection of the table. Is that possible?
    Armin

    Hi  Armin,
    you can the use the proterty "First visible row" of the table.
    create one attribute of type WDy_BOOLEAN and bind it to the "First visible row" of the table.
    as soon as you set the lead selection,get its index and set it to the attributr that is( property  "First visible row").
    once this property is set , scrolling is done automatically and lead selected row is visible as first row.
    I hope this resolves your issue.
    Thanks,
    Krishna

  • Lead Selection does not work after setting filter for ALV.

    Hi, Can you please suggest on below scenario :
    I have a Node with a sub node in it .
    I am using the supply function on Sub Node to retrieve the date based on Parent Node.
    There are two ALV's to display parent and item data. The issue is when a filter(user defined filter) is done on Parent table, the supply function does not work. The value is that of the selected row before setting the filter. Even after removing the filter, the item data is stuck and does not change on Lead Selection.
    One thing I noticed is if the child table is a table UI, there is no issue. The only problem is when the second table is ALV
    Thanks In Advance

    Hi Prashanthi,
    Your issue can be resolved as below
    Create an event handler method 'set_alv_data'  for the event 'ON_LEAD_SELECT' of parent alv
    Write the below code inside the event handler method
    METHOD set_alv_data.
      DATA lo_node TYPE REF TO if_wd_context_node.
      DATA lv_path TYPE string.
      DATA lv_index TYPE string.
      lv_index = r_param->index.
      CONDENSE lv_index.
      CONCATENATE wd_this->wdctx_my_parent_node
      lv_index
      wd_this->wdctx_my_child_node
      INTO lv_path SEPARATED BY '.'.
      lo_node = wd_context->path_get_node(
          path                          = lv_path
      DATA lo_interface TYPE REF TO iwci_salv_wd_table.
      lo_interface = wd_this->wd_cpifc_alv_child( ). "get the ref of alv comp of child
      lo_interface->set_data(
        EXPORTING
    *    only_if_new_descr =
          r_node_data       = lo_node
    ENDMETHOD.
    The above code sets the data node of child alv based on lead selection of parent alv data.
    Note: Replace 'parent_node', 'child_node'  with your nodes & 'alv_child' with your alv component name of child alv.
    If you want to control the data of child alv on filter function, you can use the event ON_STD_FUNCTION_AFTE and once you define the filter you get the r_param->id = 'SALV_WD_FILTER_DEFINE'  & now you can clear data of child alv.
    Hope this helps you.
    Regards,
    Rama

  • WD:ABAP  change lead selection

    Hi all,
    I  need to change the lead selection according to a particular table column.  The lead selection is set to the first row of the table.  The table has some input fields which already contain values.  If the user changes the value of the input field in any row, the lead selection has to be changed to that row of the table without having to select that row.  I wrote the code in  onEnter event of the table, but it is returning the values of the first row that has the lead selection.  How do I change it? It would be helpful if u could please post the code too.
    Thanks,
    Sravanthi

    Hi,
    You can change it in ModifyView method. You can use setLeadSelection method.
    Regards,
    Parminder

  • Why does GET_STATIC_ATTRIBUTES or SET_STATIC_ATTRIBUTES change lead selecti

    I loop over all elements of a context node, and change some attributes.
    The code looks like this:
          LOOP AT lt_element_list INTO lo_el_element.
            lo_el_element->get_static_attributes( IMPORTING static_attributes = ls_element ).
            ls_element-created_by_name  = get_user_name( iv_user_id = ls_element-created_by ).
            ls_element-changed_by_name  = get_user_name( iv_user_id = ls_element-changed_by ).
            lo_el_element->set_static_attributes( EXPORTING static_attributes = ls_element ).
          ENDLOOP.
    This coding seems to change the the lead selection of the context node, which leads to problems somewhere else.
    Why does it change the lead selection and how can I prevent it?

    hi daniel.....
             i dont think there is a need for looping in this manner.
             you just get all the values of a node into an internal table.
             and then loop the internal table an make changes in it.
             then clear the node and pass this currently changed internal table into the node.
              the lead selection changes because you are setting the attribute and it might be stored in index 1 or the to the index where the lead selection is referred to. this might be your problem.
    ---regards,
       alex b justin

  • How to make a row enabled for lead selection and make other Rows disabled?

    Hi,
    What I require is:
    In a webdynpro table , which can have multiple rows, I want to make the rows which are retrieved fom backend as disabled for selection.
    And when I add a new row (using an ADD functionality) , this newly added row should only be enabled for lead selection.
    The Table property "enabled" can be assigned a context , and can be used to control the disabling of whole table.But then if I add the new row to this table, even this will be disabled.
    I can set lead selection to a the new row, but if the whole table is disabled, this won't work.
    Please suggest a solution for this.
    Thanks,
    Richa

    Do not set the enabled flag to the whole table but to the editors of each column. Bind the enabled property to a calculated boolean flag in the data source node. In the get method of this flag add a code that will make the editor enabled only if it belongs to the lead selection element.
    Now do not allow the selection of rows in the table (there is a property for this, perhaps is named rows selection I don't remember well now), but change the lead selection of the data source node to the desired element when you add the element programatically.
    Hope it helps.

  • Reset lead selection after refresh in alv grid

    Hi experts,
    I've a problem with holding the lead selection in an alv grid table view in web dynpro.
    After changing an attribute the lead selection in the view gets lost, but is hold in the referenced context node.
    Is there a way to change the lead selection in alv by code?
    I've found the method "set_index()" in class CL_SALV_WD_TABLE_LEAD_SELECT, can I use that?
    Thanks a lot,
    Kai

    Hi Kai,
    I faced a similar problem earlier.
    Request you to elaborate about the  "attribute" you are changing.
    I was also facing a similar issue.
    It will be gr8 if I can help you.
    Please see the below thread for some reference.
    [Not able to select a row in ALV|Not able to select a row in ALV?;
    I hope it helps.
    Regards,
    Sumit Oberoi

  • Table: show the line of lead selection

    Hello,
    I have a table with 691 lines, showing 20 lines per page. Is it possible to change the lead selection for example to line 60 and also jump to line 60. So that the table automatically shows the 3rd page with the line 60 - 80.
    I can change the lead selection with:
    node_trefferliste->set_lead_selection_index( index = 60 ).
    Lead selection is set correctly to 60 but the table still shows the lines 1- 20.
    best regards
    Stefan

    Hi Stefan,
    What ever you have done is correct. One thing you need to change is whenever you change the lead selection for you table you need to scroll ALV also. For that get the lead selected entry and set it as frst_visible_row for you ALV table. Please do this coding in the respective view controller method WDDOMODIFYVIEW(). so that you will get exact result what you are expecting.
    I hope i make you clear.
    Warm Regards,
    Vijay

  • Bind Table / Lead Selection

    Is there a way to bind a table without changing the lead selection?  I know that I can read the lead selection before binding, and then set it after binding, but was wondering if there was a better way.

    As far as i know there is no such ready made method or api available. As you already pointed out , you need to do that with programmatic.

  • How to prevent action (lead selection change) with popup (confirmation)?

    Hello all,
    I have an application where I want the user to confirm when he selects a new line in a table. When the user selects a new line in the table an other used component reloads its data based on the new line selected. If the user has not pressed the save button before selecting a new line, any changes in the used component will be lost.
    Currently I use onLeadSelect action on the table to call the load_data method(id=xxx) on the used component in order to display data relevant for id=xxx based the new line.
    I can open a popup to confirm from the onLeadSelect-action or the WDDoBeforeAction, but the action still happens; it doesn't wait for the user to respond. And then any changes are lost...
    I may have to store the parameters sent to the onLeadSelect method in context and continue when the button action from the pop-up returns via subscribed method, but I think this is an unelegant way of doing this.
    There must be a better way...? Any ideas?
    Regards,
    Christian Frier

    on the lead select event handler you can show the popup and no other logic. Move your logic to the ok and cancel button handlers of the pop up.

  • How to tackle the error - " The Lead Selection has not been set in view "?

    Hi Guys,
    I'm getting this error " The Lead Selection has not been set in view " . If any one has faced the same problem , then please guide me . I am new to WD ABAP so finding it difficult to track the reason.
    TIA,
    Vishesh

    Hi Pradeep,
    I have already checked  "Initialisation Lead Selection" property . I have faced the same problem in another view also there it got solved by changing the cardinality.  In this case, I had tried both cardinality and Lead selection property  but nothing  is working.
    Thanx.

  • Getting "The Lead selection has not been set in view"Error during runtime

    Hi Guys,
    I'm getting  this error " The Lead Selection has not been set in view " . If any one has  faced the same problem , then please guide me .  I am new to WD ABAP so finding it difficult to track the reason.
    TIA
    Moderator Message: Please search the forum before posting basic messages. Thread locked
    Edited by: Neil Gardiner on Oct 1, 2010 3:48 PM

    Hi Pradeep,
    I have already checked  "Initialisation Lead Selection" property . I have faced the same problem in another view also there it got solved by changing the cardinality.  In this case, I had tried both cardinality and Lead selection property  but nothing  is working.
    Thanx.

  • Automatic lead selection change line in WD table

    Hi all,
    In footer of WD table, there is an input field, where user can specify number of record, which will be shown in first visible line.   
    I need to automatically select this line as lead selection. How can I achieve this behaviour? ( I'm using NW 2004 SP 19)
    Thanks for any answer.
    Regards,
    Juraj

    Hi Juraj,
    Assuming that when first time the view containing the table is loaded their is no changes required.
    Only when you enter some value in the input field then that record should be shown as first visible row ans should be lead selected.
    Now,
    1. Create a context attribute ctx_rowinput.Bind this context to the input field.
    2. Create a action say onInputShow and associate this with the input field.
        Either use a button and associate the action to the button or OnEnter event of input field.
    3. In your action onInputShow();
      public void onActionInputShow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        int i = wdContext.currentContextElement().getctx_rowinput();
        wdContext.node<table node>().setLeadSelection(i);
    4. In your wdDoModifyView add the following code
      public static void wdDoModifyView(IPrivateTest_Table_View wdThis, IPrivateTest_Table_View.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
        if(!firstTime)
              IWDTable table =(IWDTable)view.getElement("Table");
              table.setFirstVisibleRow(wdContext.currentContextElement().getctx_rowinput());
        //@@end
    <b>Note: If you enter 3 in the input field it will show 2 record as the node index
    starts from 0.And also before setting the leadselection and visible row check if
    the input value exceeds the nuber of rows in the table.</b>
    This has worked for me.

  • Error "Lead selection not set for context node"

    Hi everyone,
    I've got a Tree control in WebDynpro ABAP and I've implemented an "expand all" button.
    Here's the coding:
    METHOD expand_node_rec.
      DATA lo_el_child TYPE REF TO if_wd_context_element.
      DATA lo_node_children TYPE  wdr_context_child_map.
      DATA wa_lo_node_children LIKE LINE OF lo_node_children.
      DATA lo_nd_child TYPE REF TO if_wd_context_node.
      DATA lo_kschl TYPE klschl.
      DATA lv_has_children TYPE boolean.
      lo_el_child = node->get_element( ).
      lo_node_children = node->get_child_nodes( ).
      node->get_attribute( EXPORTING name = 'KSCHL' IMPORTING value = lo_kschl ).
      node->get_attribute( EXPORTING name = 'HAS_CHILDREN' IMPORTING value = lv_has_children ).
      IF lv_has_children = abap_true.
        node->set_attribute( name = 'IS_EXPANDED' value = abap_true ).
      ENDIF.
      LOOP AT lo_node_children INTO wa_lo_node_children.
        lo_nd_child = wa_lo_node_children-node.
        me->expand_node_rec( node = lo_nd_child  ).
      ENDLOOP.
    ENDMETHOD.
    However I'm getting the error above: "Lead selection not set for context node".
    Any suggestions?
    Edited by: DEVELOPMENT THEMIS on Jul 7, 2011 6:34 PM

    hi developement Themis,
    I think u didn't diclare "node" as context node. So declare it as a context node before using as a context node..as below
    DATA node  TYPE REF TO if_wd_context_node.
    or u can use  "lo_nd_child " as ur context node in ur program in place of "node"
    then I think this error will be removed.
    thanks,
    simadri

  • How to block lead selection change in a tree ?

    Hi Guys,
    <u>Scenario</u>
    I have MasterTree - DetailEditor pair. <i>MasterTree</i> is used to visit some tree-structured data and <i>DetailEditor</i> is used to edit currently selected tree node.
    <u>Requirement</u>
    If currently selected node data is updated through <i>DetailEditor</i> and needs to be saved, than on a subsequent tree selection change the user should be warned about unsaved data.
    <u>Implementation</u>
    In <b>onAction</b> event handler of <i>MasterTree</i> I check whether last selected node data is updated and needs to be saved and if this is the case rollback <i>treeSelection</i> to that node. On the time <b>onAction</b> event handler is called the tree selection is changed from the node that needs save to the newly selected node. In order to rollback <i>treeSelection</i> I need to introduce variable referencing last selected tree node.
    <u>Question</u>
    Is there any other technique to implement above scenario without using additional variable and manually rollback <i>treeSelection</i> ? For example, to plug in WDP framework on validation step just before lead selection is changed.
    Thanks in advance

    Alex,
    Here is a link to the phase model of WD:
    http://help.sap.com/saphelp_nw04/helpdata/en/b8/cd96edb9c8794aa362e6e8b4236a1f/frameset.htm
    There aren't any hooks provided prior to the event handlers being called. As far as I can tell, the way you are handling it is the only way that will work.
    -Cindy

Maybe you are looking for