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

Changing header text of column–ALV report

 

The Output of the ALV report which we created in the earlier post is as below.                   

Link: http://www.teamabap.com/2014/05/a-simple-alv-report.html

 

 

 

clip_image001

                                                                                                                                               

Now let us see how to change the standard text for the header that comes form the dictionary.

 

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.

 

Let us proceed to create the first column as the link to action.

 

Step 1: Instantiate the used component.

 

clip_image003

 

Coding will be generated as below.

 

clip_image005

 

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_image006

 

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

 

clip_image008

 

Codings will be generated as below.

 

clip_image010

 

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_image012

 

In order to change the header text 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_image014

 

Coding will be generated as below.

 

clip_image016

 

Modify the coding as below.

 

clip_image018

 

Now we have obtained the object reference for the column. Using the object reference for the column get the object reference for the header of the column. Call the method get_header of the class to get the object reference of the header.

clip_image020

 

Coding will be generated as below.

clip_image022

Change the codings as below.

clip_image024

 

Now we have obtained the object reference of the header. Using the method set_text of the class for header set the user defined text for the column.

clip_image026

Coding will be generated as below.

clip_image028

 

Change the default binding value for the column as none as shown below.

clip_image030

 

Save and activate the whole component.

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.

* Getting the object reference for the header


 
DATA : LO_HEADER TYPE REF TO CL_SALV_WD_COLUMN_HEADER.

 
CALL METHOD
LO_EBELN->GET_HEADER
    RECEIVING
     
VALUE
= LO_HEADER.

* Setting the user defined text


 
CALL METHOD LO_HEADER->SET_TEXT
   
EXPORTING

     
VALUE = 'PO Number'.

  LO_HEADER->SET_PROP_DDIC_BINDING_FIELD(
     
PROPERTY
=  IF_SALV_WD_C_DDIC_BINDING=>BIND_PROP_TEXT
     
VALUE
= IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE ).

 

Output:

 clip_image032

About Arun

0 Comments:

Post a Comment

Powered by Blogger.