Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

 

Applies to:

SAP CRM 6.0 / 7.0

Summary

A demo on how to add multiple context nodes of different structures to a table view, explained with an example.

Author(s):  

   
Company:     Accenture
Created on:    Sep'22 2010
Author(s) Bio
Arun Kumar is a CRM developer working with Accenture.

Table of Contents

Introduction

Any basic table view seen in Web UI corresponds to any single entity structure. For example, an opportunity search result is displayed as a table view which adopts the structure CRMST_QUERY_R_OPP_BTIL. This document illustrates how to accommodate multiple context nodes in a table view with a simple example using Quotations search result.

Quotations search result basically lists the quotations that passed the search criteria in a table view. This search result is enhanced to integrate Quotation items and item pricing     conditions which have different context node and entity structure.

                                                                                                           Level 0

                                                                             Quotation search result list (a basic table view)

                                                                                                           Level 1

                                                   Quotation items in the same table view displayed in a hierarchical structure

                                                                                                            Level 2

                                                                      Pricing conditions of Item 30 displayed in the same table

Component Layout

The custom component has three views - Quotation search view, Search result view and a viewset to embed these views. The viewset is assigned to a default main window.

View Definitions:

 ZMULTI_TV/BTQuotVS
 

View name

BTQuotVS

View type

View set


The viewset has 2 views, QuotSearch and Tableview assigned to it.


ZMULTI_TV/QuotSearch

View name

QuotSearch

View type

Advanced search controller

Context node

BTQSLSQUOT

Base entity name

'BTQSlsQuot'

Context node super class

CL_CRM_UIU_BT_ADVS_CN


ZMULTI_TV/Tableview

View name

Tableview

View type

Search result view (deep table view)

Context node

BTQRSLSQUOT

Base entity name

'BTQRSlsQuot'

Context node super class

CL_BSP_WD_CONTEXT_NODE_DTV

Adding dependant context nodes to deep table view:

 The search result context node BTQRSLSQUOT of view 'ZMULTI_TV/Tableview' is created as a deep table view in order to integrate the quotation items. The deep table view class CL_BSP_WD_CONTEXT_NODE_DTV has an abstract method GET_SUB_CNODE_DEFINITIONS which defines the child context nodes, which in this case is quotation items.
 
A context node with base entity BTAdminI is created and assigned as child node to quotation search result.

Context node

Items

Base entity name

'BTAdminI'

Context node super class

CL_BSP_WD_CONTEXT_NODE_DTV

* Dependant context nodes assignment
 METHOD get_sub_cnode_definitions.
   DATA: ls_entry TYPE crmt_bsp_wd_elem_descr.
* Assign the Items context node class
   ls_entry-name = 'Items'. "#EC NOTEXT
   ls_entry-implclass = 'ZL_ZMULTI_T_TABLEVIEW_CN01'.
   APPEND ls_entry TO rt_result.
 ENDMETHOD.


Second level dependant nodes: Addition of item pricing conditions to quotation items

A context node with base entity 'BTCondLine' is created and assigned as child node to quotation items.

Context node

BTCondSet

Base entity name

'BTCondLine'

Context node super class

CL_BSP_WD_CONTEXT_NODE_TV



* Dependant context nodes assignment
 METHOD get_sub_cnode_definitions.
   DATA: ls_entry TYPE crmt_bsp_wd_elem_descr.
* Assign the item conditions context node class
   ls_entry-name = 'BTCondSet'. "#EC NOTEXT
   ls_entry-implclass = 'ZL_ZMULTI_T_TABLEVIEW_CN02'.
   APPEND ls_entry TO rt_result.
 ENDMETHOD.

  

                                                                 Context node structure

Generating dynamic config cellerator

The initial search result is displayed using chtmlb:configCellerator, which has an iterator assigned for dependant objects. chtmlb:configCellerator tag has a property 'iterator2' for dependant objects.

 Adding iterator for dependant objects:

Create a class with interface IF_THTMLB_CELLERATOR_ITERATOR - additional iterator for cellerator. The interface has the method for rendering dependant objects. The dependant object table will be assigned dynamically to the return parameter et_object_bindings.

Method RENDER_DEPENDANT_OBJECTS.

* When quotation header is expanded, the importing parameter iv_object_id
* contains the cellerator id specified in the view layout.
  IF iv_object_id CS 'Cellerator'.

* Get the current context node
   gr_row_entity ?= gr_context_node->get_bo_by_index( iv_index = iv_row_index).
   entity ?= gr_row_entity.

* Create a reference for the first dependant object, items (Refer image Level 1)
   CREATE OBJECT lr_items_iterator.
   lr_items_iterator->gr_entity ?= entity.

* Create a reference to cl_thtmlb_cellerator and pass the items iterator.
   CREATE OBJECT ls_cellerator.

* Generate cellerator id by concatenating the selected row index.
* This is done to identify the index of the quotation expanded for conditions view
    CONCATENATE
        lv_row_index
        'Items'
          INTO ls_cellerator->id.
    ls_cellerator->selectionmode     = 'MULTI'.

    CONCATENATE 'Items - ' lv_objectid INTO lv_objectid SEPARATED BY space.
    ls_cellerator->headertext        = lv_objectid.
    ls_cellerator->_table            = '//Items/TABLE'.
    ls_cellerator->editmode          = ls_cellerator->gc_edit_mode_none.
* Assign the reference object for items iterator
    ls_cellerator->iterator          = lr_items_iterator.
    ls_cellerator->personalizable    = 'FALSE'.

* Populate the dependant object table
    ls_object-bee                   ?= ls_cellerator.
    APPEND ls_object TO et_object_bindings.

* Now populate the item conditions when an item is expanded
* When quotation items are expanded, the importing parameter iv_object_id
* contains the cellerator id generated above.

  ELSE IF iv_object_id CS 'Items'.

* Get the current context node
    gr_row_entity ?= me->gr_coll->find( iv_index = iv_row_index ).
    entity ?= gr_row_entity.

* Create a reference for the second dependant object, Condition types
    CREATE OBJECT lr_condline_iterator.
    lr_causal_iterator->gr_entity = entity.

* Create a reference to cl_thtmlb_cellerator &
* pass the condition types iterator. ( Refer image Level 2)
    CREATE OBJECT ls_cellerator.

* Generate cellerator id by concatenating the selected row index.
* This is done to identify the index of the item expanded for conditions view
    CONCATENATE
        'condset'
          lv_row_index
          INTO ls_cellerator->id.

    ls_cellerator->headertext        = lv_objectid.
    ls_cellerator->_table            = '//BTCondSet/TABLE'.
    ls_cellerator->editmode          = ls_cellerator->gc_edit_mode_none.
    ls_cellerator->personalizable    = 'FALSE'.
* Assign the reference object for items iterator
    ls_cellerator->iterator          = lr_conditions_iterator.
    ls_object-bee ?= ls_cellerator.

* Populate the dependant object table
    ls_object-bee                   ?= ls_cellerator.
    APPEND ls_object TO et_object_bindings.
  ENDIF.

EndMethod.

Quotation items iterator: ( Level 1 dependent object )

Create an iterator with interface IF_HTMLB_TABLEVIEW_ITERATOR.

Define the columns to be displayed in method GET_COLUMN_DEFINITIONS.

  ls_column-columnname = 'NUMBERINT'.
  ls_column-title      = 'No:'.
  ls_column-edit       = 'X'.
  ls_column-wrapping   = 'X'.
  ls_column-width      = '200px'.
  APPEND ls_column TO p_column_definitions.

Define cell rendering in method RENDER_CELL_START.

IF p_column_key EQ 'NUMBERINT'.

* Create reference to cl_thtmlb_inputfield.
      CREATE OBJECT lr_data.
      lr_data->width     = '100%'.
      lr_data->value     = gr_row_entity->get_property_as_string( iv_attr_name =  'NUMBER_INT' ).
      SHIFT lr_data->value LEFT DELETING LEADING '0'.
      lr_data->id        = p_cell_id.
      lr_data->disabled  = 'TRUE'.
      lr_data->maxlength = 50.

* Assign the input field reference to replacement BEE.
      p_replacement_bee  = lr_data.
ENDIF.

Item condition types iterator: ( Level 2 dependent object )

Create an iterator with interface IF_HTMLB_TABLEVIEW_ITERATOR.

Define the columns to be displayed in method GET_COLUMN_DEFINITIONS.

  ls_column-columnname = 'VTEXT'.
  ls_column-title  = 'Pricing Element'.
  ls_column-edit  = 'X'.
  ls_column-wrapping  = 'X'.
  ls_column-width  = '200px'.
  APPEND ls_column TO p_column_definitions.

Define cell rendering in method RENDER_CELL_START.
 
IF p_column_key EQ 'VTEXT'.

* Create reference to cl_thtmlb_inputfield.

      CREATE OBJECT lr_data.
      lr_data->width     = '100%'.
      lr_data->value     = gr_row_entity->get_property_as_string( iv_attr_name = 'VTEXT' ).
      SHIFT lr_data->value LEFT DELETING LEADING '0'.
      lr_data->id        = p_cell_id.
      lr_data->disabled  = 'TRUE'.
      lr_data->maxlength = 50.

* Assign the input field reference to replacement BEE.
      p_replacement_bee  = lr_data.

ENDIF.

Related Content

Please include at least three references to SDN documents or web pages.

http://wiki.sdn.sap.com/wiki/display/CRM/CRM+Web+Client+UI+Framework

http://wiki.sdn.sap.com/wiki/display/CRM/How+to+display+a+z-table+in+an+assignment+block

Useful Information

Short note about how to add multiple context nodes to a table view 

Regards,

Arun Kumar