cancel
Showing results for 
Search instead for 
Did you mean: 

Node does not contain any elements error

Former Member
0 Kudos

In the code below the statement:

    lo_beneficiaries->set_attribute(
      EXPORTING
        name  = `BENEFICIARY1`
        value = ls_bens-lv_ben1
).

Causes my application to crash with the message "NODE.1.COMPONENTCONTROLLER.BENEFICIARIES does not contain any elements"

However when I view the context I can see the elemtns under the node.

Can anyone see what I am doing wrong?

* declarations for context navigation
  DATA lo_zhr_get_pernr TYPE REF TO if_wd_context_node.
  DATA lo_exporting_1 TYPE REF TO if_wd_context_node.
  DATA lo_beneficiaries TYPE REF TO if_wd_context_node.

* declarations for parameters
  DATA lv_name TYPE text100.

  TYPES: BEGIN OF typ_bens,
    lv_ben1 TYPE zname1,
          lv_ben2 TYPE zname2,
          lv_ben3 TYPE zname3,
          lv_ben4 TYPE zname4,
          lv_ben5 TYPE zname5,
          lv_ben6 TYPE zname6,
          lv_bentype1 TYPE zbentype1,
          lv_bentype2 TYPE zbentype2,
          lv_bentype3 TYPE zbentype3,
          lv_bentype4 TYPE zbentype4,
          lv_bentype5 TYPE zbentype5,
          lv_bentype6 TYPE zbentype6,
          lv_benpct1 TYPE zbenpercn1,
          lv_benpct2 TYPE zbenpercn2,
          lv_benpct3 TYPE zbenpercn3,
          lv_benpct4 TYPE zbenpercn4,
          lv_benpct5 TYPE zbenpercn5,
          lv_benpct6 TYPE zbenpercn6,
    END OF typ_bens.

  DATA lv_pernr TYPE p_pernr.
  DATA ls_bens TYPE typ_bens.

* get all involved child nodes
  lo_zhr_get_pernr = wd_context->get_child_node( wd_this->wdctx_zhr_get_pernr ).
  lo_exporting_1 = lo_zhr_get_pernr->get_child_node( wd_this->wdctx_exporting_1 ).
  lo_beneficiaries = wd_context->get_child_node( wd_this->wdctx_beneficiaries ).

* get input from context

* the invocation - errors are always fatal !!!
  CALL FUNCTION 'ZHR_GET_PERNR'
    EXPORTING
      uname = sy-uname "wd_this->uname2
    IMPORTING
      pernr = lv_pernr
      name 
= lv_name.


* store output to context
  lo_exporting_1->set_attribute(
    EXPORTING
      name  = `NAME`
      value = lv_name ).
  lo_exporting_1->set_attribute(
    EXPORTING
      name  = `PERNR`
      value = lv_pernr ).


  SELECT SINGLE   beneficiary1
                  beneficiary2
                  beneficiary3
                  beneficiary4
                  beneficiary5
                  beneficiary6
                  bentype1
                  bentype2
                  bentype3
                  bentype4
                  bentype5
                  bentype6
                  percentage1
                  percentage2
                  percentage3
                  percentage4
                  percentage5
                  percentage6
   
INTO  ls_bens
   
FROM  pa9011
   
WHERE pernr EQ lv_pernr
     
AND begda LE sy-datum
     
AND endda GE sy-datum.

  IF sy-subrc EQ 0.
* store output to context
    lo_beneficiaries->set_attribute(
      EXPORTING
        name  = `BENEFICIARY1`
        value = ls_bens-lv_ben1
).

......

  ENDIF.

Thanks

A

Accepted Solutions (0)

Answers (2)

Answers (2)

uppu_narayan
Active Participant
0 Kudos

Hi anshul,

    the type of lo_beneficiaries should be if_wd_context_element...

your code should be some what as below where lo_nd_abc is of type if_wd_Context_node and lo_el_abc is of type if_wd_context_element.


*   get element via lead selection
     lo_el_abc = lo_nd_abc->get_element( ).


*   set single attribute
     lo_el_abc->set_attribute(
       name `NAME`
       value = lv_name ).

thanks and regards,

narayan

former_member210804
Active Participant
0 Kudos

Hi Anshul,

What Narayan  said was right. Since you are setting values for the node beneficiaries,

We have to call the method set_attribute from if_wd_context_element not from if_wd_context_node.

let say, You have a node beneficiaries and having attribute 'beneficiaries1'..Follow the below code.

data: lo_nd_beneficiaries type ref to if_wd_context_node,

        lo_el_beneficiaries  type ref to if_wd_context_element.

lo_nd_beneficiaries = wd_context->get_child_node( ' BENEFICIARIES' ).

lo_el_beneficiaries  = lo_nd_beneficiaries->get_element( ).

lo_el_beneficiaries->set_attribute(
      EXPORTING
        name  = `BENEFICIARY1`
        value = ls_bens-lv_ben1
).

Best regards,

Narasimha.

Former Member
0 Kudos

Thanks Narayan,

I've fixed it.

All I did was delete the context node and re-create it and re-bind it.

Not sure what happened there. Maybe it's a bug in the development workbench for WebDynpro because I could see nothing wrong.

Thanks

A


Former Member
0 Kudos

Thank you Narasimha.

I will try that out too.

former_member210804
Active Participant
0 Kudos

Former Member

I think you have not created an attribute 'BENEFICIARY1' in beneficiaries node.

Please check it in component controller.

Best regards,

Narasimha