Wednesday, July 6, 2011

Call lists: Creating a new call in a call list

There are several ways to add calls to a call list, for instance the following:

1. Manually in transaction CRMD_TM_CLDIST
2. Generated using transaction CRMD_CALL_LIST
3. In ABAP using classes cl_tm_clm_interaction and cl_clm_call_list.

Creating calls manually
When maintaining call lists in the IC Manager role, it is not possible to manually add calls to the call list. When maintaining call lists in SAPGUI in transaction CRMD_TM_CLDIST though, you are able to manually add a call by clicking the new-button, and adding information. 

Generating call lists
When building call lists using GUI transaction CRMD_CALL_LIST, calls are added to the generated call list automatically based on the selection of businesspartners.

Creating calls in ABAP
In some cases you might want to build a custom interface, report, function, IDI service or action definition that adds a customer to a specific call list. This is fairly easy if you know which classes to use.

In order to create a call and assign it to a call list, you will need three classes. cl_tm_clm_interaction to create the call, cl_clm_call_list to assign it to the call list and cl_tm_business_context to assign an activity, a campaign and a Business Partner to the call. In this example we will only be adding a Business Partner.

* First, you create the call, nothing specific yet.
DATA: lo_call TYPE REF TO cl_tm_clm_interaction.
lo_call = cl_tm_clm_interaction=>create( ).

* Then we retrieve the business context from the call.
DATA: lo_business_context TYPE REF TO cl_tm_business_context lo_business_context = lo_call->get_business_context( ).
lv_bp_guid = <GUID of the businesspartner>

* Add Business Partners to the call
lo_business_context->add_business_partner( lv_bp_guid ).

DATA: lt_call TYPE TABLE OF REF TO cl_tm_clm_interaction.
APPEND lo_call TO lt_call.

* Get the call list
DATA: lo_list TYPE REF_TO CL_CLM_CALL_LIST
lo_list = cl_tm_clm_session=>get_call_list_by_id( <GUID of the call list> ).

* Add the calls to the call list
DATA: lo_interactions TYPE REF TO cl_tm_clm_interactions.
lo_interactions = lo_list->get_interactions_container( ).
lo_interactions->add_interactions( lt_call ).

COMMIT WORK.

You can also add an activity to the call using class cl_tm_pxy_activity. This will enable you to also show the activity in the customer overview, and enable you to use the call state synchronization.

Once assigned to a call list, you can also add values to the call such as the complete_by date.

I have left the error handling out of the example above, but of course, some try and catch statements to avoid dumps should be implemented as well.
Using the code above, you can easily create calls from any abap source, such as an interface, a report, an action etcetera.

No comments:

Post a Comment