Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Edit and save dynamic alv.

Hi Experts

I have created a dynamic table then filled this dynamic table with the help of field symbols and then passed this dynamic table to grid1->set_table_for_first_display and hence the dynamic alv is shown on the screen. Now, can I do something to make this alv editable and store these values in z table. I have tried the method get_changed_cell method, but no help.

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
      IT_FIELDCATALOG = LT_LVC_CAT
    IMPORTING
      EP_TABLE        = LP_TABLE.

  ASSIGN LP_TABLE->* TO <LT_DATA>.


*Create structure = structure of the internal table
  CREATE DATA LP_STRUCT LIKE LINE OF <LT_DATA>.
  ASSIGN LP_STRUCT->* TO <HEADER>.

*  SORT gt_data BY erdat.
*sort IT_VEWAO by MATNR.

  LOOP AT IT_VEWZO INTO WA_VEWZO.

    AT NEW VKBUR.
      CLEAR <HEADER>.
*
      ASSIGN COMPONENT 'VKBUR' OF STRUCTURE <HEADER> TO <FIELD>.
      IF SY-SUBRC NE 0.
        EXIT .
      ENDIF.
      <FIELD> = WA_VEWZO-VKBUR.
    ENDAT.

    MOVE WA_VEWZO-PD_HIER  TO L_COL.

    ASSIGN COMPONENT L_COL OF STRUCTURE <HEADER> TO <FIELD>.

    IF SY-SUBRC NE 0.
      EXIT .
    ENDIF.
    <FIELD> = WA_VEWZO-PLAN_QTY.

    CONCATENATE WA_VEWZO-PD_HIER '_AP' INTO WA_VEWZO-PD_HIER .
    MOVE WA_VEWZO-PD_HIER  TO L_COL.

    ASSIGN COMPONENT L_COL OF STRUCTURE <HEADER> TO <FIELD>.

    IF SY-SUBRC NE 0.
      EXIT .
    ENDIF.
    <FIELD> = WA_VEWZO-APROV_QTY.


**********************************************************************
    AT END OF VKBUR.
      APPEND <HEADER> TO <LT_DATA>.
*
    ENDAT .

  ENDLOOP.

CREATE OBJECT CUSTOM_CONTAINER1
         EXPORTING
              CONTAINER_NAME = 'CUST_CONT'.
  CREATE OBJECT GRID1
          EXPORTING
              I_PARENT = CUSTOM_CONTAINER1.

  CALL METHOD grid1->REGISTER_EDIT_EVENT
          EXPORTING
              i_event_id = cl_gui_alv_grid=>mc_evt_modified.

  CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
*      I_STRUCTURE_NAME = lv_lp_struct
      IS_LAYOUT        = LS_LAYOUT
    CHANGING
*      IT_SORT          = LT_SORT1
      IT_FIELDCATALOG  = LT_FIELDCAT
      IT_OUTTAB        = <LT_DATA>.

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question