cancel
Showing results for 
Search instead for 
Did you mean: 

Webdynpro ALV UI element property binding to context attribute property

former_member193460
Contributor
0 Kudos


Hi Experts,

     I have this requirement to create a webdynpro applicaiton with more than 40 fields which are editable or read-only based on the data it contains.

The usual method of having attribute of type wdy_boolean isnt applicable as i would need to create attributes for each field (40 more attributes).

i read from the SAP site but dint understand it completely.

in my wddoinit, i have written the below code

  lo_column = lo_column_settings->get_column('/BIC/GBRECCOM').

  CREATE OBJECT lo_input_field
    EXPORTING
      value_fieldname = '/BIC/GBRECCOM'.

  lo_input_field->set_read_only_fieldname( value = '/BIC/GBRECCOM:READ_ONLY' ).
  lo_column->set_cell_editor( lo_input_field ).

after that in my Search event method ( method which populates my alv with data):

Internal table lt_tab1 contains the data from the database

loop at lt_tab1

     into ls_tab1.

  lo_nd_dashboard->bind_structure(
    EXPORTING
      new_item = ls_tab1
      set_initial_elements = abap_false
   RECEIVING
     element = lo_el_dashboard ).

  ls_attribute_properties-attribute_name = '/BIC/GBRECCOM'.
      ls_attribute_properties-visible = abap_true.
      ls_attribute_properties-enabled = abap_true.

      IF open_flag EQ 'X'.
       ls_attribute_properties-read_only = abap_false.
      ELSE.
        ls_attribute_properties-read_only = abap_true.
      ENDIF.

      INSERT ls_attribute_properties
        INTO TABLE lt_attribute_properties.

    lo_el_dashboard->set_attribute_props_for_elem(
    EXPORTING
      properties = lt_attribute_properties ).

    lo_el_dashboard->set_attribute_property(
    EXPORTING
    attribute_name = '/BIC/GBRECCOM'
    property = lo_el_dashboard->e_property-read_only
    value          = 'X' ).

i am not sure how do i do this. please help .. its very urgent and important.

i found this link.. but dint understand it completely.

http://wiki.scn.sap.com/wiki/display/WDABAP/SAP+List+Viewer+-+ALV

REgards,

Tashi

Accepted Solutions (1)

Accepted Solutions (1)

former_member193460
Contributor
0 Kudos

i saw a SAP demo program for this type of binding , i get syntax error when i try in my system. on
a closer analysis , i realized this type of binding for alv is possible after 7.2 version.

So guys working on 7.2 or later, enjoy

former_member193460
Contributor
0 Kudos

Hi Experts,

     i did a demo program for this type of binding for alv(after upgrade to 7.3) and it works seemlessly.

I have created a document for the same and waiting for scn team to approve it and publish it to the pulic as i find this quite useful.

Thanks & Regards,

Tashi

former_member193460
Contributor
0 Kudos

Hi SCN community,

     Find the document for alv context property binding.

Thanks & Regards,

Tashi

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

In the set_read_only_fieldname( ) method, you have to pass the attribute name not the attribute property.

Create an attribute in the context say, ENABLE with type wdy_boolean and pass this to the method set_read_only_fieldname( )

lo_input_field->set_read_only_fieldname( value = 'ENABLE' ).


Then set the attribute ENABLE to abap_true/ abap_false based on condition.


Check this wiki for reference: http://wiki.scn.sap.com/wiki/display/WDABAP/How+to+edit+conditionally+row+of+a+ALV+table+in+Web+Dynp...


Hope this helps u,



Regards,

Kiran

former_member193460
Contributor
0 Kudos

Hi Kiran,

     i am aware of the approach to create a boolean attribute to open or close a cell in alv, but my requirement has 25 fields which needs to be open or close depended on their respective business condition.

all fields are treated seperately to open or close.

So i was thinking to use the property of context attribute which i did  a little reading on, but unfortunately i still havent figure out the way to do so.

Please help me with the approach of property binding where i dont have to create attributes (in my case i have to create 25 attributes of type boolean which are mapped to their respecitive field.)

regards.,

Tashi

former_member184578
Active Contributor
0 Kudos

Hi,

In your search event handler method, I believe  open_flag is a column in the ALV table.

Try this below code:


LOOP AT lt_tab1 INTO ls_tab1.

     IF ls_tab1-open_flag EQ 'X'.

       ls_attribute_properties-read_only = abap_false.

     ELSE.

       ls_attribute_properties-read_only = abap_true.

     ENDIF.

     lo_el_dashboard = lo_nd_flight->get_element( index = sy-tabix ).

     lo_el_dashboard->set_attribute_property(

     EXPORTING

     attribute_name = '/BIC/GBRECCOM'

     property = lo_el_dashboard->e_property-read_only

     value          = 'X' ).

    

ENDLOOP.

this should work.

Regards,

Kiran

former_member193460
Contributor
0 Kudos

i have done the same thing, but its not working.

i want to confirm how the property of attribute is mapped to the UI property of ALV input.

This is the way i have done currently,

lo_column = lo_column_settings->get_column('/BIC/GBRECCOM').

  CREATE OBJECT lo_input_field
    EXPORTING
      value_fieldname = '/BIC/GBRECCOM'.

lo_input_field->set_read_only_fieldname( value = '/BIC/GBRECCOM:READ_ONLY' ).
  lo_column->set_cell_editor( lo_input_field ).

i am not sure about the "Bold" statement above, Is this how we map an attribute property to UI element ?

Please hlep

former_member184578
Active Contributor
0 Kudos

Hi,

It's the correct way of binding to attribute property. Is your column ( /BIC/GBRECCOM ) changing to input editable ? I guess, you have not changed the ALV to editable ALV!

Write the below code:

lr_model->if_salv_wd_table_settings~set_read_only( abap_false ). " to make ALV editable

If this is not working, please share your complete DOINIT code.

Regards,

Kiran

former_member193460
Contributor
0 Kudos


The WDDOINIT method has pattern of below code for all the fields.

    lo_column = lo_column_settings->get_column('/BIC/GBRECCOM').

  CREATE OBJECT lo_input_field
    EXPORTING
      value_fieldname = '/BIC/GBRECCOM'.

  lo_input_field->set_read_only_fieldname( value = '/BIC/GBRECCOM:READ_ONLY' ).
  lo_column->set_cell_editor( lo_input_field ).
  lo_column->set_cell_design_fieldname( value = 'CELL_COLOR' ).

On launch, the ALV is set to read_only FALSE

  wd_this->lo_value->if_salv_wd_table_settings~set_read_only(
      value  = abap_false ).

If the property binding is correct, then Can you please have a relook at my search event code.

i havent used bind_table , instead i have used bind_structure and the return value is a node element.

That node element i am using to set the attribute property.

SEARCH METHOD:

LOOP at itab

lo_nd_dashboard->bind_structure(
    EXPORTING
      new_item = ls_tab1
      set_initial_elements = abap_false
   RECEIVING
     element = lo_el_dashboard ).

lo_el_dashboard->set_attribute_property(

    EXPORTING

    attribute_name = '/BIC/GBRECCOM'

    property = lo_el_dashboard->e_property-read_only

    value          = 'X' ).

ENDLOOP.

Please help ...

former_member184578
Active Contributor
0 Kudos

Hi,

Your DOINIT method looks fine, as mentioned in my earlier reply, use the below code to get the element reference in loop.

lo_el_dashboard = lo_nd_dashboard->get_element( index = sy-tabix ).



In your current code the binding is done before setting the attribute property.

Regards,

Kiran

former_member193460
Contributor
0 Kudos


Hi Kiran,

     when i click on the search button, i get all the data ffrom the table.

The node is empty  and is populated only after clicking the search button.

So i am looping the internal table which is as a result of DB access.

Every line in the internal table, i am using to bind to the node and consequently an element is created.

The same element i am trying to set the property.

Please let me know how do i achieve for this scenario.

regards,

Tashi

former_member184578
Active Contributor
0 Kudos

Hello,

As mentioned in my earlier replies use the method get_element( ) for reading the context element not the bind_structure( ).

SEARCH METHOD:



* Populate Itab.

* bind the Itab to the Node using bind_table ( ).

lo_nd_dashboard->bind_table( itab ).


LOOP at itab into ls_tab.


lo_el_dashboard = lo_nd_dashboard->get_element( index = sy-tabix ).


If ls_tab-open_flag = abap_true.

*to make editable

lo_el_dashboard->set_attribute_property(

    EXPORTING

    attribute_name = '/BIC/GBRECCOM'

    property = lo_el_dashboard->e_property-read_only

    value          = abap_false ).

else.

*to make read only

lo_el_dashboard->set_attribute_property(

    EXPORTING

    attribute_name = '/BIC/GBRECCOM'

    property = lo_el_dashboard->e_property-read_only

    value          = abap_true ).

ENDLOOP.

Regards,

Kiran

former_member193460
Contributor
0 Kudos


Hi Kiran,

     Thanks for your reply, but i am still not able to get it done

i did something similar ( i tried on element directly as well).

   l_count = lo_nd_dashboard->get_element_count( ).

  DO l_count TIMES.

    ADD 1 TO l_index.
    CLEAR ls_attribute_properties.
    ls_attribute_properties-element_index = l_index.

    ls_attribute_properties-attribute_name = '/BIC/GBRECCOM'.

    ls_attribute_properties-visible = abap_true.
    ls_attribute_properties-read_only = abap_true.
    ls_attribute_properties-enabled = abap_true.
    INSERT ls_attribute_properties INTO TABLE lt_attribute_properties.

  ENDDO.

  IF lt_attribute_properties IS NOT INITIAL.
    lo_nd_dashboard->set_attribute_props_for_node( lt_attribute_properties ).
  ENDIF.

Do i have to do anything else ?

in the init method ,

lo_input_field->set_read_only_fieldname( value = '/BIC/GBRECCOM:READ_ONLY' ).

Please help

Tashi

Former Member
0 Kudos

Hi Tashi,

Please try below line:

lo_input_field->set_read_only_fieldname( value = ' /BIC/GBRECCOM:'READ_ONLY'' ).


Thank you,

Gajendra.