Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Data Fetching form report to internal table

Former Member
0 Kudos

Dear guru's,

I wanted to crate editable ALV by Fieldcatlog mathod. Problem is that what ever i edited in report it would not come into internal table insted comes the previous data .

Can u all please help me how to capture edited record into internal table for further processing.

p_table = 'Table Name'.
<dyn_tab_temp> is field catlog with same structure like p_table & internal table

FORM user_command  USING    r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.
  i_index = rs_selfield-tabindex.

*       Fetch the field catalog info
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
          EXPORTING
            i_program_name         = 'ZAT_SD51_LSNING'
            i_structure_name       = p_table
          CHANGING
            ct_fieldcat            = i_fieldcat
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc = 0.

*         Make all the fields input enabled except key fields
          w_field-input = 'X'.
          w_field-edit = 'X'.
          MODIFY i_fieldcat FROM w_field TRANSPORTING input edit
          WHERE key IS INITIAL.
          MODIFY gt_fldcat FROM w_field TRANSPORTING edit
          WHERE key IS INITIAL.
        ENDIF.
  CASE r_ucomm.
    WHEN 'SAVE'.
*       Find out the changes in the internal table
*       and populate these changes in another internal table

      READ TABLE gt_list INTO gs_list INDEX i_index.
      IF sy-subrc = 0.
        MOVE-CORRESPONDING gs_list TO gs_list1 .
        APPEND gs_list1 TO <dyn_tab_temp>.
      ENDIF.

*     Lock the table
      CALL FUNCTION 'ENQUEUE_E_TABLE'
        EXPORTING
          mode_rstable   = 'E'
          tabname        = p_table
        EXCEPTIONS
          foreign_lock   = 1
          system_failure = 2
          OTHERS         = 3.
      IF sy-subrc = 0.
*       Modify the database table with these changes
        MODIFY (p_table) FROM TABLE <dyn_tab_temp>.
*        MODIFY (p_table) FROM TABLE gt_list5.
        REFRESH <dyn_tab_temp>.
*       Unlock the table
        CALL FUNCTION 'DEQUEUE_E_TABLE'
          EXPORTING
            mode_rstable = 'E'
            tabname      = p_table.
      ENDIF.
      MESSAGE i005.
      WHEN'BACK'      .
      SET SCREEN 0.
  ENDCASE.
  rs_selfield-refresh = 'X'.
ENDFORM.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Atul

You can use the FM :

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF1.

DATA : REF1 TYPE REF TO CL_GUI_ALV_GRID.

  • CALL METHOD REF1->REFRESH_TABLE_DISPLAY.

CALL METHOD REF1->CHECK_CHANGED_DATA .

for capturing the edited data and can store that changed data into another internal table and can further process ...!

3 REPLIES 3

Former Member
0 Kudos

Hi Atul

You can use the FM :

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF1.

DATA : REF1 TYPE REF TO CL_GUI_ALV_GRID.

  • CALL METHOD REF1->REFRESH_TABLE_DISPLAY.

CALL METHOD REF1->CHECK_CHANGED_DATA .

for capturing the edited data and can store that changed data into another internal table and can further process ...!

kesavadas_thekkillath
Active Contributor
0 Kudos

Check vijays suggestion

Former Member
0 Kudos

Solved