Skip to Content
0

How to add a row to VIEW CONTAINER UI Element during initialisation?

Mar 06 at 06:22 PM

49

avatar image
Former Member

Hi,

I have a table which is declared inside the V_MAIN under a tabstrip button.

It is a view container UI Element and It accepts user input.

Requirement:

I need to add a row (selected from database) in this input table so that when the user reaches this tab he sees a default entry.

What I have done so far

viewcontainerui-element.png

I tried adding code in the WDDOINIT method of the V_MAIN. But the BIND_TABLE logic did not work as intended. Here is the code I added.

*--User wants to default an intermediate approver in the Approval Tab
  DATA lo_nd_approv_list TYPE REF TO if_wd_context_node.
  DATA lo_el_approv_list TYPE REF TO if_wd_context_element.
  DATA lt_approv_list TYPE wd_this->elements_approv_list.
  DATA ls_approv_list TYPE wd_this->element_approv_list.

*--navigate from <CONTEXT> to <APPROV_LIST> via lead selection
  lo_nd_approv_list = wd_context->get_child_node( name = wd_this->wdctx_approv_list ).

*-- Get default row from database.
  wd_this->add_default_approver( RECEIVING es_dpipco1300 = ls_dpipco1300 ).
*-- Add this row to the internal table 
  CLEAR ls_approv_list.
  <.....>
  APPEND ls_approv_list TO lt_approv_list.

*--Bind the data to the Webdynpro table UI element to add the default entry
lo_nd_approv_list->bind_table( lt_approv_list ).

This code does not work. No new row is added to the input table.

In INITIALIZATION event the code does not work. But it works when added to the ONACTION_ADD button event.

Could you suggest an alternative/ help/ corrections to the code.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Mar 08 at 04:11 PM
0

Hi,

Got it to work now.

Issue was running my code in the WDDOINIT method.

It started working when I moved the exact same code into the WDDOMODIFYVIEW method.

Share
10 |10000 characters needed characters left characters exceeded
Mike Pokraka Mar 06 at 08:44 PM
0

Hmmm, the code looks right.

To ask the obvious, have you tried debugging? Is the value there when you debug?

I wonder if the bug might be in your contexts? A view container will usually contain another view or component. So in this wddoinit you are working with the controller’s context. But the table will be based on another context, either the view or the component that it belongs to. Please check that these are bound correctly. If the button for the working code is in the same view as the table then that also points to a missing context binding. Or something else overwrites it.

Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi,

Thank you for replying

I was under the impression that the below code lines would pick the current context

*--navigate from <CONTEXT> to <APPROV_LIST> via lead selection
  lo_nd_approv_list = wd_context->get_child_node(name= wd_this->wdctx_approv_list ).

Is there another alternative to this?

0

Correct, but if this code is in V_MAIN and your table is in a View Container then the table would be in a different view with a different context. Assuming you do have the table in a separate view to V_MAIN, your setup could look like the second picture:

https://help.sap.com/viewer/7b44f2a7728810148a4b1a83b0e91070/7.5.9/en-US/4745640f80f81962e10000000a114a6b.html

Therefore I suggested to check your context binding, to make sure the changes done in V_MAIN’s WDDOINIT are reflected in your table's view context.

0
Former Member

Hi,

Got it to work now.

Issue was running my code in the WDDOINIT method.

It started working when I moved the exact same code into the WDDOMODIFYVIEW method.

It works now. But could you help me with the technical details as to why exactly this happened?

0

It’s difficult to tell from afar but I am fairly sure it is to do with your multiple view interactions. Perhaps you filled it in the v_main wddoinit and the v_table (or whatever) loaded the data again in its wddoinit, or it wasn’t bound.

If you have the code in the wddomodifyview, please add a check that it’s only executed the first time, otherwise it runs after each interaction.

Have a look at the web Dynpro phase model docu, unfortunately it’s missing the wddoinit (view initialisation part in the diagram) but may help make it clearer:

https://help.sap.com/viewer/7b44f2a7728810148a4b1a83b0e91070/7.5.9/en-US/49b8c706c7c26d7ce10000000a421937.html

Another possibility is e.g. your main view might fill it in the wddoinit, but navigating to the tab resets it, or something like that. Set a few breakpoints and debug.

0
Former Member

Thank you for your kind assistance

0