Wednesday, March 9, 2011

Save objects in the memory using the BDC (Business Data Context)

In the Interaction Center Webclient, a mechanism called Business Data Context (a.k.a. BDC) is used.
Don’t let them confuse you… BDC is sometimes also referred to as GDC (Global Data Context). It is actually the same.

The BDC is a set of objects stored in the Global Memory of your session. For instance, the CURRENTCUSTOMER is occupied when the business partner in the IC Webclient is confirmed.

Objects from the BDC can be used in the transaction launcher, but of course also in coding.

Standard, the Webclient UI (so for instance the SALESPRO role), does not use the BDC. However, it can be very interesting to know for instance what the last shown customer is, or what the last shown product was, or you can implement a button that calls a launch transaction, and just before calling the launch transaction, you fill the BDC with your current context (i.e., a button on the BP_HEAD).

The objects in the BDC are defined in the IMG:
Customer Relationship Management --> UI Framework --> Technical Role Definition --> Define Global Data Context Parameters

Here, you can add a parameter like ZACCOUNT of type BuilHeader or ZPRODUCT of type Product.

Now in the BSP Workbench, for instance in the BP_HEAD, you can add the following code:

data: __gdc type ref to if_crm_ui_data_context,
        lr_BuilHeader type ref to CL_CRM_BOL_ENTITY.

__gdc ?= cl_crm_ui_data_context_srv=>get_instance( ).

       lr_BuilHeader ?= <BuilHeader from the context>.
__gdc->set_entity( name = 'ZACCOUNT' value = lr_BuilHeader ).

If you implement this for instance in the BP_HEAD/BPHEADOverview --> DO_PREPARE_OUTPUT, the ZACCOUNT in the BDC will be overwritten every time a different customer is shown. This way, the parameter will always hold the last shown customer. This you might for instance use to call a transaction in the ERP system with a parameter.

No comments:

Post a Comment