cancel
Showing results for 
Search instead for 
Did you mean: 

Empty table & lead selection

Former Member
0 Kudos

Hi folks,

We are having a small problem with our new web dynpro application. Basically we have table, which is populated when the application is started. Under the table we have "detail area", and it shows more detailed information about the selected element in the table. This works basically without problems.

The problems appear when the table happens to be empty. In that situation we got a runtime error saying "Context binding for property VALUE of <attribute name> cannot be resolved: Node <context node> does not contain any elements".

We have also functionality to delete elements in the table, and this causes the same problem. Even if the table contains elements, but we delete those, then when the last element gets deleted, we got the runtime error.

How to handle this kind of situation? My guess is that the lead selection functionality is causing the problem. If the table is empty, no element can be set as selected.

The cardinality of the relevant context node is 0...n, and selection 0...1.

Regards,

Karri

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I have many screens that function similarly with no problems. You can't have the table columns and the detail fields point to the same context node. What you need to do is declare two different context nodes. One would be cardinality 0:n. This you would use for the table. You need to declare another context node for individual detail display textview / input field UI elements. The cardinality of this node will be 1:1. When you populate the table, move the contents of the first row to the structure (no first row, no move). You will need an 'On Lead Select' action in the table to read the lead select from the table and copy the contents from the table into the structure.

Former Member
0 Kudos

Hello,

i got the same problem with my program and i solved it like that.

you only have to check the lead selection. If its inital then call a popup

and exit or something.

DATA lo_nd_worklist_tabelle TYPE REF TO if_wd_context_node.

DATA lo_el_worklist_tabelle TYPE REF TO if_wd_context_element.

*navigate to a node.

lo_nd_worklist_tabelle = wd_context->get_child_node( name = wd_this->wdctx_worklist_tabelle ).

lead_selection = lo_nd_worklist_tabelle->get_lead_selection( ).

if lead_selection is initial.

call popup and exit for example.

endif.

Best regards

René

Former Member
0 Kudos

Hi,

And thanks for the answers.

An answer for your question regarding if we are using supply function is no. We create the elements in the initialization phase. And I want to also mention that the situation, when the table will be empty is totally OK. It is not an error to have the table empty (=no elements).

Changing the cardinality to 1...n helped little bit. Now in a case that there are no elements, a default element is created, and it can be seen in the table (there are some zeros in certain fields). => No runtime error when starting the application with no elements in the node.

But the default element is not that great thing. I want to point out that our table is not just for displaying data. It is possible to manipulate it by deleting and creating new elements. And now with cardinality set to 1...n we still have the problem, that if we delete the default element, we'll have the runtime error.

Regards,

Karri

Former Member
0 Kudos

Hi,

You can continue to have the cardinality as 0..n. But make sure you have the check I mentioned earlier. In of multiple element selection, use the method

lo_node->get_selected_elements(

exporting

including_lead_selection = abap_true

receiving

set = lo_els_set)

If your table is empty, even when you do a lo_node->bind_elements( lt_table ), you will not get a short dump.

Hope this helps

Regards,

Wenonah

Former Member
0 Kudos

Thanks Wenonah,

I am not sure, if I follow you.

In your first reply, you said that I should check the initial value of the lead selection. Where exactly I should check this?

Then you instructed that if the lead selection is initial, I should throw an error. But I don't want to throw an error. I still want to display the same view including the table even if the table is empty.

Can we somehow get rid of the whole "automatic lead selection" functionality? Because now when the application is started (and there are elements in the context), the first line is selected automatically.

In your second reply you mention the case of multiple selection. In our case we are not using multiple selection functionality - only one element can be selected.

Regards,

Karri

Former Member
0 Kudos

hi Karri,

are you able to sovle this issue.

I am haveing the same issue and same scenario. I am getting the lead selection is not set error...

when my context parent is empty.

pls respnd to me.

thanks Niraja

uday_gubbala2
Active Contributor
0 Kudos

Hi Niraja,

I am displaying data from 2 tables VBAK & VBAP. Depending up on the lead selection in VBAK am filling the data in VBAP. I can delete all the records from first table & still not end up in any error. I will try explain my procedure to you.

Below are the properties for my 2 context nodes:

VBAK:

Cardinality : 0..n

Selection : 0..n

Initialization Lead Selection: Unchecked

Singleton: No

VBAP:

Cardinality : 0..n

Selection : 0..1

Initialization Lead Selection: Checked

Singleton: Yes

Supply Function: SUPPLY_FETCH_VBAP_DATA

The 2 tables have the following properties set:

selectionChangeBehaviour : Auto

selectionMode: Auto

As you can see by default the leadSelection isn't set for the 1st table. But as soon as the user selects any record the leadSelection is set & the corresponding data is fetched into the 2nd table element.

METHOD supply_fetch_vbap_data .
  DATA: ls_vbak TYPE ig_componentcontroller=>element_vbak,
        lt_vbap TYPE ig_componentcontroller=>elements_vbap.

  CALL METHOD parent_element->get_static_attributes
    IMPORTING
      static_attributes = ls_vbak.

  SELECT * FROM vbap INTO TABLE lt_vbap WHERE vbeln = ls_vbak-vbeln.

  node->bind_table( new_items = lt_vbap ).
ENDMETHOD.

The user first enters a customer number & the corresponding orders are fetched from VBAK & bound to the first table. Below is the coding for the buttons action handler:

METHOD onactionfetch .
  DATA : wd_node   TYPE REF TO if_wd_context_node,
         it_vbak  TYPE ig_componentcontroller=>elements_vbak,
         lv_kunnr TYPE ig_componentcontroller=>element_vbak-kunnr.

  wd_node = wd_context->get_child_node( name = 'PARENT1' ).

  CALL METHOD wd_node->get_attribute
    EXPORTING
      name  = 'KUNNR'
    IMPORTING
      value = lv_kunnr.

  wd_node = wd_context->get_child_node( name = 'VBAK' ).
  SELECT * FROM vbak INTO TABLE it_vbak WHERE kunnr = lv_kunnr.

  IF sy-subrc EQ 0.
    wd_node->bind_table( new_items = it_vbak ).
  ELSE.
  ENDIF.
ENDMETHOD.

Regards,

Uday

former_member188831
Contributor
0 Kudos

Hi Uday,

I have the similar scenario but i am handling the nodes from PDF interactive form.

in this i have a parent node(this will not be binded to any data tables/structure) it is automatically generated with they type of interface when i give form name in tempalte source, under this i have table node.

as you said if i keep the cardinalty 0..n i am getting a dump saying that under table ndoe is not initialized.

it is working for 1...n.

when i bind with some data it is show on pdf tabl working fine whoing all the records...

but the problem is

when i fill data manually in table it is showing only on record even though i fill more than one...

Thanks,

mahesh

Former Member
0 Kudos

Hi Karri,

Did you used Supply function for filling the data?

Set the cardinality as 1:n.

the reason for the error is that if one specifies a supply function for node, the system

does not supply a default element. That means that supply function needs to take

care.

Example:

- Cardinality 1:1, no supply function => system adds a default element to the node

- Cardinality 1:1, supply function => system adds no default element to the node,

the supply function is expected to supply this element.

Thanks.

Former Member
0 Kudos

Hi,

To be on the safer side and avoid such dumps, make sure that you have put a check for for the initial value of the lead selection element as follows:

      • code for declaration and initialization of lo_node

call method lo_node->get_lead_selection

receiving

element = lo_element.

if lo_element is initial.

        • Throw error and gracefully exit

else.

lo_element->get_static_attributes(

static_attributes = lo_struct

).

endif.

Hope this helps.

Regards,

Wenonah