Quantcast
Channel: SCN: Message List - ABAP Development
Viewing all articles
Browse latest Browse all 10425

Re: Problem in editable ALV with checkbox option.

$
0
0

First create field catalog.

 

  lv_pos = lv_pos + 1.
   CLEAR gw_alv_fieldcat1.
   gw_alv_fieldcat1-fieldname = 'FLAG'.   " name of field from internal table
   gw_alv_fieldcat1-tabname = 'I_DATA1'. " internal table name
   gw_alv_fieldcat1-outputlen = 6.        " output length on screen
   gw_alv_fieldcat1-input = 'X'.
  gw_alv_fieldcat1-checkbox = 'X'.   " print as checkbox
   gw_alv_fieldcat1-edit = 'X'.       " make field open for input

   gw_alv_fieldcat1-hotspot = 'X'.       "set hotspot link to trigger event on clicking hotspot.

  gw_alv_fieldcat1-seltext_l = text-h07.      " header information
   gw_alv_fieldcat1-col_pos   = lv_pos.
   APPEND gw_alv_fieldcat1 TO gt_alv_fieldcat1.   " append field catalog internal table

 

* For other columns.

    lv_pos = lv_pos + 1.
   CLEAR gw_alv_fieldcat1.
   gw_alv_fieldcat1-fieldname = 'TXT50'.
   gw_alv_fieldcat1-tabname   = 'I_DATA1'.
   gw_alv_fieldcat1-seltext_l = text-h10.
   gw_alv_fieldcat1-col_pos   = lv_pos.
   gw_alv_fieldcat1-outputlen = 45.
   APPEND gw_alv_fieldcat1 TO gt_alv_fieldcat1.

 

Display data


CALL FUNCTION'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program       = sy-repid
       it_fieldcat              = gt_alv_fieldcat1
       i_callback_pf_status_set = 'SET_PF_STATUS'
       i_callback_user_command  = 'USER_COMMAND'
       i_default                = 'X'
       i_save                   = 'S'
       is_layout                = gd_layout
     TABLES
       t_outtab                 = i_data.

 

* Capture hotspot event.


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

 

case r_ucomm.

    when '&IC1'.  " This is the fcode for hotspot link.

       read table gt_alv_fieldcat1into gw_alv_fieldcat1 with key fieldname = 'COL_NAME'.

       gw_alv_fieldcat1-edit = 'X'.   

      modify  gt_alv_fieldcat1from gw_alv_fieldcat1.   

 

    when 'SAVE'.  " To save to database.

* Capture the changes in ALV grid.

    DATA ref1 TYPEREFTO cl_gui_alv_grid.
     CALLFUNCTION'GET_GLOBALS_FROM_SLVC_FULLSCR'
       IMPORTING
         e_grid = ref1.
     CALLMETHOD ref1->check_changed_data.

      read table i_data into wa_data index rs_selfield-tabindex.   

     update TABLE from wa_data. " THe structure of table and work area must be same, else make the necessary transfers and update database.

 

 

endcase.

 

endform.

 

 

* Now if you want only that particular row in that column to be editable, do let me know, there is more to it. 


Viewing all articles
Browse latest Browse all 10425

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>