Wednesday, July 25, 2012

Adding a date type to the item overview page

One of the selling points of SAP CRM is its configurable UI. You can easily adjust a screen to you business requirements and create different screens for different business roles. Nothing new so far, but have all been there, the business requests to show that one field that is not available in the standard.
For this blog this field is a specific date type, contract start date, which needs to be visible on item overview. This field is only available in the assigment block Dates.




The following steps need to be executed in the Component Workbench.
  • Find the correct component by using F2 in the CRM UI.
  • Enhance the Component ( For our example BT140I_SRVP).
  • Enhance the view ( For our example BT140I_SRVP/Details) by right clicking on the view and selecting enhance.
  • Create a new context node by right clicking on the folder context nodes.
    • Name: Sonething with Cont Start
    • Link the BOL Entity BTDate
  • In the Define Dependency screen fill
  • The link to BTADMINI for item (or BTADMINH for header)
  • In the BOL Relation field select the relation to the desired date type (Contract start) 

Completing the wizard will create a context node for your component. This new context node is however not linked directly to the correct super class. To change the Super Class of the created Context Node dubbel click on the name of the implementation class (like ZL_BT140I_S_DETAILS_CN01) of your newly created context node.
Go to Tab Properties, fill in a desciption since this is a mandatory field
Select Change Inheritance and fill in CL_CRM_UIU_BT_DATE_CN as super class.
Now that we have added a new super class we have inherited new methods and attributes this makes the already existing attribute Base_Entity_Name double. Remove the attribute and then check for errors and release the component.
We need to modify the ON_NEW_FOCUS method to below code.
  method ON_NEW_FOCUS.
  data: lv_collection type ref to if_bol_bo_col.
  lv_collection =  cl_crm_uiu_bt_date_tools=>on_new_focus( iv_focus_bo  = focus_bo
  iv_level     = 'I'
  iv_date_type = 'CONTSTART'
  iv_category  = 'T' ).
  me->collection_wrapper->set_collection( lv_collection ).

Pass the' I 'for Item, 'H' for Header
Pass the Date Type defined in the date profile
Pass the category as T for Dates.

Now we need to add the newly created context node as a field to the configuration of the component.
You can find the new context node in the available fields section.
The field that you need to select to display a date is `Current date´.







The Result

By redoing the above for the contract end date we have added to date fields that are now visible on the item overview. This same procedure can be used for other relationships of an item.