Hi,

I thought to have a ready code and share with all, this will help anyone who is dealing with ALV in Web dynpro ABAP.

Please find the below working and tested code.
The code will allow you to change the description of the columns, Hide/display standard functions buttons, use standard function like adding etc. Have a look at the code below. Let me know in case of any further queries.

****ALV standard declarations

    DATA: LO_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE,
          LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
          LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.

    DATA: LR_COLUMN_SETTINGS TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS,
          LR_COLUMN          TYPE REF TO CL_SALV_WD_COLUMN,
          LR_COLUMN_HEADER   TYPE REF TO CL_SALV_WD_COLUMN_HEADER.

    DATA: LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF,
          LS_COLUMNS TYPE SALV_WD_S_COLUMN_REF.

    DATA: LR_STANDARD_FUNCTIONS  TYPE REF TO IF_SALV_WD_STD_FUNCTIONS.

    DATA: LR_ALV_HEADER TYPE REF TO CL_SALV_WD_COLUMN_HEADER,
          LR_ALV_CONFIG TYPE REF TO CL_SALV_WD_CONFIG_TABLE.

    DATA: LR_FIELD_AMNT TYPE REF TO CL_SALV_WD_FIELD.
    DATA: LR_FIELD TYPE REF TO CL_SALV_WD_FIELD.

    DATA: LV_AGGR_RULE   TYPE REF TO CL_SALV_WD_AGGR_RULE.
    DATA: LR_SORT_RULE   TYPE REF TO CL_SALV_WD_SORT_RULE.

****create ALV component

    LO_CMP_USAGE =   WD_THIS->WD_CPUSE_ALV_COMP( ).
    IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
      LO_CMP_USAGE->CREATE_COMPONENT( ).
    ENDIF.

****set data

    LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_COMP( ).

****ref to if_wd_context_node

    LO_INTERFACECONTROLLER->SET_DATA(
      R_NODE_DATA =  LO_ND_CTX_VN_PLAN_OUPUT
    ).

    LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(
    ).

****implement standard functions and initializaton

    LV_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_MULTI_COLUMN_SORT( VALUE = ABAP_TRUE ).

    LR_STANDARD_FUNCTIONS ?= LV_VALUE.
    LR_STANDARD_FUNCTIONS->SET_EXPORT_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_PDF_ALLOWED( ABAP_FALSE ).
    LR_STANDARD_FUNCTIONS->SET_EDIT_CHECK_AVAILABLE( ABAP_FALSE ).
    LR_STANDARD_FUNCTIONS->SET_EDIT_INSERT_ROW_ALLOWED( ABAP_FALSE ).
    LR_STANDARD_FUNCTIONS->SET_EDIT_DELETE_ROW_ALLOWED( ABAP_FALSE ).
    LR_STANDARD_FUNCTIONS->SET_EDIT_APPEND_ROW_ALLOWED( ABAP_FALSE ).
    LR_STANDARD_FUNCTIONS->SET_VIEW_LIST_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_FILTER_FILTERLINE_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_DIALOG_SETTINGS_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_COLUMN_SELECTION_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_AGGREGATION_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_GROUP_AGGREGATION_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_COUNT_RECORDS_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_HIERARCHY_ALLOWED( ABAP_TRUE ).
    LR_STANDARD_FUNCTIONS->SET_SORT_HEADERCLICK_ALLOWED( ABAP_FALSE ).
    LR_STANDARD_FUNCTIONS->SET_SORT_COMPLEX_ALLOWED( ABAP_TRUE ).

****configure columns & column funtions

    LR_COLUMN_SETTINGS ?= LV_VALUE.
    LT_COLUMNS = LR_COLUMN_SETTINGS->GET_COLUMNS( ).

****setting column header for all display feilds

    LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ‘AUFNR’ ).
    LR_ALV_HEADER = LR_COLUMN->GET_HEADER( ).
    LR_ALV_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE ).
    LR_ALV_HEADER->SET_TEXT( ‘PO No’).
    LR_ALV_HEADER->SET_HEADER_TEXT_WRAPPING( ABAP_TRUE ).

    LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ‘ATWRT_LEN’ ).
    LR_ALV_HEADER = LR_COLUMN->GET_HEADER( ).
    LR_ALV_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE ).
    LR_ALV_HEADER->SET_TEXT( ‘Order Length(Mtr)’).
    LR_ALV_HEADER->SET_HEADER_TEXT_WRAPPING( ABAP_TRUE ).

    LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ‘ATWRT_PLAN_QTY’ ).
    LR_ALV_HEADER = LR_COLUMN->GET_HEADER( ).
    LR_ALV_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE ).
    LR_ALV_HEADER->SET_TEXT( ‘Plan Qty’).
    LR_ALV_HEADER->SET_HEADER_TEXT_WRAPPING( ABAP_TRUE ).   

LOOP AT LT_COLUMNS INTO LS_COLUMNS.

****hide fields such as CUOBJ, MATNR, AUFPL from display

      CASE LS_COLUMNS-ID.

        WHEN ‘CUOBJ’.

          LS_COLUMNS-R_COLUMN->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_NONE ).

        WHEN ‘MATNR’.

          LS_COLUMNS-R_COLUMN->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_NONE ).

        WHEN ‘AUFPL’.

          LS_COLUMNS-R_COLUMN->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_NONE ).

      ENDCASE.

    ENDLOOP.

****set row count at initial display as 30 rows
****hide all empty rows

    LV_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_VISIBLE_ROW_COUNT( ’30’ ).
    LV_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_DISPLAY_EMPTY_ROWS( VALUE = ABAP_FALSE ).

  ENDIF.

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !