The cell type of CL_GUI_ALV_GRID->MC_STYLE_HOTSPOT enables the user to navigate to a new page or session. It can also open a new window or display a list. It appears as a Link in the SAP ALV List.
The following steps are necessary to implement the HOTSPOT / LINKS
Extent the Internal table with the additional field of type lvc_t_styl.
Set the fields fieldname, style of lvc_t_Styl to each row of the ALV List. The column is specified in the fieldname.
The stylename field of the layout is assigned with the fieldstyle component.
Extension of Internal table with Fieldstyle component
TYPES: BEGIN OF ty_contact_link.
INCLUDE STRUCTURE ztt_db_table2.
TYPES: fieldstyle TYPE lvc_t_styl,
END OF ty_contact_link.
Set the column in the SAP ALV List with the field style ‘CL_GUI_ALV_GRID=>mc_style_hotspot’.
Note: The hotspot can be activated throught the field HOTSPOT of field catalog. The field HOTSPOT of the field catalog is set to ‘X’. The key advantage of this field is that the user does not have to add any additional field to the Internal table.
Button: The cell type of cl_gui_alv_grid=>mc_style_button resembles as a button in the user interface of the SAP ALV list. As the user clicks this button, any event can be executed like opening up a new window.
Dropdown List: It is used to provide a list of values as a dropdown list.
IMPLEMENTATION OF BUTTON:
The following steps are necessary to implement the Button
Extend the Internal table with the additional field of type LVC_T_STYL.
Set the fields fieldname, style of lvc_t_styl to each row of the ALV List. The column is specified in the fieldname.
The stylename field of the layout is assigned with the field style component.
Extension of Internal table with Fieldstyle component.
TYPES: BEGIN OF ty_contact.
INCLUDE STRUCTURE ztt_db_table2.
TYPES: fieldstyle TYPE lvc_t_styl.
END OF ty_contact.
Set the column in the SAP ALV List with the field style ‘cl_gui_alv_grid=>mc_style_button’.
The primary key fields of the data records must be unique. There should not be duplicate records in the Database table. The fields of the ALV List are editable through the field catalog. The primary key fields of the SAP ALV List cannot be edited directly. If a new line of record is inserted in to SAP ALV List, the primary key fields of the SAP ALV List are disabled by default. It is not possible to insert a new record in the ALV List through the edit field of the field catalog.
Contact_Id
Contact_name
Contact_address
101
Ram
Street 10
102
Mahes
Street 11
If a new line of record is inserted in to above SAP ALV List, the field contact_id is disabled by default. The contact_id is the primary key field of the SAP ALV List. If a new line of record must be inserted in the Table, then the primary key fields of the SAP ALV List must be enabled for editing. The primary key fields of the existing data records must be disabled by default.
A new line of record can be inserted in to the ALV Table through the internal table lvc_t_styl. It is introduced to the structure of the internal table of data records. The keywords ‘INCLUDE STRUCTURE’ adds the existing structure of internal table which contains the data records. The following steps helps us to achieve this.
Define the structure with lvc_t_styl.
Define the stylename field of the layout
Define the style field of lvc_s_styl to CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
Define the structure with lvc_t_styl.
TYPES: BEGIN OF st_contact.
INCLUDE STRUCTURE ztt_db_table2.
TYPES: fieldstyle TYPE lvc_t_styl,
END OF st_contact.
DATA lt_contact TYPE TABLE OF st_contact.
Define the stylename field of the layout
DATA ls_layout TYPE lvc_s_layo.
ls_layout-stylename = ‘FIELDSTYLE’.
This layout is given as parameter while calling the set_table_for_first_display method of the ALV object.
Define the style field of lvc_s_styl to CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
This style is defined for the primary key fields of the database table. This style is set to each data record of the database table. But it is constrained to specific columns by specifying the fieldname of the data records. It is finally inserted in to the field style of each data record.
Key steps to set the style field are:
a) Define the fieldname of structure lvc_s_styl.
b) Define the style of structure lvc_s_styl.
c) Insert the structure lvc_s_styl in the fieldstyle field of each data record. Fieldstyle field is the internal table of type lvc_t_styl.
The selection of the style cl_gui_alv_grid=>mc_style_disabled blocks the fields of the respective column in editing mode. For example in the above table, the editing of column CONTACT_ID is deactivated.
INSERT ls_style_record INTO TABLE <ls_contact>-fieldstyle.
ENDLOOP.
The primary key fields of the table will now be available for insertion of new record. The insert button facilitates insertion of new record. The primary key fields of the ALV List for already existing data records are disabled for editing.