cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamics attributes in a ALV component

Former Member
0 Kudos

Hi Guys,

I am triying to set dynamically two attributes that I have loaded dynamically. If I set them manually I can get the values, but when I want to set a value, my ALV doesn´t show this chage and the context contain these values but only for dynamic fields. When I use static attributes I can modify without problems.

How could I set these dynamic values like static ones?

Thanks,

Sergio.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Are U saying that u have a dynamic ALV , and u are setting the attributes of the cell dynamically but when u have the value in that cell the attributes are not working .

I am not clear with ur question . Can u explain it ?

Regards ,

Suvendu Chakraborty

Former Member
0 Kudos

I have en structutre that I increase dynamically and show in my ALV. These new fields are booleans, so they appear like checkboxes. When I check them I could get they corresponding value "abap_true". The problem that I have is when I set one on the code with set_attribute( name= 'Field1'  value="abap_true") then they appear unchecked. An example. I have the following entity:

  • ID
  • Name
  • Last_Name

Then I add dynamically a boolean variable

  • Single

Until this step the ALV show correctly a table with 4 columns and "single" appears like a checkbox and I can check or uncheck it and then I can get its corresponding value "X" or space.

The problem is when I try to set this value on the code. I assign to the context but the ALV doesn´t refresh correctly. If I debbug I have this value assigned to the field but I can´t see it in the ALV.

Kind regards,

Sergio.

0 Kudos

Try to check the data type of the checkbox field . Is the data type of the checkbox field in the ALV is correct?

After getting all the components for the ALV in structure change the data type as follows :

LOOP AT it_component INTO wa_component.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = wa_component-name .
CASE wa_component-type_kind.
WHEN 'C'.
wa_fieldcat-datatype =
'CHAR'.
WHEN 'N'.
wa_fieldcat-datatype =
'NUMC'.
WHEN 'D'.
wa_fieldcat-datatype =
'DATE'.
WHEN 'P'.
wa_fieldcat-datatype =
'PACK'.
WHEN OTHERS.
wa_fieldcat-datatype = wa_component-type_kind.
ENDCASE.
wa_fieldcat-inttype = wa_component-type_kind.
wa_fieldcat-intlen = wa_component-length.
wa_fieldcat-
decimals = wa_component-decimals.
APPEND wa_fieldcat TO it_fieldcat.
ENDLOOP.

Suvendu Chakraborty

Former Member
0 Kudos

Hello,

This is a documented limitation of the ALV.  It does not support Dynamic Attributes and static attribute at the same time.

Instead of using dynamic attributes, consider instead dynmically generating the entire context node.  Using the RTTS you can build a dynamic type that is a combination of all the fields you need.  You can then use this dynamic data type as the source of the context and all the attributes will be consider static.

For this you can use..

DATA:

   rootnode_info TYPE REF TO if_wd_context_node_info,

   dyn_node      TYPE REF TO if_wd_context_node,

   tabname_node  TYPE REF TO if_wd_context_node,

   struct_type   TYPE REF TO cl_abap_structdescr,

   comp_tab      TYPE cl_abap_structdescr=>component_table,

   comp          LIKE LINE OF comp_tab.

   comp-name = 'FLD1'.

   comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).

   APPEND comp TO comp_tab.

   comp-name = 'FLD2'.

  

   comp-type ?= cl_abap_datadescr=>describe_by_name( 'STRING' ).

   APPEND comp TO comp_tab.

  

*Code for getting node info of root node

   rootnode_info = wd_context->get_node_info( ).

*Code for creating a new node with structure defined in comp_tab

   struct_type = cl_abap_structdescr=>create( comp_tab ).

   rootnode_info = rootnode_info->add_new_child_node(

   name = 'NEW_NODE'

   is_mandatory = abap_true

   is_multiple = abap_true

   static_element_rtti = struct_type

   is_static = abap_false

   ).

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

And in the end use set_data of interface controller

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

  

    lo_cmp_usage = wd_this->wd_cpuse_alv( ).

   IF lo_cmp_usage->has_active_component( ) IS INITIAL.

     lo_cmp_usage->create_component( ).

   ENDIF.

   DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

   lo_interfacecontroller = wd_this->wd_cpifc_alv( ).

   lo_interfacecontroller->set_data(

* only_if_new_descr = " wdy_boolean

   "r_node_data =

   dyn_node " ref to if_wd_context_node

   ).

I hope this helps you....

kutjohn
Active Participant
0 Kudos

Hi

Can you please share the screen shot of your code and the view?

Answers (0)