Skip to Content

/wp-content/uploads/2015/02/1st_page_650905.png

Applies to:

SAP CRM 7.0, EHP1 , EHP2,EHP3

Summary

  This particular document illustrates as to how we can use global data context in SAP CRM framework. The GDC is a set of objects stored in the Global Memory of your session. Just illustrate the case of Inventory system where there are barrage of screens for saving inventory data and in some cases you may need Inventory data while venturing into different screens that’s where Global data context mechanism could be used to retrieve old saved data. In this document I’ll be basically showcasing the usage in terms of already existing Custom BOL component and then using that BOL component in global data context by fetching the data from the BOL and then encompassing it in global data context and then using the global data context to retrieve the data.


Author(s): Rajwin Singh Sood

Company: Atos

Created on: 19th Feb 2015

Author Bio

/wp-content/uploads/2015/02/photo_650988.jpg

Rajwin Singh Sood is currently working as Team lead/Solution Architect at Atos. He has got experience of more than 9 years in SAP ABAP and SAP CRM web UI. He is also a SAP CRM EHP2 Certified associate consultant. Prior to working with Atos he had worked with SAP India(SAP Global Delivery), Capgemini , Accenture and Infosys. He worked in SAP CRM Web UI areas like BSP enhancements, transaction launchers, BOL Programming, BRFPlus .




Scenario for Global data Context

We’ll be using the scenario where we’ll have the ZBOL already created(you can search SCN with key word Creating ZBOL in SAP CRM and you’ll find umpteen number of SCN WIKI blogs/Links) corresponding to the custom database table. Over here I already had a custom table with employee details:-

/wp-content/uploads/2015/02/pic1_650999.jpg

Containing 1 record:-

PIC2.jpg

We’ll be using the Global data context in order to save this data which will be done in the steps below and then will be showing the same in the overview page of quotation as assignment block.

  I also already had preexisting custom GENIL component created with the name ZEMP_D which has the BOL object ZEMP_DEMO associated with it using the path SPRO->Customer Relationship Management->Generic Interaction Layer/Object Layer->Basic  Settings as per below screenshots:-

PIC3.jpg

PIC4.jpg

The root ZBOL object ZEMP_Details from the object table ZEMP_DET_OBJ:-


PIC5.jpg



Creating global data context for the scenario

In this step we need to navigate to the user area menu using SPRO->Customer Relationship Management->Technical Role Definition->Define Global Data Context Parameters, after which it navigates to the Maintenance view for defining data context parameters and click on new entry ZEMP_DETAILS which is the Z BOL object created above. Please refer to the below screen shot:-

/wp-content/uploads/2015/02/pic6_651013.jpg

Preparing the BSP component for the scenario and testing in Webui

As I had specified above we’ll be using the new BSP component(ZEMP_DATA1) which will show the data from the Z BOL root object ZEMP_DETAILS in the view(ZEMPDETAILS). Hence:-

  1. As first step you would need to create new BSP component (ZEMP_DATA1) with model in the runtime repository editor as ZEMP_DEMO.
  2. Then create a form type View ZEMP_DATA1/ ZEMPDETAILS with the context model node as Zemp_details as per below screenshots:-

/wp-content/uploads/2015/02/pic7_651023.jpg

3.     Create the new configuration and add the fields in that and then save the same. It should look like the one given below:-

/wp-content/uploads/2015/02/pic8_651024.jpg

Now after this is done we would need to code in such a way that we’ll first retrieve the data from the data base table ZEMP_PERS_DATA and then encapsulate it in Context node and then pass on that context node in the global data context which we created in above section. The code snippet is give below:-

Here we have written the code in Component controller method DO_INIT_CONTEXT so that the table retrieval logic is written only once when the component is loaded and not always:-

METHOD do_init_context.

CALL METHOD super->do_init_context

    .

DATA: lo_core TYPE REF TO cl_crm_bol_core,

lo_order TYPE REF TO cl_crm_bol_entity,

lo_temp TYPE REF TO if_bol_bo_property_access,

lt_params TYPE crmt_name_value_pair_tab,

ls_emp_det TYPE zemp_pers_data,

ls_params TYPE crmt_name_value_pair,

lo_factory TYPE REF TO cl_crm_bol_entity_factory.

DATA : lr_gdc TYPE REF TO if_crm_ui_data_context,

lr_entity TYPE REF TO cl_crm_bol_entity.

CLEAR: ls_params, lt_params, lo_order.

  FREE: lo_core,

        lo_order.

  lr_gdc ?= cl_crm_ui_data_context_srv=>get_instance( ).

lo_core = cl_crm_bol_core=>get_instance( ).

lo_factory = lo_core->get_entity_factory( ‘ZEMP_Details’ ).

****fetch the data from the data base table for data base DDIC structure please refer to the section above.

SELECT SINGLE * INTO ls_emp_det FROM zemp_pers_data WHERE emp_no EQ ‘1232’.

  IF ls_emp_det IS NOT INITIAL.

ls_params-name = ‘MANDT’.                               “#EC NOTEXT

ls_params-value = ls_emp_det-mandt.

APPEND ls_params TO lt_params.

ls_params-name = ‘EMP_NO’.                              “#EC NOTEXT

ls_params-value = ls_emp_det-emp_no.

    APPEND ls_params TO lt_params.

ls_params-name = ‘EMP_NAME’.                            “#EC NOTEXT

ls_params-value = ls_emp_det-emp_name.

APPEND ls_params TO lt_params.

ls_params-name = ‘EMP_LNAME’.                           “#EC NOTEXT

ls_params-value = ls_emp_det-emp_lname.

APPEND ls_params TO lt_params.

lo_order = lo_factory->create( lt_params ).

***the entity is created over here

lo_temp ?= lo_order.

****here we pass the entity to the global data context defined

lr_gdc->set_entity( name = ‘ZEMP_DETAILS’ value = lo_temp ).

ENDIF.

  1. ENDMETHOD.

Now from the above code we had already set the global data context. Now next code will be to use the global data context which have already set with the values above, we need to use the global data context in the current view ZEMP_DATA1/ ZEMPDETAILS  in order to automatically display the database values. For which again we’ll be coding it in method DO_INIT_CONTEXT with the below code snippet:-

METHOD do_init_context.

CALL METHOD super->do_init_context

    .

DATA: lr_gdc TYPE REF TO if_crm_ui_data_context,

lr_entity TYPE REF TO if_bol_bo_property_access.

lr_gdc ?= cl_crm_ui_data_context_srv=>get_instance( ).

***get the data populated in the global data context

lr_gdc->get_entity( EXPORTING name = ‘ZEMP_DETAILS’

RECEIVING value = lr_entity ).

CHECK lr_entity IS BOUND.

*****now set the data in the view

me->typed_context->zempdetails->collection_wrapper->add( lr_entity ).

  1. ENDMETHOD.

4.     Now we’ll be using this view as an assignment block in the Quotation over view page(BSP component BT115QH_SLSQ/SQHOverView) via component usage. In order to expose this via component usage we need to first add the view ZEMP_DATA1/ ZEMPDETAILS into the interface window as per below screenshot in the BSP component ZEMP_DATA1 as per below screenshot:-

/wp-content/uploads/2015/02/pic9_651032.jpg

5.     Now once the step 4 is done now we’ll create component usage in BSP component BT115QH_SLSQ as per below screenshot:-

  

Pic10.jpg

6.     Now add this as the assignment block in the overview window:-

/wp-content/uploads/2015/02/pic11_651034.jpg

/wp-content/uploads/2015/02/pic12_651044.jpg


Now add the assignment block in the configuration of the over view page BT115QH_SLSQ/SQHOverView as per below screenshot:-

Pic13.jpg





Now go to Web UI and search for any quotation and then open it in the over view page where you can see the data flowing from the global data context:-


Pic14.jpg


To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Mohamed Ansari

    Thanks for the document.

    I have the below point:

    Here you are creating the entity from transparent DB table , which is set & get via GDC.

    But the point is Transparent Table is accessible across the system without any lifetime.

    Which means instead of GDC , we can directly access the DB table in required places to set the entity. I feel here there is no need of GDC concept.

    BR,

    MOHAMED ANSARI

    (0) 
    1. Rajwin Singh Sood Post author

      hello Mohamed Ansari Sorry but I disgree with you. GDC is very important concept in case when we are trying deal with the data within the HTTP session. In other word when we have logged on to SAP CRM and there are certain areas wherein we need data for instance once the business partner and Contract account is confirmed and when we try to go to contacts in case of ISU Customer interaction center we can’t go back to data base and then get the relevant details. This will make CRM WEBUI very slow and also every case we need to fetch data. The purpose of GDC is to globally retrieve the data and thus make it available where ever we need it in BSP component.

      Hence your thinking is not correct. However the scenario which I had enumerated is just to give a simple snapshot of what is GDC just to give idea about usage of GDC in real world scneario its really useful.

      (0) 

Leave a Reply