Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Webdynpro ABAP

Coloring the column in ALV report

 

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.

 

clip_image002

 

Coding will be generated as below.

 

clip_image004

 

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.

 

clip_image005

 

Call the get model method of the ALV component using the code wizard method call in used controller.

 

clip_image007

 

Codings will be generated as below.

 

clip_image009

 

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.

clip_image011

 

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.

clip_image013

 

Coding will be generated as below.

 

clip_image015

 

Modify the coding as below.

 

clip_image017

Using the method set cell design of the column change the background color of the cell.

clip_image019

 

Change the generated coding as below.

clip_image021

 

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:

clip_image023

About Arun

0 Comments:

Post a Comment

Powered by Blogger.