Skip to Content
author's profile photo Former Member
Former Member

ALV editable & reading it aagain

Hi All,

How to make ALV grid field editable & how to make that field obligatory. How to read that whole grid into our internal table after entering the values in editable field?

Regards,

Dilip

Message was edited by: Diliip Gupchup

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Nov 18, 2005 at 05:36 AM

    Hi,

    DATA: i_fieldcat TYPE slis_t_fieldcat_alv.

    DATA: line_fieldcat TYPE slis_fieldcat_alv.

    CLEAR line_fieldcat.

    line_fieldcat-fieldname = 'CHK'.

    line_fieldcat-tabname = 'I_DATA'.

    line_fieldcat-seltext_l = 'Checkbox'.

    line_fieldcat-checkbox = 'X'. " Display this field as a checkbox

    line_fieldcat-edit = 'X'. " This option ensures that you can

    " edit the checkbox. Else it will

    " be protected.

    APPEND line_fieldcat TO i_fieldcat.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 18, 2005 at 05:47 AM

    Hi,

    You need to capture the modified cells in the following event.

    CLASS lcl_event_handler IMPLEMENTATION .

    *--Handle Data Changed METHOD handle_data_changed . PERFORM handle_data_changed USING er_data_changed . ENDMETHOD.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 18, 2005 at 07:54 AM

    hi Dilip,

    In ur field catalog U need to specify it as

    EDIT = 'X'.

    and for getting the changes in editable field.

    u need to do couple of things.

    ----


    • CLASS lcl_event_handler DEFINITION

    ----


    CLASS LCL_EVENT_HANDLER DEFINITION .

    PUBLIC SECTION .

    METHODS:

    **Handler to Check the Data Change

    HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED

    OF CL_GUI_ALV_GRID

    IMPORTING ER_DATA_CHANGED

    E_ONF4

    E_ONF4_BEFORE

    E_ONF4_AFTER,

    HANDLE_TOOLBAR

    FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID

    IMPORTING E_OBJECT E_INTERACTIVE.

    ENDCLASS. "lcl_event_handler DEFINITION

    ----


    • CLASS lcl_event_handler IMPLEMENTATION

    ----


    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.

    **Handle Data Change

    METHOD HANDLE_DATA_CHANGED.

    DATA: X_CHANGE TYPE LVC_S_MODI,

    X_FINAL TYPE T_FINAL,

    X_OCRC TYPE ZSD_OC_HOLD,

    L_FLAG.

    LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.

    IF X_CHANGE-FIELDNAME = 'ZZOCHOLDRC'.

    READ TABLE IT_FINAL INTO X_FINAL INDEX X_CHANGE-ROW_ID.

    IF SY-SUBRC = 0.

    READ TABLE IT_OCRC INTO X_OCRC WITH KEY

    ZZOCHOLDRC = X_CHANGE-VALUE

    TRANSPORTING ZZRCDESC.

    IF SY-SUBRC = 0.

    X_FINAL-ZZRCDESC = X_OCRC-ZZRCDESC.

    MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID

    TRANSPORTING ZZRCDESC.

    L_FLAG = 'X'.

    ENDIF.

    ENDIF.

    ENDIF.

    IF X_CHANGE-FIELDNAME = 'ZZPROMDT'.

    READ TABLE IT_FINAL INTO X_FINAL INDEX X_CHANGE-ROW_ID.

    IF SY-SUBRC = 0.

    X_FINAL-ZZPROMDT = X_CHANGE-VALUE.

    MODIFY IT_FINAL FROM X_FINAL INDEX X_CHANGE-ROW_ID

    TRANSPORTING ZZPROMDT.

    L_FLAG = 'X'.

    ENDIF.

    ENDIF.

    ENDLOOP.

    IF L_FLAG = 'X'.

    CLEAR V_DATA_CHANGE.

    V_DATA_CHANGE = 'X'.

    ENDIF.

    ENDMETHOD. "data_changed

    ENDCLASS. "lcl_event_handler IMPLEMENTATION

    and u have to create Handler and set the handler for grid.

    and then u have to register the event data modified.

    Regards

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 18, 2005 at 03:25 PM

    Hi

    Apart from the method already explained by lots of people , you can also try using FM REUSE_ALV_TRANSFER_DATA_BACK to get the changed values for the line into internal table.

    And for making just one field editable use INPUT = 'X' in the field catalogue.

    Regards

    Kalpana

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.