How to change Target Group status in yMKT
Maybe this is not new for you, but the idea of this documentation is to show you how to perform a status change in yMKT and some general hints on the possible actions.
We had a requirement to set the TGs to complete based on some conditions. We came up with a report to run in background to do so and I will so you how to achieve a status change using the BOPF framework in yMKT.
Fisrt thing, since I’m new to tech side of yMKT world, I was struggling a little bit to manage the status change and any other action possible from the UI level.
There is a transaction in yMKT where you can choose the action you want to trigger and it will display the class that executes that allowing us to debug in an easy way.
Transaction is: BOPF_EWB
You will have the following view:
Here started my quest I could find how the system is triggering internally the status changes and reproduce it.
If we double click on the left handed side menu where it shows CUAN_TARGET_GROUP we will be able to see the actions available.
If we double click the actions, you will be able to see on the right handed side, the implementation class, where you can place your break-point and debug it.
Please note that in this screen we can see actions, queries and associations.
So if you have a doubt on how the system is performing something, just have a look here. Maybe it you help you as it helped me.
Now, if you want to change the status of the TG, please note that this is a very different framework.
You have to perform the action, which is a hardcoded GUID in the system.
The GUID to perform the status change from released to completed is here if_cuan_target_group_c=>sc_action-root-close. All the rest can be checked here if_cuan_target_group_c=>sc_action-root.
In the example code below I’m providing, you can see that first we are performing the action dictated by the GUID for a specific TG. Please note that there is no error handling. It’s just a simple code.
Once you perform the status change, you have to save it to reflect the changes into the DB.
Here it’s the sample code:
DATA: lr_service_manager TYPE REF TO /bobf/if_tra_service_manager,
lv_act_key TYPE /bobf/act_key,
ls_bopf_key TYPE /bobf/s_frw_key,
lt_bopf_key TYPE /bobf/t_frw_key,
lr_message TYPE REF TO /bobf/if_frw_message,
lt_failed_key TYPE /bobf/t_frw_key,
lco_tm TYPE REF TO /bobf/if_tra_transaction_mgr.
CLEAR: lco_tm, lr_service_manager, lt_bopf_key, lr_message, lt_failed_key.
lco_tm = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
lr_service_manager = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = if_cuan_target_group_c=>sc_bo_key ).
ls_bopf_key-key = ls_targetgroup-db_key. “TG GUID -> " Found it in CUAN_D_TG_ROOT
APPEND ls_bopf_key TO lt_bopf_key.
lv_act_key = if_cuan_target_group_c=>sc_action-root-close.
CALL METHOD lr_service_manager->do_action
iv_act_key = lv_act_key
it_key = lt_bopf_key
eo_message = lr_message
et_failed_key = lt_failed_key.
IF lt_failed_key IS INITIAL.
DATA: lv_failed TYPE abap_bool.
CALL METHOD lco_tm->save
ev_rejected = lv_failed
eo_message = lr_message.
IF lv_failed = abap_true.
*Implement you error handling here
I hope it helps you guys!