Editable and non-editable ALV based on entries Dynamically
Abstract:
To make serial number field editable and non -editable dynamically based on the material in ALV display, if a material is serialized(editable) and gray out if not.
Executive Summary:
This program is used to make the ALV field editable if a material is serialized and disable if a material is not serialized for the users. User can provide the serial numbers and can post the Material document on click of save.
Processing Logic:
- To check whether a material is serialized or not, we can use function module “material_read”. Pass values to table MTCOM (material master communication).
- The importing parameter will be table MARC. The field SERNP in MARC, if it is not initial then material is serialized. Use SERIAL_PROFILE_READ to read the serial number read profile parameters.
- To create an Editable ALV, We can use OOPS concept(Call Screen 100).Inside PBO do the following.
- Create custom container and Grid for the screen you are going to display the ALV output.
- Move the final internal table, which is used to display the ALV to a temporary internal table. Add one field call celltab of type lvc_t_styl.
- Give the layout style name as ‘CELLTAB’.
- Check if marc-sernp not initial. If so, use class cl_gui_alv_grid=>mc_style_enabled to make the field editable.
- Sample code:
PERFORM fill_celltab USING gt_outtab-sernp
CHANGING lt_celltab.
FORM fill_celltab USING wt_outtab-sernp TYPE marc-sernpCHANGING pt_celltab TYPE lvc_t_styl.
DATA: ls_celltab TYPE lvc_s_styl,
l_mode TYPE raw4.
IF wt_outtab-sernp <> ”.
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE.
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = ‘FIELD’.”field= the field name you want to make editable”
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.