Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 

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

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:-

Containing 1 record:-

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:-

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




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:-

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:-

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

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:-

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

  

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


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





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:-



9 Comments
Labels in this area