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

fetch data in edittable field in alv using REUSE_ALV_GRID_DISPLAY_LVC FM

i am using REUSE_ALV_GRID_DISPLAY_LVC to display alv.

how can i fetch the data in edittable field in alv.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Aug 06, 2008 at 09:24 AM

    Check this Sample code.

    calling the Function in the user command will help you in getting the updated values to interanl table.

    'GET_GLOBALS_FROM_SLVC_FULLSCR'

    REPORT  ztest_lvc_fm.
    
    TYPE-POOLS: slis.
    
    DATA: x_fieldcat TYPE lvc_s_fcat,
    it_fieldcat TYPE lvc_t_fcat.
    
    
    DATA: BEGIN OF itab OCCURS 0,
    vbeln LIKE vbak-vbeln,
    posnr LIKE vbap-posnr,
    chk(1),
    color(4),
    END OF itab.
    
    SELECT vbeln
    posnr
    FROM vbap
    UP TO 20 ROWS
    INTO TABLE itab.
    
    x_fieldcat-fieldname = 'CHK'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 1.
    x_fieldcat-edit = 'X'.
    x_fieldcat-checkbox = 'X'.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-coltext = 'VBELN'.
    x_fieldcat-hotspot = 'X'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 2.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-coltext = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-edit = 'X'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
      EXPORTING
        i_callback_program      = sy-repid
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat_lvc         = it_fieldcat
      TABLES
        t_outtab                = itab
      EXCEPTIONS
        program_error           = 1
        OTHERS                  = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    
    *&---------------------------------------------------------------------*
    *&      Form  USER_COMMAND
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
    
      DATA: gd_repid LIKE sy-repid, "Exists
      ref_grid TYPE REF TO cl_gui_alv_grid.
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.
      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data .
      ENDIF.
    
      "now check the entries in ALV table
      BREAK-POINT.
    
    ENDFORM. "USER_COMMAND

    Regards

    Vijay Babu Dudla

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Vijay,

      We have created our code on similar lines to your code(given above) and we are able to get the Changed data, but the problem we are facing Occasionally is when we enter the data into the Editable alv fields the fields are not getting populated with the new values they are over written by the previous values.After entering the data if we click enter Key the data is getting populated properly.

      Is there any way to prevent the usage of Enter key (. I have tried using the REGISTER_EDIT_EVENT method also, but it was of no use.Can you please help.

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.