cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot access Created Context Attribute from Component Controller

Former Member
0 Kudos

Hello All,

I have added a new attribute to a node in my component controller 'LOGONUID' and I cannot access it within my windows within the WDA application.



DATA lo_nd_url_param TYPE REF TO if_wd_context_node.
  DATA ls_workset TYPE wd_this->element_workset.
  "DATA ls_logonuid TYPE wd_this->element_logonuid.

 

I get an error as soon as I try to activate this code in my method in my W_MAIN

In my component controller I do not see it reference in the SAP generated code in my WD_THIS IF_COMPONENTCONTROLLER?


* Intf.: ig_componentcontroller
* Purp.: programming interface for access of this controller within
*        other controllers of the same component
*        controller:  <COMPONENTCONTROLLER> of
*        component:   <zhr_wd_mss>
* UDate: 20111207 145441
*=====================================================================*
interface ig_componentcontroller.

  interfaces: ziwci_hr_wd_mss .
  constants:
    wdctx_context type string value `CONTEXT`.
  constants:
    wdctx_cuifcontext type string value `CUIFCONTEXT`.
  types:
    begin of Element_cuifcontext,
      USERID  type String,
      LASTEVENTOPERATION  type String,
    end of Element_cuifcontext,
    Elements_cuifcontext type
       standard table of Element_cuifcontext
       with default key.
  constants:
    wdctx_messages type string value `MESSAGES`.
  types:
    Element_messages type ZHR_S_MESSAGE,
    Elements_messages type
       standard table of Element_messages
       with default key.
  constants:
    wdctx_workset type string value `WORKSET`.

I want it to be declared as the constant 'WORKSET'

thank you

Edited by: Keith Warnock on Dec 7, 2011 8:55 PM

Edited by: Keith Warnock on Dec 7, 2011 8:56 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

> I have added a new attribute to a node in my component controller 'LOGONUID' and I cannot access it within my windows within the WDA application.

>

>


> 
> DATA lo_nd_url_param TYPE REF TO if_wd_context_node.
>   DATA ls_workset TYPE wd_this->element_workset.
>   "DATA ls_logonuid TYPE wd_this->element_logonuid.
> 
>  

>

This declaration is not right. There is no element logonuid, you have the attribute inside a node. workset is a node and thats why you can declare that way.

easiest way is to declate

data lv_logonuid type <ddic type> or

data lv_logonuid type wd_this-><node name>-logonuid.

You can also use the code generator in (CTRL +F7 ) to get/set attributes.

Former Member
0 Kudos

you're right Baskaran, I did have that wrong.

The problem I am running into now is accessing the attribute of the context.


  CLEAR wa_parameter.
  READ TABLE it_parameter WITH KEY name = 'LOGONUID' INTO wa_parameter.
  IF sy-subrc EQ 0.
    ls_workset-logonuid = wa_parameter-value.
  ENDIF.

*--Save LOGONUID parameter to context
  lo_nd_url_param = wd_context->get_child_node(  name = wd_this->wdctx_logonuid  ).
  lo_nd_url_param->set_static_attributes(
     static_attributes = ls_workset ).	

My Problem is that, it does not think that wdctx_logonuid exists although I have added as a attribute to my node?

See post above that SAP generated code does not show it as a constant?

Former Member
0 Kudos

hi everyone,

I got mixed up... I was thinking that I was referencing the ATTRIBUTE and not the entire NODE.

This code here corrected my issue:


  " Get parameter values
  CLEAR wa_parameter.
  READ TABLE it_parameter WITH KEY name = 'WORKSETID' INTO wa_parameter.
  IF sy-subrc EQ 0.
    ls_workset-worksetid = wa_parameter-value.
  ENDIF.

*---------------------- END OF  todo ------------------------
  " Get parameter values
  CLEAR wa_parameter.
  READ TABLE it_parameter WITH KEY name = 'LOGONUID' INTO wa_parameter.
  IF sy-subrc EQ 0.
    ls_workset-logonuid = wa_parameter-value.
  ENDIF.
*---------------------- END OF  todo ------------------------

*--Save URL parameter to context
  lo_nd_url_param = wd_context->get_child_node(  name = wd_this->wdctx_workset  ).
  lo_nd_url_param->set_static_attributes(
     static_attributes = ls_workset ).

Answers (0)