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
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.
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 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.
Coding will be generated as below.
Modify the coding as below.
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.
Coding will be generated as below.
Change the codings as below.
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.
Coding will be generated as below.
Change the default binding value for the column as none as shown below.
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:
0 Comments:
Post a Comment