Monday, March 26, 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.
    • Context tab->Create TOP_OF_LIST node with attribute CONTENT (type ref to CL_SALV_FORM_ELEMENT)
    • Context tab-> Map node TOP_OF_LIST of ALV Component context to TOP_OF_LIST of Component Controller.
    • Methods tab->Write the code in WDDOINIT to populate data in ALV and creating TOP_OF_LIST.

    • WDDOINIT method code
    • METHOD wddoinit .
      
        wd_this->get_pa0002_data(  ).
        wd_this->create_top_of_list(  ).
      
      ENDMETHOD.
      
    • GET_PA0002_DATA code
    • METHOD get_pa0002_data .
        DATA lo_nd_pa0002 TYPE REF TO if_wd_context_node.
        DATA lt_pa0002 TYPE wd_this->elements_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 20 ROWS.
        lo_nd_pa0002->bind_table( new_items = lt_pa0002 set_initial_elements = abap_true ).
      
      ENDMETHOD.
      
    • CREATE_TOP_OF_LIST code
    • METHOD create_top_of_list.
        DATA lo_nd_top_of_list TYPE REF TO if_wd_context_node.
        DATA lo_el_top_of_list TYPE REF TO if_wd_context_element.
        DATA ls_top_of_list    TYPE wd_this->element_top_of_list.
        DATA:lr_grid           TYPE REF TO cl_salv_form_layout_grid.
      * TOP-OF-LIST
      **...create top grid
        CREATE OBJECT lr_grid
          EXPORTING
            columns = 5.
      
      *... fill 1. row
        lr_grid->create_text(
          EXPORTING
            row = 1
            column = 1
            rowspan = 1
            colspan = 1
            text = 'Cell 1,1' ).
      
        lr_grid->create_text(
          EXPORTING
            row = 1
            column = 2
            rowspan = 1
            colspan = 1
            text = 'Cell 1,2' ).
      
        lr_grid->create_text(
          EXPORTING
            row = 1
            column = 3
            rowspan = 1
            colspan = 1
            text = 'Cell 1,3' ).
      
        lr_grid->create_text(
        EXPORTING
          row = 1
          column = 4
          rowspan = 1
          colspan = 1
          text = 'Cell 1,4' ).
      
        lr_grid->create_text(
      EXPORTING
        row = 1
        column = 5
        rowspan = 1
        colspan = 1
        text = 'Cell 1,5' ).
      *...fill 2nd row
        lr_grid->create_text(
          EXPORTING
            row = 2
            column = 1
            rowspan = 1
            colspan = 1
            text = 'Cell 2,1' ).
      
        lr_grid->create_text(
          EXPORTING
            row = 2
            column = 2
            rowspan = 1
            colspan = 1
            text = 'Cell 2,2' ).
      
        lr_grid->create_text(
          EXPORTING
            row = 2
            column = 3
            rowspan = 1
            colspan = 1
            text = 'Cell 2,3' ).
      
        lr_grid->create_text(
        EXPORTING
          row = 2
          column = 4
          rowspan = 1
          colspan = 1
          text = 'Cell 2,4' ).
      
        lr_grid->create_text(
      EXPORTING
        row = 2
        column = 5
        rowspan = 1
        colspan = 1
        text = 'Cell 2,5' ).
        "Navigate from <context> to <top_of_list> via lead selection
        lo_nd_top_of_list = wd_context->get_child_node( name = wd_this->wdctx_top_of_list ).
      
        "pass TOL to context node
        lo_nd_top_of_list = wd_context->get_child_node( name = 'TOP_OF_LIST' ).
        lo_el_top_of_list = lo_nd_top_of_list->get_element( index = 1 ).
      
        CALL METHOD lo_el_top_of_list->set_attribute
          EXPORTING
            value = lr_grid
            name  = 'CONTENT'.
      
      ENDMETHOD.
      
  • Go to INTERFACECONTROLLER_USAGE of ALV->Map Context node PA0002 of component controller to DATAof ALV Interface Controller.  
  • Go to window ALV_TOL_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 the web dynpro application

0 comments:

Post a Comment

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.