Tuesday, March 13, 2012

Program steps

  • Create Web Dynpro Component with Window and View(Automatically View is embedded into Window). 
  • Define Component Use ALV for the Used component SALV_WD_TABLE under Used Components tab of Web Dynpro Component.
  • Go to Component Controller of component
    • Properties tab->Define or Include Used Controllers/ Components of ALV.
    • Context tab->Create PA0002 node with cardinality 0..n. and CELLDESIGN attribute beneath the node PA0002  to collect colour code.
    • Methods tab->Write the code in WDDOINIT to populate data in ALV.
    • WDDOINIT method code.
    • METHOD wddoinit .
        wd_this->get_data( ).
        wd_this->configure_alv( ).
      ENDMETHOD.
      
    • GET_DATA method code.
    • METHOD get_data .
        DATA lo_nd_pa0002 TYPE REF TO if_wd_context_node.
        DATA lt_pa0002 TYPE wd_this->elements_pa0002.
        DATA ls_pa0002 LIKE LINE OF  lt_pa0002.
        "Navigate from <CONTEXT> to <PA0002> via lead selection
        lo_nd_pa0002 = wd_context->get_child_node( name = wd_this->wdctx_pa0002 ).
        SELECT *
          FROM pa0002
          INTO CORRESPONDING FIELDS OF TABLE lt_pa0002
          UP TO 40 ROWS.
        LOOP AT lt_pa0002 INTO ls_pa0002.
          ls_pa0002-celldesign = sy-tabix.
          MODIFY lt_pa0002 FROM ls_pa0002.
        ENDLOOP.
        lo_nd_pa0002->bind_table( new_items = lt_pa0002 set_initial_elements = abap_true ).
      
      ENDMETHOD.
      
    • For colour numbers to use in Web Dynpro ALV, we have to refer the below steps.
    • CONFIGURE_ALV method code.
    • METHOD configure_alv .
        "Instantiate 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.
        "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,
              lt_columns         TYPE salv_wd_t_column_ref,
              ls_columns         LIKE LINE OF lt_columns,
              l_column   TYPE REF TO cl_salv_wd_column.
      
        lr_column_settings ?= lv_value.
        lt_columns = lr_column_settings->get_columns( ).
        LOOP AT lt_columns INTO ls_columns.
          ls_columns-r_column->set_cell_design_fieldname( value = 'CELLDESIGN' ).
          lv_value->if_salv_wd_column_settings~delete_column( id = 'CELLDESIGN' ).
        ENDLOOP.
      
      ENDMETHOD.
      
  • Go to view ALV_ROW_COLOR_V.
    • Layout tab->Create View Container UI element to display ALV output. 
  • Go to INTERFACECONTROLLER_USAGE of ALV->Map Context node PA0002 of component controller to node DATA of ALV Interface Controller.

  • Go to window  ALV_ROW_COLOR_W->Embed TABLE view of SALV_WD_TABLE component in window as shown in the screen.
  • Activate Web Dynpro component.
  • Create Web Dynpro Application and Save it as local object.
  • Run web dynpro application.

1 comment:

  1. You can refer this link for easy steps for colouring column in Web dynpro ALV table

    http://theabap.blogspot.in/2012/03/coloring-particular-column-of-alv-table.html

    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.