Skip to Content
Author's profile photo Former Member

REX 3.0: Enabling flow of all activities of an account to REX irrespective of Employee Responsible


Activities on REX 3.0 flow to REX based on the Sales Rep syncing the device.

All activities on the account by standard will flow to the front end given the activity should have the same Sales Representative (Syncing from the Device) as Employee Responsible and within the days profile. (Please refer about the days profile and the modification from the standard process in the article Enabling Count based filter for activities on REX 3.0)

We faced the challenge to implement the activity flow to mobile on REX 3.0 as the requirement was that of all the activities on account irrespective of employee responsible should flow to REX.The scope of this document is the modification required to achieve the same.

Technical Flow Description

  • The parameter ET_ACTIVITY_GUIDS of the internal FM ‘/MAC/RSFM_GET_USR_ACT_LIST’ of BAPI /MAC/RSFM_GET_USR_ACTIVITIES is updated with all the activity GUIDs of the customer.
  • The enhancement spot lr_badi_activity->/mac/rs_badi_act_get_list_bef of  FM of /MAC/RSFM_GET_ACT_LIST is implemented (ZBADI_IMPL_ACT)to update the GUIDs.
  • The implementation class ZBADI_IMPL_ACT is created and made required changes in the method /MAC/RS_BADI_IF_ACT~/MAC/RS_BADI_ACT_GET_LIST_BEF.

ABAP Development

  The below logic is included in the method /MAC/RS_BADI_IF_ACT~ /MAC/RS_BADI_ACT_GET_LIST_BEF: 

  • The functional module ZGET_USER_DETAILS is called to differentiate the DEX user for this enhancement by checking the business unit of the user ‘UFS’.
  • The selection criteria to fetch the activity GUIDs are as :
    • Transaction type : All DEX REX transaction type( FM : /MAC/RSFM_GET_SRV_CUSTOMIZING, Parameter ET_ACT_DOWN_PARAM)
    • Partner function: ‘00000009’ (Activity Partner).
    • Partner: the entire customer for whom the SR is employee responsible (FM /MAC/RSFM_GET_BP_LIST, Parameter ET_ACCOUNT_ID).
    • Date: Valid from, valid to from REX date profile.

The standard REX code in the FM is skipped by setting value CV_SKIP = ‘X’.

Sample code

METHOD /mac/rs_badi_if_act~/mac/rs_badi_act_get_list_bef.

CONSTANTS:lc_eq(2)             TYPE c VALUE ‘EQ’,
lc_i                 TYPE c VALUE ‘I’,
lc_object_type       TYPE name_komp        VALUE ‘OBJECT_TYPE’,
lc_process_type      TYPE name_komp        VALUE ‘PROCESS_TYPE’,
lc_category          TYPE name_komp        VALUE ‘CATEGORY’,
lc_partner_fct       TYPE name_komp        VALUE ‘PARTNER_FCT’,
lc_valid_from        TYPE name_komp        VALUE ‘VALID_FROM’,
lc_valid_to          TYPE name_komp        VALUE ‘VALID_TO’,
lc_bu_partner        TYPE name_komp        VALUE ‘BU_PARTNER’,
lc_bus2000110        TYPE tvarv_val        VALUE ‘BUS2000110’,
lc_orderadm_h        TYPE crmt_object_name VALUE ‘ORDERADM_H’,
lc_activity_h        TYPE crmt_object_name VALUE ‘ACTIVITY_H’,
lc_appointment       TYPE crmt_object_name VALUE ‘APPOINTMENT’,
lc_partner           TYPE crmt_object_name VALUE ‘PARTNER’,
lc_status            TYPE crmt_object_name VALUE ‘STATUS’,
lc_rejected          TYPE crm_j_status     VALUE ‘I1032’,
lc_closed            TYPE crm_j_status     VALUE ‘E0009’,
lc_cancelled         TYPE crm_j_status     VALUE ‘E0007’,
lc_finished          TYPE crm_j_status     VALUE ‘I1008’,
lc_docflow           TYPE crmt_object_name VALUE ‘DOC_FLOW’.


DATA: lv_start_date            TYPE sy-datum,
lv_end_date              TYPE sy-datum,
lv_guid                  TYPE guid_32,            “#EC NEEDED
lv_days_ahead            TYPE /mac/rsde_no_days,
lv_days_back             TYPE /mac/rsde_no_days,
lv_subrc                 TYPE sysubrc,
lv_index                 TYPE sy-index,
lv_past_no               TYPE zno_of_objects,
lv_future_no             TYPE zno_of_objects.

DATA: lr_1o_search             TYPE REF TO cl_crm_q1o_search.

DATA: i_selection_param        TYPE genilt_selection_parameter_tab,
i_guids                  TYPE crmt_object_guid_tab,
i_doc_flow               TYPE crmt_doc_flow_wrkt,
i_return                 TYPE bapiret2_t,
i_return_val             TYPE bapiret2_t,
i_act_data               TYPE REF TO data,
i_tran_type_down         TYPE /mac/rst_act_down_param,
i_device_transactions    TYPE /mac/rst_device_trans,
i_account_id             TYPE /mac/rst_bp_id,
i_column_value           TYPE TABLE OF zcolumnvalue,
i_act_guids              TYPE crmt_object_guid_tab,
i_requested_objects      TYPE crmt_object_name_tab,
i_orderadm_h             TYPE crmt_orderadm_h_wrkt,
i_activity_h             TYPE crmt_activity_h_wrkt,
i_appointment            TYPE crmt_appointment_wrkt,
i_partner                TYPE crmt_partner_external_wrkt,
i_status                 TYPE crmt_status_wrkt.

DATA: wa_selection_param       TYPE genilt_selection_parameter,
wa_act_tab               TYPE crmst_query_r_act_btil,
wa_tran_type_down        TYPE /mac/rss_act_down_param,
wa_account_id            TYPE /mac/rss_bp_id,
wa_sales_org             TYPE /mac/rss_crm_erp_sales_org,
wa_guid                  TYPE guid_32,
wa_act_guids             TYPE crmt_object_guid,
wa_doc_flow              TYPE crmt_doc_flow_wrk,
wa_requested_objects     TYPE crmt_object_name,
wa_orderadm_h            TYPE crmt_orderadm_h_wrk,
wa_activity_h            TYPE crmt_activity_h_wrk,
wa_appointment           TYPE crmt_appointment_wrk,
wa_partner               TYPE crmt_partner_external_wrk,
wa_status                TYPE crmt_status_wrk,
wa_no_act                TYPE zact_cnt.

DATA: wa_activities    TYPE crmst_query_r_act_btil,
i_activities     TYPE crmt_query_r_act_btil,
i_all_activities TYPE crmt_query_r_act_btil,
lv_result_size              TYPE i,
lv_delete_from_index        TYPE i.

“Read mobile relevant customization – Activity Type, Partner Function, Days Back and Days Ahead
iv_act_flag       = ‘X’
et_act_down_param = i_tran_type_down.
et_device_transactions = i_device_transactions.

iv_user_id   = sy-uname
es_sales_org = wa_sales_org.
LOOP AT i_tran_type_down  INTO wa_tran_type_down.
      ” Define Transaction Type Filter  from Customization
IF wa_tran_type_down-process_type IS NOT INITIAL.
READ TABLE i_device_transactions WITH KEY process_type = wa_tran_type_down-process_type
  device_trans_key = ‘0001’ TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
CLEAR wa_selection_param.
wa_selection_param-attr_name = lc_process_type.
wa_selection_param-sign      = lc_i.
wa_selection_param-option    = lc_eq.
wa_selection_param-low       = wa_tran_type_down-process_type.
APPEND wa_selection_param TO i_selection_param.

” Define category Filter  from Customization
CLEAR wa_selection_param.
wa_selection_param-attr_name = lc_category.
wa_selection_param-sign      = lc_i.
wa_selection_param-option    = lc_eq.
wa_selection_param-low       = wa_tran_type_down-act_category.
APPEND wa_selection_param TO i_selection_param.


” Define Business Object Category Filter -Fetch Activities & Task
    CLEAR wa_selection_param.
wa_selection_param-attr_name = lc_object_type.
wa_selection_param-sign      = lc_i.
wa_selection_param-option    = lc_eq.
wa_selection_param-low       = lc_bus2000110.
APPEND wa_selection_param TO i_selection_param.

“Partner Function for activity partner
    CLEAR wa_selection_param.
wa_selection_param-attr_name = lc_partner_fct.
wa_selection_param-sign      = lc_i.
wa_selection_param-option    = lc_eq.
wa_selection_param-low       = ‘00000009’.
APPEND wa_selection_param TO i_selection_param.

” Get accounts for sy-user
et_account_id = i_account_id.

IF i_account_id IS NOT INITIAL.

LOOP AT i_account_id INTO wa_account_id WHERE partner_id IS NOT INITIAL.

CLEAR wa_selection_param.
wa_selection_param-attr_name = lc_bu_partner.
wa_selection_param-sign      = lc_i.
wa_selection_param-option    = lc_eq.
wa_selection_param-low       = wa_account_id-partner_id.
APPEND wa_selection_param TO i_selection_param.

“Valid From Date
        lv_days_back = wa_tran_type_down-days_behind.
IF lv_days_back IS INITIAL.
lv_start_date = sy-datum.
lv_start_date = sy-datum – lv_days_back. “Deduct the days back to get the valid from date

CLEAR wa_selection_param.
wa_selection_param-attr_name = lc_valid_from.
wa_selection_param-sign      = lc_i.
wa_selection_param-option    = lc_eq.
wa_selection_param-low       = lv_start_date.
APPEND wa_selection_param TO i_selection_param.

“Valid To Date
lv_days_ahead = wa_tran_type_down-days_ahead.
IF lv_days_ahead IS INITIAL.
lv_end_date = sy-datum.
lv_end_date = sy-datum + lv_days_ahead.  “Add the days ahead to get the valid to date

CLEAR wa_selection_param.
wa_selection_param-attr_name = lc_valid_to.
wa_selection_param-sign      = lc_i.
wa_selection_param-option    = lc_eq.
wa_selection_param-low       = lv_end_date.
APPEND wa_selection_param TO i_selection_param.

“Set the Selection Parameters to Activity Object Search
        CREATE OBJECT lr_1o_search.

CALL METHOD lr_1o_search->set_selection_parameters
iv_obj_il                 = ‘BTQACT’
it_selection_parameters   = i_selection_param
et_return                 = i_return
partner_fct_error         = 1
object_type_not_found     = 2
multi_value_not_supported = 3
OTHERS                    = 4.

lv_subrc = sy-subrc.
IF lv_subrc <> 0.

CREATE DATA i_act_data TYPE TABLE OF crmst_query_r_act_btil.
ASSIGN i_act_data->* TO <activity_tab>.
“Run the Activity query
CALL METHOD lr_1o_search->get_result_values
iv_max_hits = ‘999999999’
et_results  = i_activities
et_return   = i_return.

IF sy-subrc <> 0.
APPEND LINES OF i_return TO i_return_val.

ELSEIF i_activities[] IS NOT INITIAL.

APPEND LINES OF i_activities TO i_all_activities.
REFRESH i_activities.

cv_skip = ‘X’.


********Above documents were co authored by my fellow colleague Karthi Dhayalan. *********

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.