cancel
Showing results for 
Search instead for 
Did you mean: 

REG : Multiple Approver's determined for each item.

Former Member
0 Kudos

Hi Team,

I am using process controlled workflow, and have Item level approval, but when I add more then one item in the shopping cart, all the approvers from the preceding levels are added to the next levels.

I have used the responsible resolver badi and the methods area to item map and get approvers by area guid.

For each line items, these are called multiple times, adding the approvers to the process levels.
I tried debugging and found that, after the approver determination for the items,again it is entering the badi and the table RT_APPROVER is appended.

May be after the line item is read and the values are fetch we need to stop it from entering the BADI again.

Suppose for item 1, we have 3 levels of approvals, and for each level A, B and C are the approvers.

Similarly for item 2, we have 3 levels of approvals, and for each level D, E and F are the approvers.

When I order the shopping cart.

Following is what I see in the approver overview tab :

Item 1 : Level 1 : A, B, C

            Level 2 : A, B, C

            Level 3 : A, B, C

Item 2 : Level 1 : D, E, F

            Level 2 : D, E, F

            Level 3 : D, E, F


What I want is something like this :


Item 1 : Level 1 : A

            Level 2 : B

            Level 3 : C

Item 2 : Level 1 : D

            Level 2 : E

            Level 3 : F

Following is the code snippet of BADI for one of the levels of approvers.

GET_AREA_TO_ITEM_MAP

DATA ls_item_to_area_map TYPE /sapsrm/s_wf_item_to_area.

     DATA lt_item             TYPE STANDARD TABLE OF bbp_pds_sc_item_d.

     DATA ls_item             TYPE bbp_pds_sc_item_d.

     DATA lv_guid             TYPE /sapsrm/wf_area_guid.

     DATA lo_area             TYPE REF TO /sapsrm/if_wf_area.

     CONSTANTS : c_area_type_techman  TYPE swf_clsnam VALUE 'ZCL_SRM_WF_AREA_TECHMAN'.

* Input checks

     IF is_document IS INITIAL.

       RAISE EXCEPTION TYPE /sapsrm/cx_wf_abort.

     ENDIF.

* Exporting the document guid to the memory id

     EXPORT zs_sc_guid FROM is_document-document_guid TO MEMORY ID 'ZS_SC_GUID'.

* Getting the shopping cart details

     CALL FUNCTION 'BBP_PD_SC_GETDETAIL'

       EXPORTING

         i_guid = is_document-document_guid

       TABLES

         e_item = lt_item.

     IF sy-subrc EQ 0.

       LOOP AT lt_item INTO ls_item.

**     Create responsibility area (Corresponding to the category)

               lo_area /sapsrm/cl_wf_area=>/sapsrm/if_wf_area~create_instance(

                                                                 iv_area_type = c_area_type_techman

                                                                 iv_leading_object_id  = is_current_process_level-level_guid ).

* Get responsibility area GUID ... (w/o item assignment)

                ls_item_to_area_map-area_guid = lo_area->get_guid( ).

         APPEND ls_item_to_area_map TO rt_item_to_area_map.

       ENDLOOP.

     ENDIF.

GET_APPROVES_BY_AREA_GUID

     DATA        lo_area             TYPE            REF TO /sapsrm/if_wf_area.

     CONSTANTS : c_area_type_techman TYPE swf_clsnam VALUE 'ZCL_SRM_WF_AREA_TECHMAN'.

* Input checks

     ASSERT ID /sapsrm/wf_cfg CONDITION ( NOT is_area IS INITIAL ).

     IF is_area IS INITIAL.

       RETURN.

     ENDIF.

* Get responsibility area reference for given area GUID

     lo_area = /sapsrm/cl_wf_area=>/sapsrm/if_wf_area~get_instance_by_guid(

     iv_area_type = c_area_type_techman

     iv_area_guid = is_area-area_guid ).

* Getting the responsible approvers

     rt_approver = lo_area->get_responsible_approvers( ).

Please let me know where I went wrong.

Regards,

Aakash Awasthi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello Aakash,

Better maintain a process level indicator along with your approvers names in your Approver   Table and do modification in you Z-Class.. May help you..

Thanks in Advance.

Regards,

Sankarbabu

Former Member
0 Kudos

Hi Sankar,

I am unable to get how to maintain process level indicator, can you please explain briefly.

Regards,

Aakash Awasthi

Former Member
0 Kudos

Hi Akash,

I am also stuck in similar condition. Were you able to resolve the issue ?

If so kindly share your inputs.

Best regards,

Abhijit.

konstantin_anikeev
Active Contributor
0 Kudos

The Problem can be in your class ZCL_SRM_WF_AREA_TECHMAN, please provide its code

The part, creating area pro item, but with the same criteria is a little bit strage.

Why not to use the standard SAP area class for that?

Have you checked these blog posts for example agent determination?

Former Member
0 Kudos

Hi Konstantin,

I wrote the code of the class ZCL_SRM_WF_AREA_TECHMAN in the method itself, and now the revised code is given as below :

GET_AREA_TO_ITEM_MAP

METHOD /sapsrm/if_ex_wf_resp_resolver~get_area_to_item_map.

      DATA: ls_item_to_area_map TYPE /sapsrm/s_wf_item_to_area,

           lt_item             TYPE STANDARD TABLE OF bbp_pds_sc_item_d,

           ls_item             TYPE bbp_pds_sc_item_d,

           ls_area_appr        TYPE ztsrm_area_appr,

           lo_area             TYPE REF TO /sapsrm/if_wf_area.

      CONSTANTS : c_area_type_techman  TYPE swf_clsnam VALUE 'ZCL_SRM_WF_AREA_TECHMAN'.

* Input checks

     IF is_document IS INITIAL.

       RAISE EXCEPTION TYPE /sapsrm/cx_wf_abort.

     ENDIF.

* Exporting the document guid to the memory id

*    EXPORT zs_sc_guid FROM is_document-document_guid TO MEMORY ID 'ZS_SC_GUID'.

* Getting the shopping cart details

     CALL FUNCTION 'BBP_PD_SC_GETDETAIL'

       EXPORTING

         i_guid = is_document-document_guid

       TABLES

         e_item = lt_item.

     IF sy-subrc EQ 0.

       LOOP AT lt_item INTO ls_item.

**     Create responsibility area (Corresponding to the category)

         lo_area /sapsrm/cl_wf_area=>/sapsrm/if_wf_area~create_instance(

                                                            iv_area_type = c_area_type_techman

                                                            iv_leading_object_id  = is_current_process_level-level_guid ).

* Get responsibility area GUID ... (w/o item assignment)

         ls_item_to_area_map-area_guid = lo_area->get_guid( ).

         ls_item_to_area_map-item_guid = ls_item-guid.

         APPEND ls_item_to_area_map TO rt_item_to_area_map.

         MOVE-CORRESPONDING ls_item_to_area_map TO ls_area_appr.

         INSERT ztsrm_area_appr FROM ls_area_appr.

       ENDLOOP.

     ENDIF.

   ENDMETHOD.


GET_APPROVER_BY_AREA_GUID

METHOD /sapsrm/if_ex_wf_resp_resolver~get_approvers_by_area_guid.

     DATA: lo_area          TYPE            REF TO /sapsrm/if_wf_area,

           ls_area_appr     TYPE ztsrm_area_appr,

           ls_approver      TYPE /sapsrm/s_wf_approver,

           lt_item          TYPE STANDARD TABLE OF bbp_pds_sc_item_d,

           ls_item          TYPE bbp_pds_sc_item_d,

           lv_default_admin TYPE swd_shead-wfi_admin.

*    CONSTANTS :  c_area_type_techman TYPE swf_clsnam VALUE 'ZCL_SRM_WF_AREA_TECHMAN'.

* Input checks

     ASSERT ID /sapsrm/wf_cfg CONDITION ( NOT is_area IS INITIAL ).

     IF is_area IS INITIAL.

       RETURN.

     ENDIF.

     SELECT SINGLE * FROM ztsrm_area_appr

                 INTO ls_area_appr

                 WHERE area_guid = is_area-area_guid.

     IF sy-subrc EQ 0.

       CALL FUNCTION 'BBP_PD_SC_ITEM_GETDETAIL'

         EXPORTING

           i_guid = ls_area_appr-item_guid

         IMPORTING

           e_item = ls_item.

       IF sy-subrc EQ 0.

         CALL FUNCTION 'BBPU_CHECK_USER'

           EXPORTING

             username            = ls_item-zz_resp_buyer

           EXCEPTIONS

             user_does_not_exist = 1.

         IF sy-subrc EQ 0.

           ls_approver-approver_ot = /sapsrm/if_wf_process_c=>gc_otype_user.

           ls_approver-approver_id = ls_item-zz_resp_buyer.

           APPEND ls_approver TO rt_approver.

         ELSE.

           CALL FUNCTION 'SWD_WF_DEFINITION_ADMIN_GET'

             IMPORTING

               default_admin           = lv_default_admin

             EXCEPTIONS

               administrator_not_found = 1.

           IF sy-subrc EQ 0.

             ls_approver-approver_ot = /sapsrm/if_wf_process_c=>gc_otype_user.

             ls_approver-approver_id = lv_default_admin.

             APPEND ls_approver TO rt_approver.

           ENDIF.

         ENDIF.

       ENDIF.

       DELETE ztsrm_area_appr FROM ls_area_appr .

     ENDIF.

ENDMETHOD.


What I am not getting here is If I do not use the zclass, what should I give in IV_AREA_TYPE parameter, now I am giving an empty class which is just a copy of the standard interface /sapsrm/if_wf_area.


Also, I rectified the above issue, by creating a ztable and storing, area_guid, item_guid and approvers, filling it in area_to_item_map and using the same in get_approvers_by_area_guid.

Now, the approvers are not getting clubbed.

I know this is not a correct practice, but I was not getting any alternative.

Please suggest, any alternate solution.

Regards,

AkkI

konstantin_anikeev
Active Contributor
0 Kudos

* Get responsibility area GUID ... (w/o item assignment)

                ls_item_to_area_map-area_guid = lo_area->get_guid( ).

                ls_item_to_area_map-item_guid = ls_item-guid.