* ------------------------------------- ALV parameter ------------------------------------
Type-Pools: slis.
Data : Gt_fieldcat Type Slis_t_fieldcat_alv With Header Line ,
Gs_layoutType Slis_layout_alv,
G_repid Like Sy-repid Value Sy-repid.
Data : Git_events Type Slis_t_event,
It_sort Type Slis_t_sortinfo_alv With Header Line .
Data : Git_listheader Type Slis_t_listheader,
Git_listend Type Slis_t_listheader.
data : begin of t_tab occurs 0 ,
sel type C ,
MARK type C ,
matnr like mseg-matnr, "material encoding
menge like mseg-menge, "quantity
end of t_tab.
PerformInit_fieldcatTablesGt_fieldcatUsing '1'.
FormInit_fieldcatTablesG_alv_fieldcatUsingP_flag.
RefreshG_alv_fieldcat.
If P_flag = '1' .
Clear Gt_fieldcat. "When this option is selected, the value of Mark changes to 1.
Gt_fieldcat-fieldname = 'Mark' .
Gt_fieldcat-outputlen = '5' .
Gt_fieldcat- Key = 'X' .
Gt_fieldcat- Edit = 'X' .
Gt_fieldcat- Checkbox = 'X' .
Gt_fieldcat-seltext_s ='Select' .
Append Gt_fieldcat To G_alv_fieldcat.
Endif .
clear gt_fieldcat.
gt_fieldcat-fieldname = 'matnr '.
gt_fieldcat-seltext_s = 'material Code' .
gt_fieldcat-outputlen = 10 . gt_fieldcat-seltext_m = gt_fieldcat-seltext_s. gt_fieldcat-seltext_l = gt_fieldcat-seltext_s.
gt_fieldcat-no_zero = 'X' .
append gt_fieldcat.
ClearGt_fieldcat.
Gt_fieldcat-fieldname ='Maktx'.
Gt_fieldcat-seltext_s ='Material description'.
Gt_fieldcat-outputlen =10.
Gt_fieldcat-seltext_m = gt_fieldcat-seltext_s.
Gt_fieldcat-seltext_l = gt_fieldcat-seltext_s.
Gt_fieldcat-emphasize ='C603'."Color, cannot be used with key value gt_fieldcat-key = 'x '.
AppendGt_fieldcat.
Clear Gt_fieldcat.
Gt_fieldcat-fieldname = 'Menge' .
Gt_fieldcat-seltext_s = 'Number' .
Gt_fieldcat-outputlen = 10 .
Gt_fieldcat-seltext_m = gt_fieldcat-seltext_s.
Gt_fieldcat-seltext_l = gt_fieldcat-seltext_s.
* Gt_fieldcat-key = 'x '.
Gt_fieldcat- Edit = 'X' . "Modifiable status
Gt_fieldcat-inttype = t_tab5-menge. "Modified value
gt_fieldcat-ref_tabname = 't001l '. "search the table corresponding to the help field
gt_fieldcat-ref_fieldname = 'lgort '. "Search for help fields
gt_fieldcat-no_zero = 'X' .
append gt_fieldcat.
endform . "init_fieldcat
FormInit_layout.
Gs_layout-box_fieldname ='Sel'.
* Gs_layout-zebra = 'x '.
Gs_layout-f2code ='& Sel'.
Gs_layout-detail_popup ='X'.
* The gs_layout-colwidth_optimize = 'x'. "automatically sets the column width, which is set by the gt_fieldcat-outputlen value after being disabled
Endform."Init_layout
FormListado.
G_repid = sy-repid.
Call Function 'Reuse _ alv_grid_display'
Exporting
I _callback_program = g_repid
Is_layout = gs_layout
It_fieldcat = gt_fieldcat []
I _save = 'A'
It_events = git_events []
I _callback_pf_status_set = 'Frm _ status' "Display custom Toolbar
I _callback_user_command ='User _ command' "Call Command
It_sort = it_sort []
Tables
T_outtab = t_tab5
Exceptions
Program_error = 1
Others = 2 .
Endform . "Listado
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield. "responds to events after ALV clicks the Custom button
case r_ucomm.
when 'test' .
perform save_alv.
endcase .
endform . "execute_command
form save_alv. "Save the modified value to the internal table
data : l_grid type ref to cl_gui_alv_grid.
* ------------ Save the modified content on alv to the inner table --------------------------------- *
call function 'get _ globals_from_slvc_fullscr '
importing
e_grid = l_grid.
call method l_grid-> check_changed_data.
endform . "save_alv