| Component | Support Package |
|---|
| BBPCRM | SAPKU70204 |
| SAP_ABA | SAPKA73105 |
| SAP_BASIS | SAPKB73105 |
| WEBCUIF | SAPK-73105INWEBCUIF |
Hi everyone,
This time is a very short and quite simple blog but I hope is useful enough :smile:
Scenario
I want to determine and redetermine some custom fields which are generated via AET on CRMD_CUSTOMER_I, the values for the custom fields on each item rely on all the items of the order.
PPF and Actions
From here I expect you have some basics about PPF and Actions if is not your case I would suggest the following readings:
Solution
After creating the action profile, the action and assign them to corresponding business transaction the only thing you should take "special" attention is in the action definition.
I implemented a new PFF BADI for the method call (EXEC_METHODCALL_PPF) and inside the method, I did all my stuff and finally I called the API CRM_ORDER_MAINTAIN, what happened? since I'm modifying the document itself once I register it for saving, the action will be trigered again and again and again becoming a endless loop. and now what?
Note 1034624 - Dependencies between actions and side effects, gives you the solution/hint to overcome this issue, the secrete relays on the static methods ACTION_EXECUTED_SAVE and ACTION_WAS_EXECUTED_SAVE of the class CL_ACTION_EXECUTE.
A typical example of the implementation of those two method is:
Begining of the BADI for the method call:
METHOD if_ex_exec_methodcall_ppf~execute.
INCLUDE crm_log_states_con.
INCLUDE crm_object_kinds_con.
DATA: lo_action_execute TYPE REF TO cl_action_execute,
DATA: lv_guid_ref TYPE crmt_object_guid,
lv_kind_ref TYPE crmt_object_kind.
lv_message TYPE char80.
********************************************************************
* not relevant iv preview is active
IF NOT ip_preview IS INITIAL.
MESSAGE s007(crm_action) INTO lv_dummy.
cl_log_ppf=>add_message( ip_problemclass = '4'
ip_handle = ip_application_log ).
RETURN.
ENDIF.
CREATE OBJECT lo_action_execute.
* get parameter from reference object
CALL METHOD lo_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_guid_ref
ev_kind_ref = lv_kind_ref.
* Only on header level
IF lv_kind_ref NE gc_object_kind-orderadm_h.
MESSAGE s010(crm_action) WITH lv_kind_ref INTO lv_dummy.
cl_log_ppf=>add_message( ip_problemclass = '1'
ip_handle = ip_application_log ).
RETURN.
ENDIF.
IF cl_action_execute=>action_was_executed_save( iv_head_guid = lv_guid_ref
iv_action = ip_action ) EQ abap_true.
* Prevent endless loop
RETURN.
ENDIF.
Ending of the BADI for the method call:
cl_action_execute=>action_executed_save( EXPORTING iv_head_guid = lv_guid_ref
iv_action = ip_action ).
* Save the document
CALL METHOD lo_action_execute->register_for_save
EXPORTING
iv_source_header_guid = lv_guid_ref
ip_application_log = ip_application_log
* iv_recursive_det =
IMPORTING
rp_status = rp_status.
ENDMETHOD.
I know this is not a something very complicated or hard to figure it out, but I looked at scn and I didn't find it, so why not? :wink:
Cheers!
Luis