on 10-30-2012 11:53 AM
Hello Experts,
We are into SRM 7.0 and use process controlled workflow.
I have designed n step approval workflow for SC and it includes duplicate approver removal.I am fetching approvers from a z table and while selecting the approvers, I exclude the approver who has previously approved using Retrieve process history. Below is a scenario.
For 3 level approval workflow, if approver x1 has approved the first level and he/she is also there in level 2nd and 3rd then he/she would be eliminated from that approval process. It works well when there are multiple approvers for single item.
level approver status
1 x1,x2 active
2 x1,x3 valid
3 x1,x4 valid
after approval
level approver status
1 x1 approved
2 x3 active
3 x4 valid
In above scenario, there is no problem and workflow works well.
But it returns blank approver when there is only single approver present for both levels.
Below is the example.
level approver status
1 x1 active
2 x1 valid
after approval
level approver status
1 x1 approved
2 valid
As it is observed, the approver is blank here because it eliminates x1as an approver. In effect, it returns blank. Now my questions is whether there is any mechanism present so that we would replicate the decision in the same level. I mean could we make 2nd level as approved automatically? If not can we make 2nd level as automatically approved ?
Has anyone faced such scenario ? Please share your ideas/suggestions.
Best regards.
Dear Abhijit,
you have a wrong approach.
If all relevant approvers for the second step already approved SC, then the second step should not appear in Workflow at all. Define your own Evaluation ID in Process Level Configuration and own Expression with Data Access via BADI.
For that purpose you can use BADI BRF_EXPRESSION.
Best Regards
Konstantin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Konstantin,
Thank you for your reply.
Yes. I do agree that once relevant approvers for the second step already approved SC in previous level, then the second step should not appear in Workflow at all. That is why I have created a FM expression of type character 1. In that, I am calling a method CALL METHOD /SAPSRM/CL_WF_APV_FACADE=>RETRIEVE_PROCESS_HISTORY.
I am doing in the following way.
DATA ls_approver TYPE /sapsrm/s_wf_approver. "added by 528434
data : level_status type /SAPSRM/WF_PROCESS_LEVEL_STAT,
resolver_name type /SAPSRM/WF_RESP_RESOLVER_NAME,
evaluation_id TYPE /SAPSRM/WF_EVALUATION_ID,
lv_agent type /SAPSRM/WF_APPROVER_ID,
ls_process type /SAPSRM/S_WF_PROCESS,
lt_process TYPE /SAPSRM/T_WF_PROCESS_LEVEL_S,
lr_process type REF TO /SAPSRM/S_WF_PROCESS_LEVEL,
lt_decisionset_list TYPE /SAPSRM/T_WF_DECISIONSET_S,
lr_decisionset type REF TO /SAPSRM/S_WF_DECISIONSET,
lt_itemstatuslist TYPE /SAPSRM/T_WF_DS_ITEM_STATUS,
lr_itemstatuslist TYPE REF TO /SAPSRM/S_WF_DS_ITEM_STATUS,
lt_agentlist type /SAPSRM/T_WF_APPROVER,
lr_agentlist TYPE REF TO /SAPSRM/S_WF_APPROVER,
ls_agentlist type /SAPSRM/S_WF_APPROVER,
item_status TYPE /SAPSRM/WF_DS_ITEM_STATUS,
lt_workitem type /SAPSRM/T_WF_WORKITEM_S,
lr_workitem type REF TO /SAPSRM/S_WF_WORKITEM,
ls_workitem type /SAPSRM/S_WF_WORKITEM,
agent type /SAPSRM/WF_AGENT_ID,
approver_ot TYPE /SAPSRM/WF_APPROVER_OT,
approver_id type /SAPSRM/WF_APPROVER_ID.
DATA : it_catman TYPE STANDARD TABLE OF ty_catman,
wa_catman type ty_catman,
temp_value TYPE c.
DATA : history_instance TYPE REF TO /SAPSRM/CL_WF_APV_FACADE.
data : ls_process_level TYPE /SAPSRM/S_WF_PROCESS_LEVEL.
data : it_item type STANDARD TABLE OF BBP_PDS_SC_ITEM_D, "table
wa_item type BBP_PDS_SC_ITEM_D.
data : cat_id TYPE COMT_CATEGORY_ID.
data : is_process_level TYPE /SAPSRM/S_WF_PROCESS_LEVEL,
level_guid TYPE /SAPSRM/WF_PROCESS_LEVEL_GUID,
resolver_name1 TYPE /SAPSRM/WF_RESP_RESOLVER_NAME.
ev_type = /sapsrm/if_wf_rule_c=>TYPE_CHAR."'B'.
ev_length = 1.
CLEAR ev_currency.
ev_output_length = 1.
ev_decimals = 0.
ev_value = abap_true. " no processing
CALL METHOD /SAPSRM/CL_WF_APV_FACADE=>RETRIEVE_PROCESS_HISTORY
EXPORTING
IV_DOCUMENT_GUID = lv_document_guid
IV_AGENT_ID = lv_agent
IV_LANGUAGE = sy-langu
IMPORTING
ES_PROCESS = ls_process
.
lt_process = ls_process-PROCESS_LEVEL_LIST.
loop at lt_process REFERENCE INTO lr_process.
resolver_name = lr_process->resolver_name.
evaluation_id = lr_process->evaluation_id.
level_status = lr_process->level_status.
if resolver_name = 'Z902_IMMNGR'. "and level_status = 'COMPLETED'.
lt_decisionset_list = lr_process->decisionset_list.
loop at lt_decisionset_list REFERENCE INTO lr_decisionset.
lt_itemstatuslist = lr_decisionset->ITEM_STATUS_LIST.
loop at lt_itemstatuslist REFERENCE INTO lr_itemstatuslist.
item_status = lr_itemstatuslist->item_status.
if item_status = 'APPROVED'.
lt_workitem = lr_decisionset->workitem_list.
loop at lt_workitem REFERENCE INTO lr_workitem.
agent = lr_workitem->agent.
endloop.
else.
agent = 'MANAGER999'.
endif.
endloop.
endloop.
else.
agent = 'MANAGER999'.
ENDIF.
endloop.
refresh : it_catman[].
refresh : rt_approver[].
select category_id cat_approver from ZAPPROVAL_CAT into table it_catman.
LOOP AT it_catman INTO wa_catman.
if wa_catman-manager = agent.
temp_value = 'X'.
ELSE.
temp_value = ' '.
ENDIF.
ENDLOOP.
if temp_value = 'X'.
ev_value = 'X'.
elseif temp_value = ' '.
ev_value = ' '.
clear ev_data_missing.
endif.
The purpose is when ev_value returns 'X', then level should not trigger.
But I am facing one issue here. My table lt_process is blank. I am not able to figure it out why it is getting blank (initial). I debugged several times. I also noted that same piece of code works fine and shows contents of the lt_process when it is written in customized class.
Is that table initialized because it is done in FM expression ? It should contain level guid, resp_resolver_name details etc. Am I doing anything wrong here ?
Please share your ideas.
Best regards.
Abhijit.
Hello Konstantin,
Thank you again for your quick reply. I am using RETRIEVE_PROCESS_HISTORY purposely so that I could find who has approved previous level and then it is easier to eliminate him, in effect, the level would not trigger. That was my idea. With GET_PROCESS_INFO would I be able to do the same ?
Please guide.
Share your idea.
Best regards.
Abhijit.
I've tried following.
TRY.
CALL METHOD /sapsrm/cl_wf_apv_facade=>get_process_info
EXPORTING
iv_document_guid = '0017A477C8301ED289FD4D9484793C02'
iv_document_type = /sapsrm/if_pdo_obj_types_c=>gc_pdo_shop
iv_agent_id = 'WF-BATCH'
IMPORTING
es_process_info = ls_process_info.
CATCH /sapsrm/cx_wf_abort .
CATCH /sapsrm/cx_wf_error .
ENDTRY.
works fine for me...
Hello Konstantin,
Indeed thank you very much for your continuous helpful replies. Your code is right. Unfortunately, I am not still able to get APPROVED status and approver in the debugging. Debugger hits the code (function module expression ) twice i.e. before ordering the SC and after ordering the SC. After approving first level, it should again hit to the function module expression and get the approver of the previous level. That is not working. I am really couldn't get why it doesn't hit the function module espression after 1st level is approved.
My goal is, it should hit the function module expression after first level is approved so that i should be able to delete that approver if the existing level approver is same as of the previous level. I am trying to achieve this in following way.
data : lt_PROC_DETAIL_LIST type /SAPSRM/T_WF_PROC_DETAIL,
lr_proc_detail_list type ref to /SAPSRM/S_WF_PROC_DETAIL,
WORKITEM_LIST type /SAPSRM/T_WF_WORKITEM_BASE,
lr_workitem_list type ref to /SAPSRM/S_WF_WORKITEM_BASE,
agent_id TYPE /SAPSRM/WF_AGENT_ID,
agent_new TYPE /SAPSRM/WF_AGENT_ID.
data : lt_PROC_LEVEL_LIST type /SAPSRM/T_WF_PROC_LEVEL,
lr_proc_level_list type ref to /SAPSRM/S_WF_PROC_LEVEL,
lt_WORKITEM_LIST type /SAPSRM/T_WF_WORKITEM_BASE,
lr_workitem_list1 type ref to /SAPSRM/S_WF_WORKITEM_BASE,
status TYPE SWW_WISTAT.
TRY.
CALL METHOD /SAPSRM/CL_WF_APV_FACADE=>GET_PROCESS_INFO
EXPORTING
IV_DOCUMENT_GUID = lv_document_guid
IV_DOCUMENT_TYPE = /sapsrm/if_pdo_obj_types_c=>gc_pdo_shop "lv_document_type
* IV_CHANGE_VERSION_GUID =
IV_AGENT_ID = 'WF-BATCH' "lv_agent
* IV_WORKITEM_ID =
* IV_TRANSFORMATION = 'ID'
IMPORTING
* EV_WF_PROCESS_INFO_XML =
ES_PROCESS_INFO = is_process_info
.
CATCH /SAPSRM/CX_WF_ABORT .
CATCH /SAPSRM/CX_WF_ERROR .
ENDTRY.
lt_PROC_DETAIL_LIST = is_process_info-PROC_DETAIL_LIST.
LOOP at lt_PROC_DETAIL_LIST REFERENCE INTO lr_proc_detail_list.
lt_proc_level_list = lr_proc_detail_list->PROC_LEVEL_LIST.
LOOP at lt_proc_level_list REFERENCE INTO lr_proc_level_list.
RESOLVER_NAME = lr_proc_level_list->RESOLVER_NAME.
if RESOLVER_NAME = 'Z902_IMMNGR'.
lt_WORKITEM_LIST = lr_proc_level_list->WORKITEM_LIST.
loop at lt_WORKITEM_LIST REFERENCE INTO lr_workitem_list1.
if status = 'APPROVED'.
agent_id = lr_workitem_list1->agent_id.
else.
agent_id = 'MANAGER999'.
ENDIF.
ENDLOOP.
else.
agent_id = 'MANAGER999'.
endif.
ENDLOOP.
ENDLOOP.
if agent_id is INITIAL.
agent_id = 'MANAGER999'.
ENDIF.
refresh : it_catman[].
refresh : rt_approver[].
agent = 'MANAHGER999'.
select category_id cat_approver from ZAPPROVAL_CAT into table it_catman.
LOOP AT it_catman INTO wa_catman.
if wa_catman-manager = agent_id.
temp_value = 'X'.
ELSE.
temp_value = ' '.
ENDIF.
ENDLOOP.
if temp_value = 'X'.
ev_value = 'X'.
elseif temp_value = ' '.
ev_value = ' '.
clear ev_data_missing.
endif.
Please advise. Am I doing any mistake in the code ? Thank you.
Best regards.
Abhijit
Hi Konstantin,
I tried to debug with the user. After approving first level, it doesn't hit the FM expression. It just shows next approver ( same approver who approved previous level ) level. I am seriously not able to get it why it doesn't hi the FM expression in debugging. Thank you very much for your inputs.
Best regards.
Abhijit
Hello Gurus,
Please share your ideas/suggestions.
Can we skip this level and go to next level for approval ? Is this right approach ?
If so, how it can be done ? Kindly guide.
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear,
Did you try to forward the workitem with transaction SWIA to a user, which is able to approve it?
Best Reagrds,
Gergely
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Gergely,
Thank you for your quick reply.
Work item goes to the next approver. I can approve that. But on the portal, under processor tab I can see blank space. Also I get level status as Active. I would like to make that level approved (because same approver has already approved the item in the previous level ) and then workflow should go to the next level.
Best regards.
Abhijit
User | Count |
---|---|
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.