cancel
Showing results for 
Search instead for 
Did you mean: 

how to get static attributes from dynamic node in wda

Former Member
0 Kudos

hi:

   I have created a dynamic node which name  as 'NEW_CODE' and displayed in alv.

   Now I created an eventhandler method for the event ON_CLICK of the ALV  and how to get static attributes from dynamic node in the method of   on_click

 
   how to do.

     

       thanks!!

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Dear Huang,

And anybody who arrives to this SCN post.

This works very well

I could kiss you buddy, I have been trying to get this working for some time.

Thanks for sharing the correct answer.

Best regards.

Former Member
0 Kudos


hi:

Problem has been resolved

the code:

       

DATA:

       dyn_node     TYPE REF TO if_wd_context_node

     , node_info    TYPE REF TO if_wd_context_node_info

     , struct_type  TYPE REF TO cl_abap_structdescr

     , table_type   TYPE REF TO cl_abap_tabledescr

     , t_newtable   TYPE REF TO data

     , t_newline    TYPE REF TO data

   .

  FIELD-SYMBOLS:

       <t_data> TYPE STANDARD TABLE,

     <fs_data> TYPE any,

       <FS_ZCYN> TYPE ANY,

     <fs_checkbox> TYPE wdy_boolean.









   dyn_node = wd_context->get_child_node( name = 'NEW_NODE' ).

   node_info = dyn_node->get_node_info( ).

   struct_type = node_info->get_static_attributes_type( ).

   table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).

   CREATE DATA t_newtable TYPE HANDLE table_type.

   ASSIGN t_newtable->* TO <t_data>.

   CREATE DATA t_newline TYPE HANDLE struct_type.

   ASSIGN t_newline->* TO <fs_data>.

*   ASSIGN COMPONENT 'ATTRIBUTE_NAME' OF STRUCTURE <fs_data> TO <fs_checkbox>.

*   dyn_node->get_static_attributes_table( IMPORTING table = <t_data> ).

   CALL METHOD dyn_node->get_static_attributes

      EXPORTING

        INDEX = R_PARAM->INDEX

      IMPORTING

        STATIC_ATTRIBUTES = <fs_data>.

harsha_jalakam
Active Contributor
0 Kudos

Hi Huang,

Please follow the below snipped for fetching the static attributes of the clicked row/element.

Data lo_element type ref to if_wd_context_element.

Data lo_node type ref to if_wd_context_node.

Data ls_struc type wd_this->Element_name.

lo_node = wd_context->get_child_node( name = wd_this->wdctx_node_name ).

lo_element = wd_event->get_context_element( name = 'CONTEXT_ELEMENT' ).

lo_node->set_lead_selection( Exporting element = lo_element ).

lo_element->get_static_attributes( importing static_attributes = ls_struc ).

Regards,

Harsha

Former Member
0 Kudos

hi:Harsha

    Thank you for your reply!

    But my question is which have created a dynamic node as  'NEW_CODE' and have displayed in alv. I want to get get static attributes of 'NEW_CODE'  when click alv cell.

your code:

                 Data ls_struc type wd_this->Element_name is failed

                 Because node is dynamicl

harsha_jalakam
Active Contributor
0 Kudos

Hi Huang,

In that scenario you can give ls_struc type as a structure type of the node or a local work area must be declared similar to that of node type.and while accessing node, access it through name instead of path,


Data lo_element type ref to if_wd_context_element.

Data lo_node type ref to if_wd_context_node.

Data ls_struc type local_wa .


lo_node = wd_context->get_child_node( name = 'NODE_NAME'). " Name of the node ,


lo_element = wd_event->get_context_element( name = 'CONTEXT_ELEMENT' ).

lo_node->set_lead_selection( Exporting element = lo_element ).

lo_element->get_static_attributes( importing static_attributes = ls_struc ).

Regards,

Harsha

Former Member
0 Kudos

hi:Harsha

    Thank you for your reply!

  MY CODE IN the method of on_click:Because node is dynamicl,

     ES_RESULT  which I do not know how to define?

  DATA: LR_NODE TYPE REF TO IF_WD_CONTEXT_NODE.
  DATA LO_EL TYPE REF TO IF_WD_CONTEXT_ELEMENT.
  LR_NODE = wd_context->get_child_node( name = 'NEW_NODE').
  CHECK LR_NODE IS NOT INITIAL.
  LO_EL = LO_NODE->GET_ELEMENT( ).
  IF LO_EL IS BOUND.
    LO_EL->GET_STATIC_ATTRIBUTES(
    EXPORTING
      index = R_PARAM->index
    IMPORTING
      STATIC_ATTRIBUTES = ES_RESULT ).
  ENDIF.

harsha_jalakam
Active Contributor
0 Kudos

Hi Huang,

Interface IF_CONTEXT_NODE_INFO can be used to get the data from a dynamic node, please check the last section of the below ink, which exactly fulfills your requirement.

Regards,

Harsha