Skip to Content
avatar image
Former Member

Adding Shopping Cart lines through BBP_DOC_CHANGE_BADI


I had a requirement where there is a need to split the line with multiple quantities.

I'm doing this change in DOC CHANGE BADI. This should be similar to a "copy" functionality performed through Shopping cart GUI. But this one is done inside the badi as opposed to user clicking on "copy" button.

As you know, the BADI contains the following structures.

Import -- > Header, Item, Account, Partner, Org data, Header Custom fields, Item custom fields.

Export --> Header, Item, Account, Partner, Org data, Header Custom fields, Item custom fields.

I'm creating a new item and also creating associated objects like account, partner and org data.

I've also looked at the logic for copy function in SRM FM "BBP_SC_APP_EVENT_DISPATCHER".....I believe I've taken care of all the steps.

<b>But it still doesnt WORK.</b> Pls. look at the code and help me if there are any obvious flaws. Points would be awarded for helpful answers.

I've also debugged this BADI and found that if the export structure is populated with

the new item. But GUI neither shows any error nor adds the new item to the cart.

When it errors out, I can atleast look at it. In this case, no clue why it is not being added although I believe I've done the necessary steps.


LOOP AT it_item INTO ls_item_data_wa WHERE del_ind = ''.

if ( ls_item_data_wa-category_id = '40000001' OR

ls_item_data_wa-category_id = '40000002' OR

ls_item_data_wa-category_id = '40000003' )

AND ( ls_item_data_wa-quantity > 1 ).

append ls_item_data_wa to lt_item_data_multiple.

ls_item_data_wa-quantity = 1.

MODIFY it_item FROM ls_item_data_wa.



CLEAR ls_item_data_wa.

DATA: lv_lines TYPE i,

lv_max_item_no TYPE i,

ls_partner_count1 type i,

ls_partner_count2 type i,

ls_partner_count3 type i.

DESCRIBE TABLE it_item LINES lv_lines.

READ TABLE it_item INTO ls_item_data_wa INDEX lv_lines.

IF sy-subrc EQ 0.

lv_max_item_no = ls_item_data_wa-number_int.


CLEAR ls_item_data_wa.

if NOT lt_item_data_multiple IS INITIAL.

DATA: lv_item_guid_16 TYPE GUID_16,

lv_acct_guid_16 TYPE GUID_16,

lv_partner_guid_16 TYPE GUID_16,

lv_orgdata_guid_16 TYPE GUID_16.

loop AT lt_item_data_multiple INTO ls_item_data1.

ls_current_item_guid = ls_item_data1-guid.



E_GUID_16 = lv_item_guid_16.


ls_item_data1-guid = lv_item_guid_16.

ls_item_data1-quantity = 1.

lv_max_item_no = lv_max_item_no + 1.

ls_item_data1-number_int = lv_max_item_no.

ls_item_data1-created_at = sy-datum.

ls_item_data1-changed_at = sy-datum.

append ls_item_data1 to it_item.

READ TABLE it_account INTO ls_acct_data1

WITH KEY p_guid = ls_current_item_guid.



E_GUID_16 = lv_acct_guid_16.

ls_acct_data1-guid = lv_acct_guid_16.

ls_acct_data1-p_guid = lv_item_guid_16.

ls_acct_data1-acc_no = lv_max_item_no.

append ls_acct_data1 TO it_account.

LOOP AT it_partner INTO ls_partner_wa WHERE p_guid =




E_GUID_16 = lv_partner_guid_16.

ls_partner_wa-partner_guid = lv_partner_guid_16.

ls_partner_wa-p_guid = lv_item_guid_16.

append ls_partner_wa TO lt_temp_partner.

clear: ls_partner_wa , lv_partner_guid_16.


append lines of lt_temp_partner TO it_partner.

LOOP AT it_orgdata INTO ls_orgdata_wa WHERE p_guid =




E_GUID_16 = lv_orgdata_guid_16.

ls_orgdata_wa-guid = lv_orgdata_guid_16.

ls_orgdata_wa-p_guid = lv_item_guid_16.

append ls_orgdata_wa TO lt_temp_orgdata.


append lines of lt_temp_orgdata TO it_orgdata.




es_header = ls_header.

et_item[] = it_item[].

et_account[] = it_account[].

et_partner[] = it_partner[].

et_orgdata[] = it_orgdata[].

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Aug 17, 2007 at 06:53 PM

    OK, now I believe I know why the added item didnt show up!

    A search of SAP notes revealed that a note needs to be applied for the added items

    to be available in the shopping cart.

    Note 931735 - bbp_doc_change_badi: Transferring added items

    Let me try that and share the results here!


    Add comment
    10|10000 characters needed characters exceeded