cancel
Showing results for 
Search instead for 
Did you mean: 

Which Badi to Use?

Former Member
0 Kudos

While creating a shopping cart I want to throw an error message if we give price equal to 0 ie. I want an validation whenever the price is given 0. the shopping cart shouldn't accept such a value. Kindly help

Accepted Solutions (1)

Accepted Solutions (1)

yann_bouillut
Active Contributor
0 Kudos

Hi,

Please use bbp_doc_check badi for bus2121

Kind regards,

Yann

Former Member
0 Kudos

Hi Yann,

I have already used Badi bbp_doc_check badi for bus2121. But it checks for the items already existing in the shopping cart where we can pass the GUID and do the validation. But my requirement is that when creating the item in the shopping cart the validation should be made and an error message should be shown. I mean no item should be created with price = 0. Kindly help.

Sateerth

yann_bouillut
Active Contributor
0 Kudos

Hi,

Not sure to clearly understand your requirement...

when Sc is filled with an item where price=zero then issue error message ?

if this is what you want, this badi is usefull

Kind regards,

Yann

Former Member
0 Kudos

Hi,

In the BADI,use the FM "BBP_PD_SC_GETDETAIL" to get the SC deatils and then preform a check on the ITEM table data for each line item .

BR,

Disha.

<b>Pls reward points for useful answers.</b>

Former Member
0 Kudos

Hi,

FM "BBP_PD_SC_GETDETAIL is used to get the details of SC. My requirement is that when I create a line item whrere price is 0 the error message should be displayed. can you please provide me a FM for this. I have already implemented BBP_DOC_CHECK_BADI in se19. I have to now write the method.

Former Member
0 Kudos

Hi,

In the method "bbp_sc_change" of the BADi,write the code in the foll way:

First Use the FM "BBP_PD_SC_GETDETAIL" to get the SC details for each line item.The item details will be in table "E_ITEM".

Then read each line item for whcih price is 0 and throw an error message

loop at et_item into wa_item_price where price eq 0.

Your Error Message.

endloop.

BR,

Disha.

Pls reward points for useful answers.

Former Member
0 Kudos

Hi,

That is all right . FM "BBP_PD_SC_GETDETAIL" to used to get the SC details for each line item. But what I want is that when I create a line item in the shopping cart at that time I want to throw an error message.I mean if the user enter price = 0 then the shopping cart shouldn't accept it. That means there should be no line item with price = 0 in the shopping cart.

Sateerth

Former Member
0 Kudos

Hi,

It is only after you <b>create</b> the line item the system will check as per the code in the BADI.Through BADi,you can only prompt the user to enetr some value in the Price field.

BR,

Disha.

Pls reward points for useful answers.

Former Member
0 Kudos

Hi ,

I have used FM BBP_PD_SC_GETDETAIL, but here I have to pass GUID ans the object ID, I think this is created once shopping cart is created. I want an validation on the price field on the item before shopping cart is created. As I am new to this area Please help me out........

Former Member
0 Kudos

Hi,

As explained earlier ,using the BADI "BBP_DOC_CHECK_BADI" only you can check/validate the data while creating the SC.So just pass the SC GUID to the FM and get the details for the Price field.If the price field is blank then throw the error message.

BR,

Disha.

<b>Pls reward points for useful answers.</b>

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Das,

For your better understanding, technically there is cart created as soon as you click the shop button but it is not complete (Shopping cart creation as you understand) until you order it..

If you would like to validate the shopping cart based on the price then use the logic explained by Disha. When you throw a hard error then the shopping cart cannot be ordered ( cannot be created).

So your problem of throwing an error on 0 price before the shopping cart is created is achieved.

Let me know if you have further questions..

Regards

Rakesh

Ps. Please close the thread if your question is answered..

Former Member
0 Kudos

Hi,

I have now implemented BADI "BBP_DOC_CHECK_BADI in se19. I am using FM BBP_pd_sc_GETLIST to get the items. I just need one clarification. The SC guid as you say (IV_DOC_GUID) in this badi.....I mean this will automatically come....I mean from where this value comes....?

Former Member
0 Kudos

Das,

BADI is a Method to a class and the iv_doc_guid is the import parameter. So when this BADI is called then the import parameters are already filled.

Please let me know if you need more information..

Regards

Rakesh

Former Member
0 Kudos

Hi rakesh,

I am just sending you what I have done? Just let me know if i have done anything wrong?

method IF_EX_BBP_DOC_CHECK_BADI~BBP_DOC_CHECK.

DATA: wa_item TYPE BBP_PDS_SC_ITEM_D.

DATA: it_item TYPE STANDARD TABLE OF BBP_PDS_SC_ITEM_D.

DATA: it_error type standard table of BBP_SMESSAGES_BADI.

DATA: wa_error type BBP_SMESSAGES_BADI.

  • CALL FUNCTION 'BBP_PD_SC_GETDETAIL'

  • EXPORTING

  • I_GUID = IV_DOC_GUID

    • I_OBJECT_ID =

    • I_ATTACH_WITH_DOC = ' '

    • I_WITH_ITEMDATA = 'X'

    • I_ITEM_SORTED_BY_HIERARCHY =

    • I_WITHOUT_HEADER_TOTALS =

    • I_READ_FROM_ARCHIVE = ' '

    • IMPORTING

    • E_HEADER =

    • EV_IS_PD =

    • ET_ATTACH =

  • TABLES

  • 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-price = 0.

  • wa_error-message = text-001.

  • append wa_error to it_error.

*ENDIF.

*ENDLOOP.

*ET_MESSAGES[] = IT_ERROR[].

**ENDIF.

endmethod.

Former Member
0 Kudos

Hi,

Seems to be OK, but add to wa_error message type (E=error, S=success, I=info).

or

You can create a message class in transaction SE91 (for example ZMY_SC)

In this message class create message with number (for example: numer 001, message The price is zero!)

In your code write something like this:


LOOP at it_item into wa_item.
  IF wa_item-price = 0.
   call function 'BBP_PD_MSG_ADD'
        exporting
          i_msgty       = 'E'
          i_msgid       = 'ZMY_SC'
          i_msgno       = 001
        exceptions
          log_not_found = 1
          others        = 2.
  ENDIF.
ENDLOOP.

Regards,

Marcin

Former Member
0 Kudos

thamks to all of you.Its solved