on 01-26-2011 6:52 PM
Hi all,
SRM 5.0 Sp13,ECS
We need to implemengt the Item level appr WF 14500015 for SHC based on the Cost centre in the SHC line items .
I am trying to test the WF in DEV system .I copied the std implementationm code in a custom implem,entation "SAP_LIA_BADI_EX_SIMP" and actiavted the same.Also enabled the event linkage for the same WF.
The WF gets triggered and the approval table is populated correctly in the BADI with the detaisl for the approvers from table bbpt_wfl_lia_def.
Now the issue:
In the Approval preview,when I clcik on the link "ITEM APROVAL",the approver names are not displayed.Under the column "TO BE APPROVED BY",I see the text "No approvers".
In BBP_PD,under the work item ID,I see the foll:
Node ID Agent User State Workitem
0040000000 Approver on item level X No Work Item Found
0040000002 No Work Item Found
There are 4 approvers(2 for each line in SC with 2 line items) populated in the badi...Suprisingly when I see the inbox of the approvers,I can see the work item in the approvers inbox.
The BADI code :
METHOD if_ex_bbp_wfl_approv_badi~get_remaing_approvers.
* This a default implementation that gives idea about of how line item
* approval should work
*{ INSERT LSRK001669 2
*
INCLUDE <swfcntn01>. "Workflow
* purchase order special...
DATA:
lt_approval_agent_obj TYPE TABLE OF swf_bor_object,
lt_approval_init_agents TYPE TABLE OF bbp_wfl_approval_table,
ls_wa_agent_obj TYPE swf_bor_object,
ls_approval_agent TYPE bbp_wfl_approval_table,
ls_wa_approval_init_agents TYPE bbp_wfl_approval_table,
ls_wa_approval_history TYPE bbps_wfl_history_line_badi,
lv_index TYPE syindex,
lv_usr01_name TYPE ad_namtext,
lo_new_instance TYPE swf_bor_object,
lo_user TYPE swf_bor_object.
*
*} INSERT
DATA:
ls_header TYPE bbp_pds_sc_header_d,
* tables for different approval criteria
lv_call_crit1 TYPE bbp_wfl_app_criterion,
lv_call_value1 TYPE bbp_wfl_app_property,
* local help variables
lv_guid TYPE crmt_object_guid,
* item fields and structures
ls_item TYPE bbp_pds_sc_item_d,
lt_item TYPE TABLE OF bbp_pds_sc_item_d,
* accounting structures
ls_account TYPE bbp_pds_acc,
lt_account TYPE TABLE OF bbp_pds_acc.
DATA: ls_approver TYPE bbp_wfl_approval_table_badi.
* Business objects (local)
CONSTANTS:
c_po TYPE crmt_subobject_category_db VALUE 'BUS2201',
c_shop TYPE crmt_subobject_category_db VALUE 'BUS2121',
c_contract TYPE crmt_subobject_category_db VALUE 'BUS2000113'.
*{ INSERT LSRK001669 1
*
*** workflow approval states
CONSTANTS:
c_wf_approved TYPE bbp_wfl_approvalstate VALUE '0',
c_wf_rejected TYPE bbp_wfl_approvalstate VALUE '1',
c_wf_not_instanced TYPE bbp_wfl_approvalstate VALUE '2',
c_wf_changed TYPE bbp_wfl_approvalstate VALUE '3',
c_wf_partialapproved TYPE bbp_wfl_approvalstate VALUE '4',
c_wf_step_in_process TYPE bbp_wfl_approvalstate VALUE '5'.
*} INSERT
.
* Approval Criteria and properties used (local)
CONSTANTS:
c_cost_centre TYPE bbp_wfl_app_criterion VALUE 'COST_CTR',
c_prod_categ TYPE bbp_wfl_app_criterion VALUE 'PROD_CAT'.
CASE object_type.
WHEN c_shop.
* ----------- shopping cart ---------------------------------- *
*** get the details of the shopping cart
CALL FUNCTION 'BBP_PD_SC_GETDETAIL'
EXPORTING
i_object_id = object_id
* I_WITH_ITEMDATA = 'X'
IMPORTING
e_header = ls_header
* EV_IS_PD =
* ET_ATTACH =
TABLES
e_item = lt_item
e_account = lt_account
* E_PARTNER =
* E_ORGDATA =
* E_TAX =
* E_PRIDOC =
.
* 1st approval step executed for indices 1 and 0
IF actual_approval_index LE 1.
*********************** First approval step (cost center based)
LOOP AT lt_item INTO ls_item WHERE del_ind IS INITIAL.
*** We consider only items, which are not deleted (del_ind = 'X')
*** Found out to which cost center this item belongs
READ TABLE lt_account INTO ls_account
WITH KEY p_guid = ls_item-guid.
IF sy-subrc = 4.
MOVE 'OTHERS' TO lv_call_value1.
ELSE.
MOVE ls_account-cost_ctr TO lv_call_value1.
ENDIF.
*** Call your own customers function to found the approver of this item
*** based on your own customizing table/RFC.
*** The function BBP_WFL_DIN_ITEM_APPROVAL_GET is only an example
*** for implementing this.
CALL FUNCTION 'BBP_WFL_DIN_ITEM_APPROVAL_GET'
EXPORTING
sc_guid = ls_header-guid
item_guid = ls_item-guid
approval_index = '1'
approval_description = 'Cost center approval'
*** each cost center approver should see only items he is responsible
hide_items_not_responsible = 'X'
criterion1 = c_cost_centre
value1 = lv_call_value1
* CRITERION2 = ''
* CRITERION3 = ''
* VALUE2 = ''
* VALUE3 = ''
CHANGING
approval_table = approval_table
item_approval_table = item_approval_table
item_approval_obj = item_approval_obj
.
ENDLOOP.
ENDIF.
**** 2. approval step executed for indices 2,1 and 0
IF actual_approval_index LE 2.
IF ls_header-total_value GE 510000000.
LOOP AT lt_item INTO ls_item WHERE del_ind IS INITIAL.
*** We consider only items, which are not deleted (del_ind = 'X')
*** Set the product category
MOVE ls_item-category_id TO lv_call_value1.
*** Call your own customers function to found the approver of this item
*** based on your own customizing table/RFC.
*** The function BBP_WFL_DIN_ITEM_APPROVAL_GET is only an example
*** for implementing this.
CALL FUNCTION 'BBP_WFL_DIN_ITEM_APPROVAL_GET'
EXPORTING
sc_guid = ls_header-guid
item_guid = ls_item-guid
approval_index = '2'
approval_description = 'Product approval'
*** each product category approver should see all items
hide_items_not_responsible = ''
criterion1 = c_prod_categ
value1 = lv_call_value1
* CRITERION2 = ''
* CRITERION3 = ''
* VALUE2 = ''
* VALUE3 = ''
CHANGING
approval_table = approval_table
item_approval_table = item_approval_table
item_approval_obj = item_approval_obj
.
ENDLOOP.
ELSEIF actual_approval_index EQ 2.
*** don't process 2nd step if shopping cart value is less than 510000000
no_further_approval_needed = 'X'.
ENDIF. " value more than 510000000
ENDIF.
* now fill the approval_table
IF actual_approval_index GE 3.
* this BADI-implementation defines 2 steps
no_further_approval_needed = 'X'.
ELSE.
IF approval_table[] IS INITIAL.
* if no approver found because send sc to default administrator
ls_approver-approval_index = actual_approval_index.
*** the agent is 'US' + user
ls_approver-approval_agent = 'USADMNIN1'.
ls_approver-name = 'Peter Admin'.
APPEND ls_approver TO approval_administrators.
ENDIF.
ENDIF.
*{ INSERT LSRK001669 3
WHEN c_po.
*** 1) Evaluate the list of spending limit approvers from BOR attributes
swf_create_object lo_new_instance object_type guid.
swf_get_property lo_new_instance 'SLManagerUserList'
lt_approval_agent_obj[].
lv_index = 1.
LOOP AT lt_approval_agent_obj INTO ls_wa_agent_obj.
swf_get_property ls_wa_agent_obj 'User' lo_user.
swf_get_property lo_user 'NameWithLeadingUS'
ls_approval_agent-approval_agent.
swf_get_property lo_user 'Name' lv_usr01_name.
MOVE lv_usr01_name TO ls_approval_agent-name.
ls_approval_agent-approval_index = lv_index.
ls_approval_agent-approval_branch = 1.
ls_approval_agent-initial_index = lv_index.
ls_approval_agent-initial_agent =
ls_approval_agent-approval_agent.
ls_approval_agent-approval_state = c_wf_not_instanced.
APPEND ls_approval_agent TO lt_approval_init_agents.
lv_index = lv_index + 1.
ENDLOOP.
*** 2) Evaluate the list of remaining approvers. The actual approver
*** belongs to the list as well.
LOOP AT approval_history_table INTO
ls_wa_approval_history WHERE type <> 'I'.
LOOP AT lt_approval_init_agents INTO
ls_wa_approval_init_agents.
IF ls_wa_approval_init_agents-approval_index LT
ls_wa_approval_history-approval_index.
DELETE lt_approval_init_agents.
ENDIF.
ENDLOOP.
ENDLOOP.
* fill the import table
CLEAR ls_wa_approval_init_agents.
LOOP AT lt_approval_init_agents INTO
ls_wa_approval_init_agents.
CLEAR ls_wa_approval_history.
MOVE-CORRESPONDING ls_wa_approval_init_agents TO
ls_wa_approval_history.
APPEND ls_wa_approval_history TO approval_table.
ENDLOOP.
IF approval_table[] IS INITIAL.
no_further_approval_needed = 'X'.
ENDIF.
WHEN c_contract.
*** 1) Evaluate the list of spending limit approvers from BOR attributes
swf_create_object lo_new_instance object_type guid.
swf_get_property lo_new_instance 'SLManagerUserList'
lt_approval_agent_obj[].
lv_index = 1.
LOOP AT lt_approval_agent_obj INTO ls_wa_agent_obj.
swf_get_property ls_wa_agent_obj 'User' lo_user.
swf_get_property lo_user 'NameWithLeadingUS'
ls_approval_agent-approval_agent.
swf_get_property lo_user 'Name' lv_usr01_name.
MOVE lv_usr01_name TO ls_approval_agent-name.
ls_approval_agent-approval_index = lv_index.
ls_approval_agent-approval_branch = 1.
ls_approval_agent-initial_index = lv_index.
ls_approval_agent-initial_agent =
ls_approval_agent-approval_agent.
ls_approval_agent-approval_state = c_wf_not_instanced.
APPEND ls_approval_agent TO lt_approval_init_agents.
lv_index = lv_index + 1.
ENDLOOP.
*** 2) Evaluate the list of remaining approvers. The actual approver
*** belongs to the list as well.
LOOP AT approval_history_table INTO
ls_wa_approval_history WHERE type <> 'I'.
LOOP AT lt_approval_init_agents INTO
ls_wa_approval_init_agents.
IF ls_wa_approval_init_agents-approval_index LT
ls_wa_approval_history-approval_index.
DELETE lt_approval_init_agents.
ENDIF.
ENDLOOP.
ENDLOOP.
* fill the import table
CLEAR ls_wa_approval_init_agents.
LOOP AT lt_approval_init_agents INTO
ls_wa_approval_init_agents.
CLEAR ls_wa_approval_history.
MOVE-CORRESPONDING ls_wa_approval_init_agents TO
ls_wa_approval_history.
APPEND ls_wa_approval_history TO approval_table.
ENDLOOP.
IF approval_table[] IS INITIAL.
no_further_approval_needed = 'X'.
ENDIF.
*
*} INSERT
ENDCASE.
ENDMETHOD.
I am not sure what the problem is....Please help....
Edited by: NMSRM1000 on Jan 26, 2011 7:53 PM
opened a new thread..
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.