on 07-05-2010 12:45 PM
Hi,
We have a client requirement to execute a different set of process levels, if the PO is changed. Is there any way that we can compare the previous version price with the present price ???
Also Is there any condition to check the PO is changed or not???
Thanks
Regards
Sudheer Mullamuri
Continuation of the previous message
IMPORT lt_tot_item TO lt_tot_item FROM MEMORY ID 'ZLV_TOTALVALUE_PO'.
CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
EXPORTING
i_object_id = lv_document_id
i_with_itemdata = 'X'
IMPORTING
e_header = ls_header
TABLES
e_item = lt_item
e_status = lt_status.
READ TABLE lt_status INTO ls_status WITH KEY stat = 'I1043'.
IF sy-subrc EQ 0.
IF lt_item IS NOT INITIAL.
LOOP AT lt_item INTO ls_item WHERE del_ind EQ space.
READ TABLE lt_tot_item INTO ls_tot_item INDEX 1.
IF sy-subrc EQ 0.
lv_totalvalue = ls_tot_item-lv_itm_total.
IF ls_item-ps_value_ru NE lv_totalvalue.
lv_po_value = ls_item-ps_value_ru.
lv_chng_value = lv_totalvalue.
lv_diff_value = lv_chng_value - lv_po_value.
lv_perc_diff = ( lv_diff_value / ls_item-ps_value_ru ) * 100.
lv_perc_diff = ABS( lv_perc_diff ).
lv_diff_value = ABS( lv_diff_value ).
IF ( ( lv_diff_value GE 0 ) AND ( lv_diff_value LE 100 ) ) OR
( lv_perc_diff LE 1 ).
ev_value = space.
ELSE.
ev_value = 'X'.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ELSE.
ev_value = 'X'.
ENDIF.
ENDFUNCTION. """"""""""End of the code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Code example:
FUNCTION z_po_dec_approval.
*"----
""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
*"----
Data Declarations
Class references
DATA lrf_wf_brf_event TYPE REF TO /sapsrm/cl_wf_brf_event.
DATA lrf_context_provider TYPE REF TO /sapsrm/if_wf_context_provider.
DATA lrf_process TYPE REF TO /sapsrm/if_wf_process.
DATA lrf_process_current_level TYPE REF TO /sapsrm/cl_wf_process_level.
DATA lrf_process_next_level TYPE REF TO /sapsrm/cl_wf_process_level.
DATA lrf_decision_set TYPE REF TO /sapsrm/if_wf_decisionset.
Local Variables
DATA l_current_resolver_name TYPE /sapsrm/wf_resp_resolver_name.
DATA l_next_resolver_name TYPE /sapsrm/wf_resp_resolver_name.
DATA l_document_guid TYPE /sapsrm/wf_document_guid.
DATA l_document_type TYPE /sapsrm/wf_document_type. "#EC NEEDED
DATA l_decision TYPE /sapsrm/wf_ds_status.
DATA l_msg TYPE string. "#EC NEEDED
DATA: c_x TYPE char1 VALUE 'X'.
DATA: lt_partner TYPE TABLE OF bbp_pds_partner,
lt_item TYPE TABLE OF bbp_pds_po_item_d,
ls_item TYPE bbp_pds_po_item_d,
ls_partner TYPE bbp_pds_partner.
DATA: lt_status TYPE TABLE OF bbp_pds_status,
ls_status TYPE bbp_pds_status.
DATA: lrf_po_class TYPE REF TO /sapsrm/cl_wf_rule_contxt_po.
DATA: lv_chng_guid TYPE bbp_guid_32.
DATA: lv_po_value TYPE bbp_value,
lv_chng_value TYPE bbp_value.
DATA: lv_diff_value TYPE bbp_value,
lv_perc_diff TYPE bbp_value.
DATA: lt_chng_item TYPE TABLE OF bbp_pds_sc_item_d,
ls_chng_item TYPE bbp_pds_sc_item_d.
DATA: iv_guid TYPE crmd_orderadm_h-guid.
DATA: lv_guid_32 TYPE bbp_guid_32.
DATA: ls_header TYPE bbp_pds_po_header_d.
Local Tables
DATA lt_decision_sets TYPE /sapsrm/t_wf_decisionset.
Local Exception
DATA lrf_exception TYPE REF TO /sapsrm/cx_wf_abort. "#EC NEEDED
DATA: lv_totalvalue TYPE ztotalvalue.
DATA: BEGIN OF ls_tot_item,
guid TYPE bbp_guid,
lv_itm_total TYPE ztotalvalue,
END OF ls_tot_item.
DATA: lt_tot_item LIKE TABLE OF ls_tot_item.
preset return values
ev_type = /sapsrm/if_wf_rule_c=>type_char.
ev_length = 1.
CLEAR ev_currency.
ev_output_length = 1.
ev_decimals = 0.
get event object
IF NOT io_event IS BOUND.
BRF event Object not bound. No further execution possible.
MESSAGE e089(/sapsrm/brf) INTO l_msg.
TRY.
CALL METHOD /sapsrm/cl_wf_brf_ccms=>send_message( ).
CATCH /sapsrm/cx_wf_abort INTO lrf_exception.
ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.
EXIT.
ENDTRY.
ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.
EXIT.
ENDIF.
lrf_wf_brf_event ?= io_event.
lrf_context_provider = lrf_wf_brf_event->get_context_provider( ).
get Content Container from BRF event
IF NOT lrf_context_provider IS BOUND.
BRF Context Container Object not bound. No further execution possible.
MESSAGE e090(/sapsrm/brf) INTO l_msg.
TRY.
CALL METHOD /sapsrm/cl_wf_brf_ccms=>send_message( ).
CATCH /sapsrm/cx_wf_abort INTO lrf_exception.
ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.
EXIT.
ENDTRY.
ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.
EXIT.
ENDIF.
Get the document guid and type
CALL METHOD lrf_context_provider->get_document
IMPORTING
ev_document_guid = l_document_guid
ev_document_type = l_document_type.
DATA lo_wf_pdo TYPE REF TO /sapsrm/if_wf_pdo.
DATA lx_pdo_ex TYPE REF TO cx_static_check.
DATA lt_document_responsible TYPE /sapsrm/t_wf_agent_id.
DATA lr_document_responsible TYPE REF TO /sapsrm/wf_agent_id.
DATA lv_document_id TYPE /sapsrm/object_id.
Get shopping cart instance
lo_wf_pdo ?= /sapsrm/cl_wf_pdo_impl_factory=>get_instance(
iv_document_guid = l_document_guid
iv_document_type = l_document_type
).
lv_document_id = lo_wf_pdo->get_document_id( ).
Continued in the next message
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Masa,
Note : the code is broken up into 2 messages as it is not permitting to paste long text
Below is our requirement:
A PO which is in Ordered Status, if there is a change in the value of PO and if the change is more than 100$ a workflow needs to be restarted if not it should go an Automatic aproval.
For this we are following the below procedure:
Event Expression
ZDet_Schema ZSchema_det(FM for detarmining teh schema, in our case it will return ZTEST_PROC_LEVEL schema jus like a constant)
ZTEST_PROC_LEVEL ZGET_APROVER(FM for getting the Approvers)
Process level config
we will have 2 process levels, first level will have the eval id ZTEST_PROC_LEVEL for determing the approvers and second level will be an automatic approval.
Now the problem is while changing an ordered PO and the change is more than 100$ the first process level is getting executed and getting the required approval(our coding is based on the difference in old value and new value) are getting perfectly. But in the same screen if we press on Refresh button the second process level is getting executed and the PO is going to automatic approval even there is change in the value of more than 100$.
I am pasting the code we are trying to acheive the requirement. Do let us know whether we are following the right way or we are missing anything.
Masa I am pasting the expression code in the next message, as it is not allowing me to paste long texts.
Edited by: Krishna Venkat on Jul 23, 2010 2:46 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Masa,
I am also having the same requirement. Request you to eloborate on this how to pass the data to the expression and how to calculate and any other extra information that helps us in acheving the requirement.
Information on this is highly appreciated.
Thanks in Advance.
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please go to SWO1 tarnsaction and check the BUS2201 PO Object Type.
There are attributes:
PurchaseOrderEC.SimpleListOfChanges Formatted List of Changed Fields
PurchaseOrderEC.TechnicalListOfChanges List of Changed Fields
PurchaseOrderEC.POTotalValueDiff Difference Between Current Total Value and Original
PurchaseOrderEC.POTotalValueIncreased Total Value Increased in Comparison with Original
Those attributes can be accessed from BRF expression.
FM Type /SAPSRM/WF_BRF_0EXP000
0C_C1_C_FWFPORLCNTNT Class: /SAPSRM/CL_WF_RULE_CONTXT_PO
0C_C2_C_GET_PROPERTY Method - Get Atrribute Value
0C_C3_C_POTOTLVLUDFF Net Total Amount of Purchase Order
0V_PO_POTOTALVALINCR Purchase Order Total Value Increased (Boolean char1)
0V_PO_POTOTLVLUEDIF Difference Between Current Total Value and Original
Regards,
Masa
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.