cancel
Showing results for 
Search instead for 
Did you mean: 

Shopping Cart - Different line item type and correct BRF Expression

Former Member
0 Kudos

Hi Experts,

We are in SRM 7.04 and we have developed a 2 level process controlled workflow using BRF expression. We are using decision type 2.

Requirement:

1. If line item is of type catalog only Finance approver will process the shopping cart. (In this case it will be one level approval)

2. If line item is of type non catalog, there will be 2 levels.

    a. Buyer completion step (level 1)

    b. Finance Approval step (level 2)

I have created corresponding events and expression for the same. It works fine if there is only one type of items have been ordered. It means if end user orders 2 items of type catalog, it will show 2 levels with respective finance approvers only. If end user orders 2 items of type non catalog, it will show 2 levels with repective buyers and finance approvers for corresponding items.

However, if an end user creates a shopping cart using both catalog and non catalog items, it still shows both buyer and approver for both items items. At first. I would like to know whether this is possible in Process controlled workflow/BRF to order 2 different type of items in the same shopping cart ?

here is what I have done. I have created a function module expression of result type char and under the FM, i am checking EV_VALUE. I am calling FM BBP_PD_SC_GETDETAIL and getting items. i am checking each item where item type is catalog or not and based on that i am returning ev_value.

CALL FUNCTION 'BBP_PD_SC_GETDETAIL'

    EXPORTING

      I_GUID          = LV_DOCUMENT_GUID

      I_WITH_ITEMDATA = 'X'

    IMPORTING

      E_HEADER        = LWA_HEADER

    TABLES

      E_ITEM          = LI_ITEM

      E_ACCOUNT       = LI_ACCOUNT.

CLEAR LWA_ITEM.

  EV_VALUE = ' '.

LOOP AT LI_ITEM INTO LWA_ITEM." WHERE CATALOGID EQ ' '.

    IF LWA_ITEM-CATALOGID EQ ' '.

      EV_VALUE = ABAP_TRUE.

      EXIT.

    ENDIF.

    CLEAR EV_DATA_MISSING.

  ENDLOOP.

I know my problem. When there are all non catalog items this code will work and it will show correct levels for these items. When there are catalog items this code will work and it will only show one level approval for the ordered items. However it fails when both type of items are ordered in the same cart. I would like to know what should I do if one can order different type of items in a single cart ?

Awaiting for your reply. Thank you.

Best regards.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Experts,

Any inputs for the solution ?

Thank you.

laurent_burtaire
Active Contributor
0 Kudos

Hello,

what are your BRF expressions linked to the Evaluation ID for your Buyer process level and for your Financial process level?

Check also blogs below:

Custom Workflow - Developer view - Part 1 - Idea and preparation

Custom Workflow - Developer view - Part 2 - Process Schema and Implementation

Regards.

Laurent.

Former Member
0 Kudos

Hi Laurent,

Thank you very much for replying. Your replies have been always useful for us.

I have already gone through the above mentioned blogs. However, I have issue only when there are 2 types of items are ordered in the same cart. I also want to know whether it is technically feasible or not to order different types of items in the same cart and attach expression accordingly.

Now, I have created a Function module expression for these 2 evaluation IDs.

1. When items are of non catalog type - I have crated an expression of result type C and under formula I have written - IF( ZC_SC_CHECKNONCATLOG, 'X', ' ' ). This is to check that  line items do not have catalog items. In my question's post, I have posted the snippet of the code that decides return value of EV_VALUE. This expression works fine when there are only non catalogs items are ordered and it shows both levels (buyer and approver as per requirement) correctly.

2. When items are from catalog type - I have created an expression of result type C and under formula I have written - IF( ZC_SC_NONLIMITAPPR, 'X', ' ' ). This is to check that line item does have catalog items or not. This expression works fine when there are only catalogs items are ordered and it displays only approver as per the requirement correctly.

I will explain with an example.

I order 2 items. 1. Non catalog 2. Catalog

Now in the FM BBP_PD_SC_GETDETAIL i will get all items and for the first line item my EV_VALUE = 'X' after I exit. Later for another iteration, it will repeat the same code and again EV_VALUE will be 'X'. It will result in displaying both approvers for both items.

I also created a custom Z table and tried to update it once that item is processed. But this expression is checked 3 times (using external debugger) and at the 3rd time it actually decides the EV_VALUE's result.

Now what should have been done when there are both types of items (non catalog and catalog) are ordered. As per my understanding by any means, if I come to know which item is currently being processed by user in the function module expression itself, I may be able to consider only that item and try to set my expression. Is my approach correct ?

Appreciate your help.

Thank you.

laurent_burtaire
Active Contributor
0 Kudos

Hello,

your problem is not only to know if there is a catalog item and a non catalog item.

You have to check each item for your first process level.

Item 1 > catalog item

Item 2 > non catalog item

Item 3 > catalog item

First approval level is Buyer (non-catalog item), so area_guid A (approvers to determine) for item 2 and area_guid null (no approvers to determine) for items 1 and 3.

Second process level is Financial (catalog item and non-catalog item), so area_guid B (approvers to determine) for items 1, 2 and 3.


Regards.



Laurent.

Former Member
0 Kudos

Hi Laurent,

I agree with you and I had already done that earlier. However, I was able to see a 2 levels even though only one work area guid was getting created. Here is what I had done.

READ TABLE LI_ITEM INTO LWA_ITEM WITH KEY GUID = LR_ITEM_TO_CCTR_MAP->ITEM_GUID CATALOGID = ' '.

      IF SY-SUBRC = 0.

        LO_AREA = /SAPSRM/CL_WF_AREA=>/SAPSRM/IF_WF_AREA~CREATE_INSTANCE(

          IV_AREA_TYPE         = LC_RESPONSIBLECLASSBUYER

          IV_LEADING_OBJECT_ID = LR_ITEM_TO_CCTR_MAP->ACCOUNT_CATEGORY

          ).

        LS_AREA_TO_ITEM_MAP-AREA_GUID = LO_AREA->GET_GUID( ).

      ELSE.

        LS_AREA_TO_ITEM_MAP-AREA_GUID = /SAPSRM/IF_WF_PROCESS_C=>GC_NIL_GUID.

      ENDIF.

If I understand correctly, class part will be executed later after the expression. In my case, expression is not correct when there are different type of item type as EV_VALUE will be always X in the loop.

Kindly correct me if I am mistaking anywhere.

Thank you.

Former Member
0 Kudos

Hi Laurent,

I think if I manage to bring only currently processed item's guid in the Function Module expression my issue will be resolved. I mean right now I am getting list of item guids. Instead if I get only item guid that is currently processed by end user, I would be able to keep additional check.

Any idea how to bring existing item guid in Function module expression ?

Thank you.

laurent_burtaire
Active Contributor
0 Kudos

Hello,

do not understand your code: what do you use account category ???

Just check any /SAPSRM/IF_EX_WF_RESP_RESOLVER~GET_AREA_TO_ITEM_MAP method from/SAPSRM/BD_WF_RESP_RESOLVER BAdI implementation for SC (enhancement implementation in /SAPSRM/BD_WF_AGENTS enhancement spot).

This will give you clear responsability area assignment (area_guid) based on leading object.

In your case, leading object is CATALOGID or CATALOGITEM field from SC item.

Regards.

Laurent.

Former Member
0 Kudos

Hi Laurent,

Thank you for replying.

I will go with you for catalog id part. However, my main problem is in the expression. Even if I manage to create area guid based on catalog id (based on your previous reply) how should go with expression ? In the BRF expression, I have function module expression, where in I have to call BBP_PD_SC_GETDETAIL and loop through LI_ITEM table.

My issue is coming in expression only. What approach should I follow while determining EV_VALUE for buyer level ? I have asked one query before your latest reply. By any chance can we bring only currently processed item's guid in the Function Module expression rather than having all items' guid from BBP_PD_SC_GETDETAIL ?


We would really appreciate your reply.

Thank you.

laurent_burtaire
Active Contributor
0 Kudos

Hello,

which expression are you talking about?

The one to trigger process level?

Process steps in Process-Controlled Workflow are below:

1) Process schema evaluation (BRF configuration) to get correct process schema.

2) Process level evaluation (BRF configuration) from the process schema triggered: once your expression is true for Buyer process level (that is at least one item is non-catalog item), process level is triggered.

3) Next step is to determine, using Responsability Resolver Name:

a- Area of responsibilities for document items (based on CATALOGID in your case: leading object),

b- Agents working in the responsibility area

4) Finally, determine responsible approvers using /SAPSRM/CL_WF_AREA sub-class.

According to your first post, process level Buyer (first level) is correctly triggered: if at least one item is non-catalog item, process level is active which is correct.

Your problem is first level triggered is assigned to ALL items, whatever the value for CATALOGID field: this is not correct.

So your problem comes from point 3a, not from BRF expression.

Regards.

Laurent.

Former Member
0 Kudos

Hi Laurent,

Thanks for replying. We have amended our code and now even though there are different guid assigned based on catalog and non catalog, we are getting issue. We are still able to see both levels. Now area guid is not being assigned to all items. Please find attached screen shot for your reference. I am assigning are guid only if catalogid is blank other wise I am passing GC_NIL_GUID. In my get_responsible _approver method, it picks the area guid if the catalogid is blank.

For buyer, in item_map method of the class I have below code.

LOOP AT LT_ITEM_GUID REFERENCE INTO LR_ITEM_GUID WHERE LEAF = ABAP_TRUE.

    LS_ITEM_TO_CCTR_MAP-ITEM_GUID = LR_ITEM_GUID->GUID.

READ TABLE LI_ITEM INTO LWA_ITEM WITH KEY GUID = LR_ITEM_GUID->GUID.

    IF SY-SUBRC = 0.

      LS_ITEM_TO_CCTR_MAP-CATALOGID = LWA_ITEM-CATALOGID.

    ENDIF.

    APPEND LS_ITEM_TO_CCTR_MAP TO LT_ITEM_TO_CCTR_MAP.

ENDLOOP.

SORT LT_ITEM_TO_CCTR_MAP BY CATALOGID.

  LOOP AT LT_ITEM_TO_CCTR_MAP REFERENCE INTO LR_ITEM_TO_CCTR_MAP.

    AT NEW CATALOGID.

IF LR_ITEM_TO_CCTR_MAP->CATALOGID = ' '.

      LO_AREA = /SAPSRM/CL_WF_AREA=>/SAPSRM/IF_WF_AREA~CREATE_INSTANCE(

        IV_AREA_TYPE         = LC_RESPONSIBLECLASSBUYER

        IV_LEADING_OBJECT_ID = LR_ITEM_TO_CCTR_MAP->CATALOGID

        ).

      LS_AREA_TO_ITEM_MAP-AREA_GUID = LO_AREA->GET_GUID( ).

ELSE.

        LS_AREA_TO_ITEM_MAP-AREA_GUID = /SAPSRM/IF_WF_PROCESS_C=>GC_NIL_GUID.

      ENDIF.

ENDAT.

IF NOT LS_AREA_TO_ITEM_MAP-AREA_GUID EQ /SAPSRM/IF_WF_PROCESS_C=>GC_NIL_GUID.

      LS_AREA_TO_ITEM_MAP-ITEM_GUID = LR_ITEM_TO_CCTR_MAP->ITEM_GUID.

      APPEND LS_AREA_TO_ITEM_MAP TO RT_ITEM_TO_AREA_MAP.

    ENDIF.

  ENDLOOP.

Is anything still wrong in our understanding ?

Thank you.