Showing results for 
Search instead for 
Did you mean: 

expression to check An item exists from a Catalog entry

Former Member
0 Kudos

Hello experts,

I am looking for an expression to check if an item exists from a Catalog entry in shopping cart.

There is standard expression to check An item exists from a free entry (0V_SC_XSTFRTXTLNTM).

I want to execute similar expression fro catalog. I want to check for catalog.

If an item exists from a Catalog in SC.

Please advise/suggest. Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Experts,

Has anyone worked on the similar condition ?

I want to check if catalog item exists in SC or not. To achieve this I need to write 2 expressions.

     1. one function module expression that returns catalogid which is (mdm catalog 3.0) in our example.

          Therefore I created  Z function module expression.. Copied the FM '/SAPSRM/WF_BRF_0EXP001' into 'Z. I later called  FM 'BBP_PD_SC_GETDETAIL' get the item details and header details.

data line_item type c.

       I_GUID                           = lv_document_guid
*       I_OBJECT_ID                      =
*       I_ATTACH_WITH_DOC                = ' '
*       I_WITH_ITEMDATA                  = 'X'
*       I_WITHOUT_HEADER_TOTALS          =
*       I_READ_FROM_ARCHIVE              = ' '
*       E_HEADER                         = IT_HEADER
*       EV_IS_PD                         =
*       ET_ATTACH                        =
       E_ITEM                           = it_item
*       E_ACCOUNT                        =
*       E_PARTNER                        =
*       E_CONFIRM                        =
*       E_LONGTEXT                       =
*       E_LIMIT                          =
*       E_ORGDATA                        =
*       E_TAX                            =
*       E_PRIDOC                         =
*       E_HCF                            =
*       E_ICF                            =
*       E_MESSAGES                       =
*       E_ACTVAL                         =
*       E_ACC_ACTVAL                     =
*       E_HEADER_REL                     =
*       E_ITMLIM_REL                     =
*       E_STATUS                         =
  loop at it_item INTO wa_item.
    if wa_item-CATALOGID = 'MDM Catalog 3.0'.
      line_item = 'X'.
      line_item = ''.

  if line_item = 'X'.
*    ev_value = 'MDM Catalog 3.0'.
    ev_value = 'X'.
    ev_value = ''.

     2. second one of boolean type with the  condition overall value >=501 AND (catalogid is mdm or not) 

           Overall value >= 501 AND ( an item exists from Catalog = 'X' )

But at portal, I do get systm's auto approval. It should not be the case. Has anyone tried to work on similar condition? Please advise/suggest where i need to change/add any code.

Thank you.

0 Kudos


Abhijit Kamatkar wrote:

I have tried to do so by creating z class of /sapsrm/CL_WF_RULE_CONTEXT. But that is not great idea. If you know please share.

I think it is a good idea to copy such a class, however, copy /SAPSRM/CL_WF_RULE_CONTXT_SC to ZCL_WF_RULE_CONTXT_SC.

In this class define your own public instance method to retrieve the catalogid, make a copy of the existing method /SAPSRM/IF_WF_RULE_CONTXT_SC~CONTAINS_ACCOUNT_ASSIGNMENT for the parameter interface (also you can use some of the contents of that method), call this CONTAINS_CATALOG for example. This method should return a boolean value if the catalogid is available or not (basically the coding you created).

In BRF create 3 new constant expressions:

  1. ZC_C1_C_CONTXT_SC (with description ZCL_WF_RULE_CONTXT_SC) and as constant ZCL_WF_RULE_CONTXT_SC.
  2. ZC_C2_C_CONTAINS_CAT and as constant the method name you defined: CONTAINS_CATALOG
  3. ZC_C4_C_MDM_CAT and as constant your catalogid for MDM

With the above constants build a new expression ZEX_CONTAINS_CAT that looks the same as the standard 0B_SC_ACCTASSCAT_AS.

Finally create a new expression of type 0FB001 (ZEX_CHECK_SC or a more suitable name!) with return type boolean. In the formula wizard enter the expression ZEX_CONTAINS_CAT AND ( total value >= '501' ).

To square things up - to trigger the process level enter the ZEX_CHECK_SC in the evaluation id of the process level.

In the code you posted above there is a small coding issue: if there are 2 items in the shopping cart and the first comes from MDM and the second is a free text the code will return false. To prevent this EXIT the loop when you find the correct catalogid.



Former Member
0 Kudos


THank you very much for your reply. I said using /sapsrm/CL_WF_RULE_CONTEXT is not great idea because I have already tried it using zcl_wf_rule_contxt_sc.only difference is instead of using 0B_SC_ACCTASSCAT_AS, I used (0V_SC_XSTFRTXTLNTM). Problem remained the same. Approval is going for auto approval. As a catalogid constant i am taking MDM CATALOG 3.0 (with spaces ...referred table BBP_PDIGP )for ZC_C3_C_CATLOG. Is there anything wrong there ? Because in debugging I clearly sees ev_value = 'X'. It clearly means that flag is set once when catalogid = MDM Catalog 3.0.

Please share your experience. Thank you for your help.

Best regards.

Former Member
0 Kudos

Hey Robin...That works. Thank you very much for the helpful and correct answer.

Answers (1)

Answers (1)

Former Member
0 Kudos


The only standard delivery expression that we have for SC item catalog is:

Determination of the catalog ID (if the same for all items)



Determination of the catalog ID of all line items relevant for the current approval step. For item-based approval only items to be approved are considered. The catalog ID is only returned if it is unique for all items; otherwise the result variable is initial.



Former Member
0 Kudos

Melina thank you very much for your reply. I will try with this standard expression. I have not understood these ex[ressions entirely. My following question might be out of box or irrelevant but if i decide to create my own z expression like (0V_SC_XSTFRTXTLNTM------An item exists from a free entry) for catalog; is it possible to do so or it would be a wrong idea ? If yes, how would I find SC guid ? Right now I know that

   CALL METHOD lo_context_provider->get_document will give me GUID. But if I want to know other details like where these results are stored ? I know that ev_value contains result but for (0V_SC_XSTFRTXTLNTM--- An item exists from a free entry) there must be some mechanism that tells to the expression that this item is from freetext. Where these details are stored ? Which variables ? I have tried to do so by creating z class of /sapsrm/CL_WF_RULE_CONTEXT. But that is not great idea. If you know please share.

Thank you.

Best regards.