Thursday, April 5, 2012

Procedure.
  • Create Web dynpro alv program by using ALV component SALV_WD_TABLE.
  • Configure the ALV to get hypertext link for ALV column
  • Define one event handler method  ON_CLICK in the view controller for ON_CLICK event of SALV_WD_TABLE interface controller. 
  • Identify Click in a Cell of ALV Output in event handler method ON_CLICK.
  • Implement  WDDOMODIFYVIEW to set data based on click in a Cell. 
Program steps
  • Create One Web Dynpro application for ALV output. Click here to check on how to create.
  •  Go to Component controller of web dynpro component
    • Methods tab ->Define CONFIGURE_ALV method and write the code as specified.
    • 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.
    
      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'.
            DATA:lr_link TYPE REF TO cl_salv_wd_uie_link_to_action.
            CREATE OBJECT lr_link.
            lr_link->set_text_fieldname( ls_columns-id ).
            ls_columns-r_column->set_cell_editor( lr_link ).
        ENDCASE.
      ENDLOOP.
    
    ENDMETHOD.
    
    • Call CONFIGURE_ALV method in WDDOINIT hook method.
    METHOD wddoinit .
      wd_this->get_data( ).
      wd_this->configure_alv( ).
    ENDMETHOD.
    
  • Activate web dynpro component and run application. The output would be like below. 
  • Go to view ALV_EVENTS_V
    • Properties tab->Define or Include Used Controllers/ Components of ALV.
    • Context tab->Create node PA0006 with cardinality 0..n and another node EVENT_PROPERTIES(beneath NAME and VALUE are attributes) with cardinality 0..n.
    • Context node EVENT_PROPERTIES is needed to hold the information on the last event.
    • Map context node PA0002 of component controller to View context.

    • Layout tab->Create one table UI element->Bind Context node PA0006 with table UI element. 
    • Method tab->Define ON_CLICK event handler method for ON_CLICK event of ALV Interface controller. 
    • ON_CLICK event handler method code.Here EVENT_PROPERTIES context node will be populated with details like column id, column index, column attributes and value of column. 
    • Bind the internal table to context node EVENT_PROPERTIES.
    METHOD ON_CLICK .
      DATA: lr_node             TYPE REF TO if_wd_context_node,
            lt_event_properties TYPE wd_this->elements_event_properties,
            ls_event_properties TYPE wd_this->element_event_properties.
    
      FIELD-SYMBOLS:  TYPE ANY.
    * fill internal table
      ls_event_properties-name = 'COLUMN_ID'.
      ls_event_properties-value = r_param->column.
      APPEND ls_event_properties TO lt_event_properties.
    
      ls_event_properties-name = 'INDEX'.
      ls_event_properties-value = r_param->index.
      APPEND ls_event_properties TO lt_event_properties.
    
      ls_event_properties-name = 'ATTRIBUTE'.
      ls_event_properties-value = r_param->attribute.
      APPEND ls_event_properties TO lt_event_properties.
    
      ASSIGN r_param->value->* TO <l_value>.
      ls_event_properties-name = 'VALUE'.
      ls_event_properties-value = <l_value>.
      APPEND ls_event_properties TO lt_event_properties.
    
    * navigate to context node EVENT_PROPERTIES
      lr_node = wd_context->get_child_node( 'EVENT_PROPERTIES' ).
    * bind internal table to context node
      lr_node->bind_table( lt_event_properties ).
    
    ENDMETHOD.
    
    • Populate context node PA0006 based on context EVENT_PROPERTIES. For that use WDDOMODIFYVIEW hook method. 
    • WDDOMODIFYVIEW method code
    METHOD wddomodifyview .
      DATA lo_nd_event_properties TYPE REF TO if_wd_context_node.
      DATA: lt_event_properties TYPE wd_this->elements_event_properties,
            ls_event_properties LIKE LINE OF lt_event_properties.
      " Navigate from <CONTEXT> to <EVENT_PROPERTIES> via lead selection
      lo_nd_event_properties = wd_context->get_child_node( name = wd_this->wdctx_event_properties ).
      lo_nd_event_properties->get_static_attributes_table( IMPORTING table = lt_event_properties ).
    
    
      READ TABLE lt_event_properties INTO ls_event_properties WITH KEY name = 'INDEX'.
      DATA lo_nd_pa0002 TYPE REF TO if_wd_context_node.
      DATA lt_pa0002 TYPE wd_this->elements_pa0002.
      DATA ls_pa0002 TYPE wd_this->element_pa0002.
      " Navigate from <CONTEXT> to <PA0002> via lead selection
      lo_nd_pa0002 = wd_context->get_child_node( name = wd_this->wdctx_pa0002 ).
      lo_nd_pa0002->get_static_attributes_table( IMPORTING table = lt_pa0002 ).
      READ TABLE lt_pa0002 INTO ls_pa0002 INDEX ls_event_properties-value.
    
      DATA lo_nd_pa0006 TYPE REF TO if_wd_context_node.
      DATA lt_pa0006 TYPE wd_this->elements_pa0006.
      " Navigate from <CONTEXT> to <PA0006> via lead selection
      lo_nd_pa0006 = wd_context->get_child_node( name = wd_this->wdctx_pa0006 ).
      SELECT *
        FROM pa0006
        INTO CORRESPONDING FIELDS OF TABLE lt_pa0006
        WHERE pernr EQ ls_pa0002-pernr.
      lo_nd_pa0006->bind_table( new_items = lt_pa0006 set_initial_elements = abap_true ).
    
    ENDMETHOD.
    
  • Activate Web dynpro component.
  • Run web dynpro application.

10 comments:

  1. Very usefull bolg !
    [www.thesapjobs.com]

    ReplyDelete
  2. Very nice blog...Thank you so much for sharing information of sap consultancies with us.

    ReplyDelete
  3. It's really a great site.
    can u upload some real time scenarios related to abap objects.
    It'll be really helpful.....

    ReplyDelete
  4. Thanks a lot for the information you are providing on SAP Webdynpro and the topics that are covered up.are very helpful.
    i would like to ask that what is the scope of SAP webdynpro ABAP training what all topics
    should be covered and has anyone studies from this course
    http://www.wiziq.com/course/8153-sap-web-dynpro-pro-abap-training of SAP webdynpro ABAP training ??
    or tell me any other guidance…
    would really appreciate help… and Also i would like to thank for all the information you are
    providing on SAP Webdynpro ABAP training.

    ReplyDelete
  5. Hi sukaniya,
    nice piece of information provided i had many doubts in mind that weather i should go for online learning or not so putting my mind together i went for a online course http://www.wiziq.com/course/8153-sap-web-dynpro-pro-abap-training
    which was a very good experience and learned a lot so know i have decided to learn online only

    ReplyDelete

  6. ABAP (Advanced Business Application Programming, originally Allgemeiner Berichts-Aufbereitungs-Prozessor, German for “general report creation processor”) is a very high level programming language created by the German software company SAP.

    SAP ABAP ONLINE TRAINING

    ReplyDelete
  7. SAP HANA training in hyderabad,This is the best path You can Learn COmplete Course with full fledge knowledge of SAP.SAP HANA training in hyderabad

    ReplyDelete
  8. thinx referral code


    Thanks for sharing this amazing article, it is very informative post good work keep it up.

    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.