Bruno Hello again,
I am calling it from webui. As you can see my current code block below, I was checking the role of the user and changing the F4 help. But now, I need to change the F4 help depending on the order type which is process type. To do this, I need to get the order's guid. You may also check the picture that I have attached.
function zcrm_approval_step_id_f4help.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCR_TAB_T
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------
data: lr_entity type ref to cl_crm_bol_entity,
lv_collection type ref to if_bol_bo_col,
lr_core type ref to cl_crm_bol_core,
lr_fac type ref to cl_crm_bol_entity_factory,
lt_params type crmt_name_value_pair_tab,
ls_params type crmt_name_value_pair,
lr_ent type ref to cl_crm_bol_entity,
lv_guid type string,
lv_name type crmt_ext_obj_name,
lr_gdc type ref to if_crm_ui_data_context,
lr_bt type ref to cl_crm_bol_entity,
lr_adminh type ref to cl_crm_bol_entity,
lv_proctype type crmt_process_type.
data: ls_record type seahlpres,
lt_search type crmt_approval_s_f4_disp_tab,
ls_user_role type string,
lr_profile_instance type ref to if_crm_ui_profile.
field-symbols:
<fs_search> like line of lt_search.
if callcontrol-step = 'DISP'.
clear ls_user_role.
lr_gdc ?= cl_crm_ui_data_context_srv=>get_instance( ).
check lr_gdc is bound.
lr_bt ?= lr_gdc->get_entity( name = if_iccmp_global_data_cont_con=>gdc_currentbt ).
check lr_bt is bound.
"Get process type directly
lr_adminh ?= lr_bt->get_related_entity( 'BTOrderHeader' ).
check lr_adminh is bound.
lv_proctype = lr_adminh->get_property_as_string( 'PROCESS_TYPE').
* lr_profile_instance = cl_crm_ui_profile=>get_instance( ).
* lr_profile_instance->get_profile( receiving rv_result = ls_user_role ).
call function 'CRM_APPROVAL_GET_STEPS_F4_DISP'
importing
et_approval_s_f4 = lt_search.
* if ls_user_role eq 'ZA' OR ls_user_role eq 'ZB'.
delete lt_search where step_id ne 'ZXX' and step_id ne 'ZYY'.
* endif.
loop at lt_search assigning <fs_search>.
clear ls_record.
ls_record-string = <fs_search>.
collect ls_record into record_tab.
endloop.
endif.
endfunction.