cancel
Showing results for 
Search instead for 
Did you mean: 

How to Disable the Row in Web Dynpro ABAP ALV?

KiranJ
Active Participant
0 Kudos

Hai Experts,

In my Screen Have the Web Dynpro ALV in that one Column As Check Box,

an another Column as Order number, whn we select the check box if order number is ther in that

Row that Row should be in disable mode if Order number is doesn't there in that row that check box shoud be in

select mode.

Plz help me h do it.

Thanks in Adv...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sree,

I think, Table row disable functionality is not possible. Let's wait for any other reply if they have some option to do this functionality, meantime you can detelete the ALV table row by using ABAP coding in the backend as aditya suggested.

Although we can disable the table column by using set_column_selection_allowed of class CL_SALV_WD_CONFIG_TABLE(as shown below alv_conf_table is type CL_SALV_WD_CONFIG_TABLE).

  • show tab COLUMN SELECTION in Settings page

CALL METHOD wd_this->alv_conf_table->if_salv_wd_std_functions~set_column_selection_allowed

EXPORTING value = ABAP_false..

Answers (6)

Answers (6)

Former Member
0 Kudos

Sample Code for Previous Post:

METHOD wddomodifyview.

* First Time View is Rendered
  IF first_time = abap_true.

*   Set Initial Selectable Rows
    wd_this->set_selectable_rows( ).

*   Modify Standard ALV Table Settings
    wd_this->alv_table_settings( ).

  ENDIF.

ENDMETHOD.


METHOD set_selectable_rows.

* Data Declarations
  DATA: lo_nd_context_node TYPE REF TO if_wd_context_node, "Context Node Reference for ALV Data
        lt_context_node    TYPE  wd_this->elements_context_node, "Internal Table for Context Node Data
        lx_context_node    TYPE  wd_this->element_context_node.  "Work Area for Line of Context Node Data

* Navigate from the Context to the Context Node
  lo_nd_context_node = wd_context->get_child_node( name = wd_this->wdctx_context_node ).

* Get Node Data and place in an Internal Table
  lo_nd_context_node->get_static_attributes_table( IMPORTING table = lt_context_node ).

* Loop through the Internal Table Data of the Context Node
  LOOP AT lt_context_node INTO lx_context_node.

******** INSERT CONDITIONS FOR ROW SELECTION HERE *********

*   Row is Selectable
    IF sy-subrc = 0. "***Sample Condition Only***

*     Set the Row Selectable Attribute to True
      lx_context_node-row_selectable = abap_true. "row_selectable is a context attribute of type WDY_BOOLEAN
    
*   Row is NOT Selectable
    ELSE.

*     Set the Row Selectable Attribute to False
      lx_context_node-row_selectable = abap_false.

    ENDIF.

***********************************************************

*   Modify the Internal Table with Updated Row Selection Availability
    MODIFY lt_context_node FROM lx_context_node.

*   Clear the used Work Area
    CLEAR lx_context_node.

  ENDLOOP.

* Bind the Updated Internal Table Data back to Context Node
  lo_nd_context_node->bind_table( new_items = lt_context_node
                                  set_initial_elements = abap_true).

* Clear Internal Table Data After Use
  FREE lt_context_node.

ENDMETHOD.


METHOD alv_table_settings .

  DATA: lo_cmp_usage TYPE REF TO if_wd_component_usage,
	lo_interface TYPE REF TO iwci_salv_wd_table,
        lo_interfacecontroller   TYPE REF TO iwci_salv_wd_table..

  lo_cmp_usage = wd_this->wd_cpuse_alv_table( ). "Componenet Usage Created for the ALV

  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

  lo_interface = wd_this->wd_cpifc_alv_table( ).

* Get Configuration Model from ALV Component: This reference is used to set ALV properties
  lo_value = lo_interface->get_model( ).

********** Change Table Settings **********

* Set the selection type to Multiple - No Lead in the ALV
  lo_value->if_salv_wd_table_settings~set_selection_mode( cl_wd_table=>e_selection_mode-multi_no_lead ).

* Set the Selectable Rows in the ALV Table Settings
  lo_value->if_salv_wd_table_settings~set_row_selectable_fieldname( 'ROW_SELECTABLE' ).

*******************************************

********** Change Column Settings *********

* Initial Column Settings
  DATA lo_column_settings TYPE REF TO if_salv_wd_column_settings.
  lo_column_settings ?= lo_value.

* Declare a table of column settings - each line one column
  DATA lt_columns TYPE salv_wd_t_column_ref.

  lt_columns = lo_column_settings->get_columns( ).

  DATA: lw_column       TYPE salv_wd_s_column_ref,
        lo_comp_scr_hdr TYPE REF TO cl_salv_wd_column_header.
  LOOP AT lt_columns INTO lw_column.
    CASE lw_column-id.
      WHEN 'ROW_SELECTABLE'.
	lo_comp_scr_hdr = lw_column-r_column->get_header( ).
        lo_comp_scr_hdr->set_visible( cl_wd_uielement=>e_visible-none ). "Set Column to not Appear in ALV
      WHEN OTHERS.
    ENDCASE.
  ENDLOOP.

*******************************************

ENDMETHOD.

Former Member
0 Kudos

What you are going to want to do first is create and additional attribute in the context node that is holding your ALV data. Set the attribute type to WDY_BOOLEAN. This will allow you to store a flag in the attribute that will eventually set that row as either being selectable or not. If your context node is already created in the Component Controller you will need to update the mapping in the View and update the DATA binding for the INTERFACECONTROLLER_USAGE used to display the ALV.

After that is done you will want to create a method (set_selectable_rows) to set which rows were allowed to be selected. Place the call to that method in the WDDOMODIFYVIEW method. I could only get the disable row selection to function properly if I placed my methods calls in the condition which executes only on the first time the WDDOMODIFYVIEW is run. I highlighted the section where you would want to place your conditions for setting which rows are selectable. In the method to set the selectable rows is where you will set the value in the Context Attribute you just created to either ABAP_TRUE or ABAP_FALSE depending on whether or not you want that row to be selectable. I highlighted the section where you would want to place your conditions for setting which rows are selectable. Please note that the set selectable rows method needs to be executed AFTER data has already been bound to the context node for the ALV data.

I created an additional method to change my initial ALV settings and also placed that method call in the WDDOMODIFYVIEW method just after the method to set the selectable rows. The method to change the inital ALV settings is where you will use if_salv_wd_table_settings~set_row_selectable_fieldname( 'ROW_SELECTABLE' ). ROW_SELECTABLE is the name of the context attribute created in the Node that holds the ALV data. I set the column for that attribute in the ALV to invisible since it is only used to hold a flag.

If there are any Actions that will update which rows are selectable in the ALV then you will want to have conditions in the Action to set the flag of the context attribute that makes that row selectable or not. The code for these conditions will be similar to the code in the set_selectable_rows method.

See the sample code in the next post. I hope this helps you out.

KiranJ
Active Participant
0 Kudos

Thank q u.

Manogna,

thats not working .

at the time of dispalying the table that time ,if ordernumber is there that row 'll be in or check box is disable mode,

else order number is not there then select that check box and create the check box . that is the my requiredment .

any inputs....

Former Member
0 Kudos

Hi Sree

Take one attribute Readonly type WDY_BOOLEAN

If order_number is initial.

itab-readonly = 'X'.

else.

tab-readonly = ' '.

endif.

KiranJ
Active Participant
0 Kudos

Thank q u very much for inputs,

i alredy tryed with For this, SET_ENABLED_FIELDNAME of CL_SALV_WD_UIE_CHECKBOX at the time of ALV initialization.

whn ever we select the check box that time only check box 'll be in disable mode .

plz help me...

former_member1151507
Participant
0 Kudos

Sorry!

Last point I've mentioned in my last post is incorrect.

We have to restrict the user at the time of selection itself. For this, we can set the FLAG attribute in WDDOMODIFYVIEW.

Here, get the table values and run the loop. Based on the Order number, set the FLAG.

Regards,

Manogna

former_member1151507
Participant
0 Kudos

Hi,

As per your requirement, you want to allow the user to select only those records for which order number is not there.

One simple solution for this would be: Disable the check box if Order number is there, else enable the check box.

-> For this, we can use SET_ENABLED_FIELDNAME of CL_SALV_WD_UIE_CHECKBOX at the time of ALV initialization.

lo_column = lo_column_settings->get_column( 'SELECTION' ).

CREATE OBJECT lr_checkbox

EXPORTING

checked_fieldname = 'SELECTION'.

lo_column->set_cell_editor( lr_checkbox ).

lr_checkbox->SET_ENABLED_FIELDNAME( 'FLAG' ).

-> Create one attribute (for eg: FLAG) of type WDY_BOOLEAN and assign the attribute in SET_ENABLED_FIELDNAME method.

-> Now, create an even handler fot the event ON_CELL_ACTION and set the FLAG value accordingly.

Regards,

Manogna

Former Member
0 Kudos

Hi,

You can use "ON_CELL_ACTION" event.

In the handler , you can use a parameter named "R_PARAM" of type "IF_SALV_WD_TABLE_CELL_ACTION"..This parameter has the index of row selected.

Once you have the row selected , you can loop through your internal table with R_PARAM as index which has the ALV data and check if order number is valid.

But I am actually not sure how you would disable a row.(not sure if it is possible also).

Because I did not find any method in "cl_salv_wd_config_table" which disables a particular row.Altough entire ALV can be made readonly.

cheers,

Aditya.l