Skip to Content
avatar image
Former Member

Editable row in ALV

Hi All,

Is there any possibility that only a particular row can be made editable on clicking of a button.

i.e; for example, if i click on display button, the data displayed in ALV should be in read only mode.

But when i click on add button, only the new row inserted should be in editable mode.

Kindly, let me know if this can be achieved.

Thanks in Advance.

Regards,

Durga.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 01, 2010 at 08:51 AM

    HI,

    See this WIKI [ How to use attribute properties in the WD ALV component|http://wiki.sdn.sap.com/wiki/display/WDABAP/SAPListViewer-ALV#SAPListViewer-ALV-HowtouseattributepropertiesintheWDALVcomponent%3F]

    You can bind your attribute property like Read_only,visibility,enabled to the UI Element property.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hallo Ravish,

      My suggestion is to start new discussion as this is someone else discussion.

      The logic which you posted seems correct to set the attributes of all elements in the node. Further i cannot conclude based on this peice of code where you might go wrong.

      Have configured the alv input enabled and i assume that you use inputfield as cell-editor.

      Have binded the cell-editor readonly property to the attribute readonly property.

      So please post in your new discussion about the alv configuration coding involving looping the columns and bindings etc.

      Cheers

  • avatar image
    Former Member
    Dec 01, 2010 at 11:20 AM

    HI,

    You can make it by adding a attribute READ_ONLY in your context node.

    The attribute is of type WDY_BOOLEAN.

    Now when you are populating your data in context node , you make the value of attribute READ_ONLY ABAP_TRUE or ABAP_FALSE.

    like:-

    IF (CONTEXT_NODE NAME -ATTRIBUTE NAME) is NOT INITIAL.

    (CONTEXT_NODE)-READ_ONLY = ABAP_TRUE.

    ELSE.

    IF {CONTEXT_NODE NAME-ATTRIBUTE NAME} IS INITIAL.

    -READ_ONLY = ABAP_FALSE.

    ENDIF.

    ENDIF.

    Based on the value of READ_ONLY your alv row will become read only or editable.

    Now when you are displaying your alv:-

    LO_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_COMP( ).

    IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.

    LO_CMP_USAGE->CREATE_COMPONENT( ).

    ENDIF.

    LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_COMP( ).

    LO_INTERFACECONTROLLER->SET_DATA(

    • only_if_new_descr = " wdy_boolean

    R_NODE_DATA = { YOUR NODE NAME } " ref to if_wd_context_node

    ).

    DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.

    LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(

    ).

    DATA: LS_COLUMN TYPE SALV_WD_S_COLUMN_REF,

    LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF.

    DATA: LR_COLUMN TYPE REF TO CL_SALV_WD_COLUMN.

    DATA LR_INPUT_FIELD TYPE REF TO CL_SALV_WD_UIE_INPUT_FIELD.

    DATA: LR_TABLE_SETTINGS TYPE REF TO IF_SALV_WD_TABLE_SETTINGS.

    • configure columns

    LR_COLUMN_SETTINGS ?= LV_VALUE.

    LT_COLUMNS = LR_COLUMN_SETTINGS->GET_COLUMNS( ).

    LOOP AT LT_COLUMNS INTO LS_COLUMN .

    CASE LS_COLUMN-ID .

    { Now if you want particular activity in any column then do it by each column id }

    WHEN {column name A }.

    CREATE OBJECT LR_INPUT_FIELD EXPORTING VALUE_FIELDNAME = LS_COLUMN-ID .

    LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ID = LS_COLUMN-ID ).

    LR_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

    LR_INPUT_FIELD->SET_READ_ONLY_FIELDNAME( VALUE = 'READ_ONLY' ).

    { As you have to make a column input field to make it editable}

    WHEN 'READ_ONLY'.

    LS_COLUMN-R_COLUMN->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_NONE ).

    CASE OTHERS.

    CREATE OBJECT LR_INPUT_FIELD EXPORTING VALUE_FIELDNAME = LS_COLUMN-ID .

    LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ID = LS_COLUMN-ID ).

    LR_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

    LR_INPUT_FIELD->SET_READ_ONLY_FIELDNAME( VALUE = 'READ_ONLY' ).

    ENDCASE.

    • set read only mode to false (and display edit toolbar)

    LR_TABLE_SETTINGS ?= LV_VALUE.

    LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_FALSE ).

    ENDLOOP.

    Now when you want to make a row read_only or editable , then in that particular event ( as in your case clicking of a button)

    change the value of attribute READ_ONLY to ABAP_TRUE or ABAP_FALSE accordingly.

    Thanks and let me know if you have any concerns.

    Add comment
    10|10000 characters needed characters exceeded