Sunday, April 8, 2012
  • 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 COMPONENTCONTROLLER.
    • Properties tab->Define or Include Used Controllers/ Components of ALV.
    • Context tab->Create PA0002 node with cardinality 0..n as shown in the picture.  CELLDESIGN attribute is used to set colour of the cell.
    • Methods tab->Write the code in WDDOINIT to populate data in ALV and Change ALV Configuration.
    • 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 = cl_wd_table_column=>e_cell_design-goodvalue_light.
          MODIFY lt_pa0002 FROM ls_pa0002.
        ENDLOOP.
        lo_nd_pa0002->bind_table( new_items = lt_pa0002 set_initial_elements = abap_true ).
      
      ENDMETHOD.
      
    • 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.
          CASE ls_columns-id.
            WHEN 'PERNR'.
            ls_columns-r_column->set_cell_design_fieldname( value = 'CELLDESIGN' ).
            lv_value->if_salv_wd_column_settings~delete_column( id = 'CELLDESIGN' ).
          ENDCASE.
        ENDLOOP.
      
      ENDMETHOD.
      
  • Go to view CELL_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  CELL_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.

3 comments:

  1. your providing such a valuabe information about studying..and also have some good key points to every student.

    SAP BI ONLINE TRAINING

    ReplyDelete
  2. CELLDESIGN attribute is used to set colour of the cell.iam unable to add celldesign attribute to pa0002 node

    ReplyDelete
  3. Very valuable information provided, folks will be getting good knowledge Informatica online training

    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.