Go on link..

link us with ...

Monday, January 3, 2011

Changing Column settings

To change the propeties of the Columns first we need to get the Column object from the SALV Object. The reference of the column object would be CL_SALV_COLUMNS. This object reference would provide us the access to the properties of all the columns. For example, if we need to set the column width optimization for the table, we can set using this columns reference.

To change the individual column properties, we need to get the individual column reference from the reference created using the CL_SALV_COLUMNS. The individual column property can be changed by the getting the reference of CL_SALV_COLUMN. Like, to change the column heading, we need to first get the column from the Columns object and than we need to set specific property.

Here is the code snippet to which provides the ADD-ON code to our Base program. The base program can be found in the ALV Table Display.

UML Diagram would be like:


Code Snippet
  
*$*$*.....CODE_ADD_1 - Begin..................................1..*$*$*
*
* In this section we will define the private methods which can
* be implemented to set the properties of the ALV and can be
* called in the
*
PRIVATE SECTION.
* Set the various column properties
METHODS:
set_columns
CHANGING
co_alv TYPE REF TO cl_salv_table.
*
*$*$*.....CODE_ADD_1 - End....................................1..*$*$*
*
*
*$*$*.....CODE_ADD_2 - Begin..................................2..*$*$*
*
* In this area we will call the methods which will set the
* different properties to the ALV
*
* Setting up the Columns
CALL METHOD me->set_columns
CHANGING
co_alv = o_alv.
*$*$*.....CODE_ADD_2 - End....................................2..*$*$*
*
*
*$*$*.....CODE_ADD_3 - Begin..................................3..*$*$*
*
* In this area we will implement the methods which are defined in
* the class definition
*
METHOD set_columns.
*
*...Get all the Columns
DATA: lo_cols TYPE REF TO cl_salv_columns.
lo_cols = o_alv->get_columns( ).
*
* set the Column optimization
lo_cols->set_optimize( 'X' ).
*
*...Process individual columns
DATA: lo_column TYPE REF TO cl_salv_column.
*
* Change the properties of the Columns KUNNR
TRY.
lo_column = lo_cols->get_column( 'KUNNR' ).
lo_column->set_long_text( 'Sold-To Party' ).
lo_column->set_medium_text( 'Sold-To Party' ).
lo_column->set_short_text( 'Sold-To' ).
lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*
ENDMETHOD. "SET_COLUMNS
*$*$*.....CODE_ADD_3 - End....................................3..*$*$*


This code snippet will generat output like this:

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)