cancel
Showing results for 
Search instead for 
Did you mean: 

how to change the value of an attribute node added to a dynamic

0 Kudos

Hello my friends.

I created a dynamic node based on a table "ZTABLE" set up in the dictionary.

The structure of "ZTABLE" is

ZTABLE-FIELD1 - KEY

ZTABLE-FIELD2

ZTABLE-FIELD3


   cl_wd_dynamic_tool=>create_nodeinfo_from_struct( parent_info    = rootnode_info
                                                    node_name      = 'ZNODE'
                                                    structure_name = 'ZTABLE'
                                                    is_multiple    = abap_true ).

Then I added one field to use as READ_ONLY.

DATA:
*Context Nodes
    dyn_node       TYPE REF TO if_wd_context_node_info,
    dyn_node_table TYPE REF TO if_wd_context_node_info,
    ls_attribute   TYPE        wdr_context_attribute_info.

   dyn_node = wd_context->get_node_info( ).
   dyn_node_table = dyn_node->get_child_node( ZNODE ).

MOVE: 'RO_FIELD1' TO ls_attribute-name,
           'WDY_BOOLEAN'    TO ls_attribute-type_name,
           abap_true        TO ls_attribute-default_value.

     dyn_node_table->add_attribute( attribute_info = ls_attribute ).

My node ZNODE is.

ZNODEFIELD1 - KEY

ZNODE-FIELD2

ZNODE-FIELD3

ZNODE-RO_FIELD1

I selected data from table ZTABLE to node ZNODE, but i need to change the attibute 'RO_FIELD'


What better way to get the values ​​of this node and how do I change the attribute value RO_FIELD1?

I recovered from the node values​​.
But the value of the field "RO_FIELD1" did not come.
I need to change this value.

Thanks for the help.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi.....

The solution found.

Create Attribute LO_STRUCT_TYPE.

Create NODE.

METHOD ysm_create_node .

   DATA lt_comp TYPE cl_abap_structdescr=>component_table.
   DATA ls_comp LIKE LINE OF lt_comp.

   DATA ls_new  TYPE dd03p.

   DATA lo_root_info TYPE REF TO if_wd_context_node_info.

* Query the RTTS for the structure of the Input Table
   DATA: descriptor TYPE REF TO cl_abap_structdescr.
   descriptor ?= cl_abap_structdescr=>describe_by_name( "TABLE_NAME" ).
   DATA: flddescr    TYPE ddfields,
         ls_flddescr LIKE LINE OF flddescr.
   flddescr = descriptor->get_ddic_field_list( ).

   LOOP AT flddescr INTO ls_flddescr.

     ls_comp-name = ls_flddescr-fieldname.
     ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_flddescr-rollname ).
     APPEND ls_comp TO lt_comp.

   ENDLOOP.

Create attribute.

Get key fields.

CALL FUNCTION 'CUTA_DD_TABLE_KEYFIELDS_GET'
     EXPORTING
       dbtab_name           = lc_tablename
       exclude_client_field = 'X'
     TABLES
       keyfields            = wd_this->ti_key_fields.

LOOP AT wd_this->ti_key_fields INTO ls_new.

     CONCATENATE 'ROATR_' ls_new-fieldname INTO ls_new-fieldname.

     ls_comp-name = ls_new-fieldname.
     ls_comp-type ?= cl_abap_datadescr=>describe_by_name( 'WDY_BOOLEAN' ).
     APPEND ls_comp TO lt_comp.

   ENDLOOP.

   wd_this->lo_struct_type = cl_abap_structdescr=>create( p_components = lt_comp ).

*  Create a new node using this structure;
   lo_root_info = wd_context->get_node_info( ).
   CALL METHOD lo_root_info->add_new_child_node
     EXPORTING
       name                         = 'Z_NODE'
       is_initialize_lead_selection = abap_true
       static_element_rtti          = wd_this->lo_struct_type
       is_static                    = abap_false
       is_multiple                  = abap_true
       is_mandatory                 = abap_true.

ENDMETHOD.

Regards.

Ferreira

Answers (1)

Answers (1)

former_member213957
Participant
0 Kudos

Hi Ferreira,

Here your question sink is missing.

Please mention   1. data type of  RO_FIELD

                             2. are you displaying ro_field in the table or not .

                                if yes, that field column displaying as a textview or other?

                             3. purpose of this field.

the solution is ready here base on the your requirement!!!

Regards,

Kishorekumar

0 Kudos

The fields are dynamic and can contain any TYPE.

I found the solution.

Thanks for the help.

Regards.

Ferreira.