Anda di halaman 1dari 6

SAP CRM: Creating an Action with a BADI Schedule Condition

Using actions in CRM are very useful, but become a little more complicated when you want the action to be triggered when only certain fields are updated. To do this you can trigger an action using a BADI. The following steps and code will assist you to create an action and to code a trigger using a BADI. Note that this is compiled using CRM version 5.0.

Triggering an action using code within a BADI instead of using a Schedule Condition
1. Go to transaction CRMC_ACTION_DEF and select the action profile where you will define the action and double click on Action Definition on the left.

2. Action Definition Screen Add a new entry for the new action, by clicking on the New Entries button:

3. Setup the action definition details and then Save

This allows for a badi to code the start condition 4. Then Double Click to define the Processing Types and define the processing
type as METHOD

4.1 Create the Method (press the paper button)

5. Go to transaction CRMC_ACTION_CONF and change, then click on create on the right and select the Action that was created

5.1 Double click on the action when added and then click on the Schedule condition Tab

5.2 Click on edit Condition Business Add-In Window will open and select Create

5.3 Give a name to the Implementation and the Define Filter can be the same name

6. Then add this newly created badi implementation to the Schedule Condition of the Action

6.1 Code Example that goes into the Start Condition Method

data: lr_crm_order type ref to cl_doc_crm_order. data: lv_guid type crmt_object_guid. data: lv_kind type crmt_object_kind. ep_rc = 4. catch system-exceptions move_cast_error = 4. lr_crm_order ?= io_context->appl. endcatch. check sy-subrc = 0. * set the value of ep_rc to 0 when the trigger condition is met * get kind and guid lv_guid = lr_crm_order->get_crm_obj_guid( ). lv_kind = lr_crm_order->get_crm_obj_kind( ).

* we now have the guid and kind so check whatever you need to in order to establish the trigger condition.
7. Then code the action method Click on Processing Details and the display implementation button

7.1 Example Code that goes into the action (this code performs what you need to be done when the action runs).
data: lcl_action_execute type ref to cl_action_execute. data: lv_ref_guid type crmt_object_guid, lv_ref_kind type crmt_object_kind. clear: lv_ref_guid, lv_ref_kind. create object lcl_action_execute. * call method lcl_action_execute->get_ref_object exporting io_appl_object = io_appl_object ip_action = ip_action ii_container = ii_container importing ev_guid_ref = lv_ref_guid ev_kind_ref = lv_ref_kind. *GET ITEM *do stuff with the guid on the CRM Order

8. The coding of your action is now completed and should work based on your scheduled condition. Try it out and good luck!

Anda mungkin juga menyukai