cancel
Showing results for 
Search instead for 
Did you mean: 

SRM - SC - Default value in item custom field

Former Member
0 Kudos

Hi,

we need to create a new custom field in the shopping cart item ( this is easy).

But we want to evaluate it using the BBP_DOC_CHANGE_BADI only for a default value. Is there a way to know if a user is creating or updating the shopping cart?

Please help me.

Thanks

Lara

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

<u>You can use the Business Add-Ins BBP_DOC_CHANGE_BADI to make changes to the document, after user entry and before saving the document to the database. These changes are subject to the document-specific checks.

The parameter FLT_VAL acts as a filter value that assigns the BAdI implementation to a particular document type. You can use the BAdI to change the following documents:

Shopping cart (filter value BUS2121 - shopping cart EC)</u>

<b>For BBP_DOC_CHECK_BADI - see the following Sample code</b>

method IF_EX_BBP_DOC_CHECK_BADI~BBP_DOC_CHECK .

DATA: ls_header  TYPE          bbp_pds_sc_header_d,
      lt_item    TYPE TABLE OF bbp_pds_sc_item_d,
      ls_item    TYPE          bbp_pds_sc_item_d,
      ls_message TYPE          bbp_smessages_badi.

* example for checks only when orderering shopping cart
if iv_mode = 'T' OR    " check shopping cart
   iv_save = 'X'.      " order shopping cart

* get items
    CALL FUNCTION 'BBP_PD_SC_GETDETAIL'
     EXPORTING
       i_guid                  = iv_doc_guid
       i_with_itemdata         = 'X'
      IMPORTING
        e_header                = ls_header
      TABLES
        e_item                  = lt_item.

    LOOP AT lt_item INTO ls_item
         WHERE del_ind = SPACE.

* example message: warning if price is 0
      IF ls_item-price IS INITIAL.

        CLEAR ls_message.

        ls_message-msgty   = 'E'.
        ls_message-msgid   = 'BBP_PU'.
        ls_message-msgno   = '001'.
        ls_message-msgv1   = 'Price is 0'.   
        ls_message-item_guid = ls_item-guid. "assign message to item
        APPEND ls_message TO et_messages.

      ENDIF.

    ENDLOOP.

endif. " iv_mode / iv_save

* example for checks only when park shopping cart
if iv_mode = 'T' OR    " check shopping cart
   iv_park = 'X'.      " park shopping cart

endif. " iv_mode / iv_park

endmethod.

<b>iv_mode filed here, contains the status of the shopping cart (created, changed, ordered, completed etc).</b>

Hope this will help.

Regards

- Atul

Answers (2)

Answers (2)

Former Member
0 Kudos

Atul,

you are very brilliant!!!

Thanks a lot!!!

Lara

Former Member
0 Kudos

Hi,

If you need to check the value for the custom field whenever a user changes the SC,you can use the BADI's "BBP_DOC_CHANGE_BADI" or "BBP_DOC_CHECK_BADI".

In the CHECK badi,you can specifically trigger the BADI for CHANGE mode using the import parameter "IV_MODE"(C for Create,U for Change and S for Save )

BR,

Disha.

Pls reward points for useful answers.