Friday, August 9, 2013

Specifying the own wording of the Column Header

To specify the wording of the column header, we use the methods of class CL_SALV_WD_COLUMN_HEADER. We can specify the text to be displayed with the following options as the column header.

  • We can enter any text.
  • We can enter a separate DDIC data element whose field label is to be used as the column header.
If we want to enter any text, we need to unbind DDIC relationship and use method SET_PROP_DDIC_BINDING_FIELD.
Check the ALV demo program for step by step process to create ALV in Web Dynpro ABAP.
METHOD SET_COLUMN_HEADINGS .
  "Create an instance of ALV component Usage
  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.
  "Create an instance of ALV Interface Controller
  DATA LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
  LO_INTERFACECONTROLLER =   WD_THIS->WD_CPIFC_ALV( ).
  "Configuration of the ALV Output
  DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
  LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(  ).

  DATA LR_COLUMN_SETTINGS TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS.
  DATA LT_COLUMNS         TYPE SALV_WD_T_COLUMN_REF.
  DATA LS_COLUMNS         LIKE LINE OF LT_COLUMNS.
  DATA:LS_COLUMN_HEADER    TYPE REF TO CL_SALV_WD_COLUMN_HEADER .

  LR_COLUMN_SETTINGS ?= LV_VALUE.
  LT_COLUMNS          = LR_COLUMN_SETTINGS->GET_COLUMNS( ).
  LOOP AT LT_COLUMNS INTO LS_COLUMNS.
    LS_COLUMN_HEADER = LS_COLUMNS-R_COLUMN->GET_HEADER( )  .
    LS_COLUMN_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_COLUMN_SETTINGS=>DDIC_BIND_NONE ).
    CASE LS_COLUMNS-ID.
      WHEN 'PERNR'.
        LS_COLUMN_HEADER->SET_TEXT( 'Pers. No.' ).
      WHEN 'ENAME'.
        LS_COLUMN_HEADER->SET_TEXT( 'Name' ).
      WHEN 'STELL'.
        LS_COLUMN_HEADER->SET_TEXT( 'Job ID' ).
      WHEN 'STELL_TXT'.
        LS_COLUMN_HEADER->SET_TEXT( 'Job Description' ).
      WHEN 'PLANS'.
        LS_COLUMN_HEADER->SET_TEXT( 'Position ID' ).
      WHEN 'PLANS_TXT'.
        LS_COLUMN_HEADER->SET_TEXT( 'Position Description' ).
    ENDCASE.
  ENDLOOP.
ENDMETHOD.

1 comment:

  1. Fantastic website for knowledge sharing...!! Great Job...!!!

    ReplyDelete

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.