cancel
Showing results for 
Search instead for 
Did you mean: 

Shopping cart - 1 step approval issue in badi

Former Member
0 Kudos

Hello experts,

I am newbie in SRM BRF and have been trying to create 1 step approval for shopping cart using customized classes and BADI.

I want to implement product category based approval. The company assigns purchasers as category managers. When a hopping cart is created an item level approval should be implemented where a shopping cart item is sent to the category manger for approval. There is no issue at configuration part as autp approval is working fine for the customized class. I will explain what I have done so far.

I am using BADI definition /SAPSRM/BD_WF_RESP_RESOLVER. I have defined Badi agent. created subclass of standard class /SAPSRM/CL_WF_AREA_PURCH_GRP which is z02_cl_wf_area_catman_purch and using method get_responsible_approvers where i have written select query using customized z table.

I am struggling in method get_area_to_item_map where I am not able to figure it out what code/logic should be implemented and how data should be declred?

as per my knowledge I should write following code.

loop at it_item_to_cat_map REFERENCE INTO lr_item_to_cat_map.

    at NEW category_id.
      lo_area = /sapsrm/cl_wf_area=>/sapsrm/if_wf_area~create_instance(
*    iv_area_type = /sapsrm/if_wf_process_c=>GC_AREA_TYPE_CATMAN
      iv_area_type = 'Z01_CL_WF_AREA_CATMAN'
      iv_leading_object_id = lr_item_to_cat_map->category_id ).

      ls_area_to_item_map-area_guid = lo_are->get_guid( ).
      endat.

      ls_area_to_item_map-item_guid = lr_item_to_cat_map->item_guid.
      APPEND ls_area_to_item_map to rt_item_to_area_map.
     endloop.

what should be declared in the DATA and at Create responsibility area ?

Please guide us with a sample code if it is available. Please suggest and advise.

Thank you.

best regards.

Edited by: abhijitkamatkar on Dec 8, 2011 7:35 AM

Edited by: abhijitkamatkar on Dec 8, 2011 7:42 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Check the decision type at process schema.

Answers (3)

Answers (3)

Former Member
0 Kudos

I need to know the flow of get_item_map. I am still not cleared how GET_APPROVERS_BY_AREA_GUID, GET_AREA_TO_ITEM_MAP and GET_RESPONSIBLE_APPROVERS methods are inter linked ? How the references are passed from one method to another ? Is it mandatory to use lo_area ?Please advise. I am not very clear about the flow of these methods.

Edited by: abhijitkamatkar on Dec 19, 2011 3:00 PM

Former Member
0 Kudos

Hi,

When system calls "Agents" Badi, the first method will call GET_AREA_TO_ITEM_MAP where you will map the area guid with item guid then system calls GET_APPROVERS_BY_AREA_GUID where you call the GET_RESPONSIBLE_APPROVERS to get the approver based on leading_object.. GET_AREA_TO_ITEM_MAP will basically pass the leading_object..

Former Member
0 Kudos

Thank you Sarvanan ! I am creating a shopping cart basedon category Id. I have myown z table where I am keeping all the records of the category id, company code and approver. is it mandatory to use every standard method or is it possible to call get_responsible_aprovers from get_area_to_item_map itself where from we get leading_object_id ? Also according to my observations, from get_area_to_item_map following code create instance (object)

lo_area = /sapsrm/cl_wf_area=>/sapsrm/if_wf_area~create_instance(
        iv_area_type         = 'ZCL_WF_AREA_PURCH_GRP_1'
        iv_leading_object_id = lr_item_cat_map->category
        ).
      ls_area_to_item_map-area_guid = lo_area->get_guid( ).

and from get_approvers_by_area_guid we get that object using following code.

lo_area = /sapsrm/cl_wf_area=>/sapsrm/if_wf_area~get_instance_by_guid(
    iv_area_type = 'ZCL_WF_AREA_PURCH_GRP_1'                              "LO_AREA_TYPE_CATMAN
    iv_area_guid = is_area-area_guid
    ).

is this correct ? if so, using

iv_area_type = 'ZCL_WF_AREA_PURCH_GRP_1'

we pass the reference (or link) get_responsible_approvers which exists in 'ZCL_WF_AREA_PURCH_GRP_1'. Is this correct ? Please advise. I want to implement multistep approval once i crack this code.

Thank you again for your help.

Best regards.

Former Member
0 Kudos

Hi,

You dont to create class to call method 'get_responsible_approvers' in get_approvers_by_area_guid..

with in get_approvers_by_area_guid method itself you can call the method get_leading_object_id to get the leading_object from object lo_area..

lv_leading_object_id TYPE /sapsrm/wf_leading_object_id.

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

iv_area_type = /sapsrm/if_wf_process_c=>gc_area_type_employee

iv_area_guid = is_area-area_guid

).

lv_leading_object_id = lo_area->get_leading_object_id( ).

Now lv_leading_object_id will hold the value..

Saravanan

Former Member
0 Kudos

Hi sarvanan thank you for your reply.

but in my GET_RESPONSIBLE_APPROVERS i am writing my select query. I am creating a shoppping cart based on category id. following is code for GET_RESPONSIBLE_APPROVERS.

Edited by: abhijitkamatkar on Dec 23, 2011 1:42 PM

Former Member
0 Kudos

In my item map i have following code. Now i am confused at where clause. Exactly where I should change the code if i want to see different mangers for different category ids ? Right now in my item list i can see only one approver even though I add more than one category id that has different approvers. Please advise. Thank you.

In my portal if I try to add 2 items, it fails and shows the approver of the recently entered item. Would anypne help on this ? Please suggest.

Best regards.

Edited by: abhijitkamatkar on Dec 23, 2011 7:07 AM

Former Member
0 Kudos

Hello Sarvanan,

Issue is resolved. The problem was at process schema decision type.

Thank you very much for your inputs.

Best regards.

Former Member
0 Kudos

Hi,

Please refer a standard Badi '/SAPSRM/BD_WF_AGENTS_SC in SE19.. SAP has delivered Badi which will give you more details..

Saravanan

Former Member
0 Kudos

Hello Sarvanan, Sam

Thank you for your reply.

I marked it as helpful. Sarvanan I was using the same BADI. Issue was resolved when changes were made in method GET_AREA_TO_ITEM_MAP.

Even though issue has been resolved I do not know why we call few methods why.

If you could help me on it then that would be a great help.

I want to know exact working principle of few call methods from GET_AREA_TO_ITEM_MAP. for e.g.

I want to know details of it_parent_guid = lt_header_guid and mechanism of it_parent_guid = lt_header_guid. Would you please guide me on that? I tried to debug my badi by setting external break point. I could not get correct idea about how this item id and header gets the details of process scehma value. Please advice. Thank you in advance.

Best regards.

Edited by: abhijitkamatkar on Dec 23, 2011 1:43 PM

Former Member
0 Kudos

Hi,

Creating a expression of type formula interpreter and use the value 0V_SC_MTERILGROUP for your requirement to trigger the workflow?

Regards

Sam