on 07-28-2015 10:55 AM
Hi Experts,
I request your ideas on the below item
1. SRM PO is created and ordered. Workflow is triggered and it is ready for manual approval.
2. When approver clicks on it the PO is approved and transferred to ECC.
But when after making changes to the same PO and ordered, the workflow is triggered and automatic approval is taking place. i.e it is not coming to the approver inbox for manual approval instead it is directly approved and transferred to ECC.
We need the PO approval for any change to be manual always. Please share if any ideas on it
Regards,
Rafi
Hi All,
I have made code changes and set ev_value = '' now Workflow is going for manual approval.
Thanks for all your help.
Regards,
Rafi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rafi,
Are you using Process Controled Workflow?
If yes, the standard system behavior is to restart workflow for any single change.
You have to look in your Schema Determination EVENT if it's calling an automatic approval event on document changes.
Also you can look on BAdI /SAPSRM/BD_WF_PROCESS_RESTART to the document changes that occur when the document is still in approving status
Regards,
Daniel Demetrio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
Thanks for your reply.
It is a Process Controlled Workflow and I could see an event an auto approval.
As per the Function Module for the Expression could see below parameters
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IT_EXPRESSIONS) TYPE SBRF260A_T
*" REFERENCE(IO_EVENT) TYPE REF TO IF_EVENT_BRF
*" REFERENCE(IO_EXPRESSION) TYPE REF TO IF_EXPRESSION_BRF
*" EXPORTING
*" REFERENCE(EV_VALUE) TYPE BRF_RESULT_VALUE
*" REFERENCE(EV_TYPE) TYPE BRF_RESULT_TYPE
*" REFERENCE(EV_LENGTH) TYPE BRF_RESULT_LENGTH
*" REFERENCE(EV_CURRENCY) TYPE BRF_CURRENCY
*" REFERENCE(EV_OUTPUT_LENGTH) TYPE BRF_RESULT_OUTPUT_LENGTH
*" REFERENCE(EV_DECIMALS) TYPE BRF_RESULT_DECIMALS
*" REFERENCE(EV_DATA_MISSING) TYPE BRF_DATA_MISSING
In the code EV_VALUE is set to 1.
Below is the code in the Function Module.
DATA: lo_wf_brf_event TYPE REF TO /sapsrm/cl_wf_brf_event,
lo_context_provider TYPE REF TO /sapsrm/cl_wf_context_provider,
lv_document_guid TYPE /sapsrm/wf_document_guid,
lv_document_type TYPE /sapsrm/wf_document_type,
lo_pdo_sc TYPE REF TO /sapsrm/if_pdo_bo_ctr,
wa_header TYPE bbp_pds_po_header_d,
it_version TYPE STANDARD TABLE OF bbp_pds_version_list_internal,
wa_version TYPE bbp_pds_version_list_internal,
it_status TYPE STANDARD TABLE OF bbp_pds_status,
wa_status TYPE bbp_pds_status,
it_account TYPE TABLE OF bbp_pds_acc,
wa_account TYPE bbp_pds_acc,
it_item TYPE TABLE OF bbp_pds_po_item_d,
wa_item TYPE bbp_pds_po_item_d,
ls_tvarvc TYPE tvarvc,
wa_total_value TYPE bbp_total_value,
wa_agr_users TYPE agr_users.
ev_value = io_expression->ms_brf150-expression.
ev_type = 'C'. ev_length = 30. CLEAR ev_currency.
ev_output_length = 30. ev_decimals = 0. CLEAR ev_data_missing.
ev_type = 'B'.
*=======================================================================
* Get contract document
*=======================================================================
* get event object
lo_wf_brf_event ?= io_event.
* get context container from BRF event
lo_context_provider = lo_wf_brf_event->get_context_provider( ).
CALL METHOD lo_context_provider->get_document
IMPORTING
ev_document_guid = lv_document_guid
ev_document_type = lv_document_type.
CLEAR: ev_value.
CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
EXPORTING
i_guid = lv_document_guid
IMPORTING
e_header = wa_header
TABLES
e_item = it_item
e_account = it_account
e_version = it_version
e_status = it_status.
sort it_item by DEL_IND.
delete it_item where del_ind = 'X'.
* Since the current total value is not being reflected
CLEAR wa_header-total_value.
LOOP AT it_item INTO wa_item.
wa_header-total_value = wa_header-total_value + ( wa_item-quantity * wa_item-price ).
ENDLOOP.
*For - Auto Apprvl during change
READ TABLE it_version INTO wa_version WITH KEY version_type = 'C'.
IF sy-subrc = 0.
IF wa_header-process_type EQ 'ZA' OR wa_header-process_type EQ 'ZB' OR wa_header-process_type EQ 'ZC' OR wa_header-process_type EQ 'ZD' OR
wa_header-process_type EQ 'ZE' OR wa_header-process_type EQ 'ZF' OR wa_header-process_type EQ 'ZG' OR wa_header-process_type EQ 'ZH' OR
wa_header-process_type EQ 'ZJ' OR wa_header-process_type EQ 'ZK' OR wa_header-process_type EQ 'ZL' OR wa_header-process_type EQ 'ZM'.
READ TABLE it_version INTO wa_version WITH KEY version_type = space.
IF sy-subrc = 0.
SELECT SINGLE total_value FROM bbp_pdhgp INTO wa_total_value WHERE guid = wa_version-guid.
IF sy-subrc = 0 AND wa_total_value >= wa_header-total_value.
ev_value = '1'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CASE wa_header-process_type.
WHEN 'ZC'.
ev_value = '1'.
WHEN 'ZB'.
IF wa_header-total_value IS INITIAL.
LOOP AT it_item INTO wa_item.
wa_header-total_value = wa_header-total_value + ( wa_item-quantity * wa_item-price ).
ENDLOOP.
ENDIF.
* SELECT SINGLE * INTO wa_agr_users FROM agr_users WHERE agr_name = 'Z:PPS_REQUISITIONING'
* AND uname = wa_header-created_by.
* IF sy-subrc = 0 AND wa_header-total_value <= 100000.
* READ TABLE it_item INTO wa_item WITH KEY ctr_hdr_number = space.
* IF sy-subrc NE 0.
* ev_value = '1'.
* ENDIF.
* ENDIF.
SELECT SINGLE * INTO wa_agr_users FROM agr_users WHERE agr_name IN ('Z:PPS_BUYER1','Z:PPS_BUYER2')
AND uname = wa_header-created_by.
IF sy-subrc = 0 AND wa_header-total_value <= 100000.
ev_value = '1'.
ELSEIF sy-subrc ne 0 AND wa_header-total_value <= 100000.
READ TABLE it_item INTO wa_item WITH KEY ctr_hdr_number = space.
IF sy-subrc NE 0.
ev_value = '1'.
ENDIF.
ENDIF.
ENDCASE.
* To be deleted
SELECT SINGLE * FROM tvarvc INTO ls_tvarvc WHERE name = 'ZAUTO_APPROVAL' AND
low = wa_header-created_by.
IF sy-subrc = 0.
ev_value = '1'.
ENDIF.
I debugged this code for PO Change at ITEM LEVEL and it is triggered and value of EV_VALUE is set to 1.
Please suggest if EV_VALUE is set 1 then it is Auto Approval. How do I know about it? and Where to check Auto Approval Process.
Regards,
Rafi
Hi Daniel,
In the Process Level Configuration I could see below
I hope this is the place of Configuration Made.
For the first time 'Approval' happens Manually, second time when changes Auto Approval is happening so to make even second step as Manual Approval Process do I need to make changes in the Function Module?
Regards,
Rafi
Hi Rafi
Using the Eval.ID the system determines whether the Approval level is valid for a given PO or not.
For Eval ID ZSPO_EVN_AUTO, it will go to your FM and evaluate to Auto Approve.
You need to check the Eval.IDs higher up...ZSPO_EVN_HRPSC... ZSPO_EVN_BUYER.... and see which Event/Expression/FM is attached to them and check the coding there. to see if changes can be done to make that level 'True' for your PO Change Cases.
Regards,
Modak
Hi Rafi,
First of all you need to guarantee that this ZSPOBUS2201 was chosen. For that please look at Process Schema Evaluation.
There you will see the event that selects the Process Level Configuration you showed in this image. This event/expression/FM in Process Schema Evaluation that matters for now.
You can also look in transaction code SLG1 what's happening in log. Selected schema and all steps for manual or automatic approval.
After all, if you guaranteed that this schema is the selected one by previous event, you have to look on higher levels of approvals as Modak previously said. Maybe ZSPO_EVN_HRPSC, ZSPO_EVN_BUYER and the others are returning false.
Regards,
Daniel
Hi Rafi
Are you using Process Controlled Workflows ? Seems that your PO Change is set for Automatic Approval in BRF Rules (if you are using Process Controlled Workflows).
This link can give you ideas around that:
http://scn.sap.com/thread/1727671
Regards,
Modak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.