Go to the doinit method of the view controller and set the properties for the ALV table. We can also do it in the doinit method of the component controller by adding the alv controller usage to the properties of the component controller.
Step 1: Instantiate the used component.
Coding will be generated as below.
This coding calls the method created for the component usage mentioned earlier in the post. It checks for th active component usage and if there is no active component usage then it creates one.
Step 2: Method call in the used controller.
The ALV table has an interface method called get_model which will return the ALV configuration model.
Call the get model method of the ALV component using the code wizard method call in used controller.
Codings will be generated as below.
The object reference for the ALV configuration table class is now contained in the variable LV_VALUE.
This class now contains a number of interfaces which contains method for setting the different properties of the ALV table.
In order to change the color of the column, we will use the method get_column of the interface if_salv_wd_column_settings. This method will return the object reference to the column.
Using pattern call the get_column method of the interface.
Coding will be generated as below.
Modify the coding as below.
Using the method set cell design of the column change the background color of the cell.
Change the generated coding as below.
Save and activate the whole component. Test the application.
Code:
* Instantiate the used component.
DATA LO_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE.
LO_CMP_USAGE = WD_THIS->WD_CPUSE_ALV( ).
IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
LO_CMP_USAGE->CREATE_COMPONENT( ).
ENDIF.
* Method call in the used controller
DATA LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV( ).
DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(
).
* Getting the object reference of the column.
DATA LO_EBELN TYPE REF TO CL_SALV_WD_COLUMN.
CALL METHOD LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN
EXPORTING
ID = 'EBELN'
RECEIVING
VALUE = LO_EBELN.
CALL METHOD LO_EBELN->SET_CELL_DESIGN
EXPORTING
VALUE = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-POSITIVE
.
Output:
0 Comments:
Post a Comment