cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Shopping Cart lines through BBP_DOC_CHANGE_BADI

Former Member
0 Kudos

Folks,

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.

<b>code:</b>

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.

endif.

ENDLOOP.

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.

ENDIF.

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.

CALL FUNCTION 'MDM_GET_NEXT_GUID'

IMPORTING

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.

CALL FUNCTION 'MDM_GET_NEXT_GUID'

IMPORTING

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 =

ls_current_item_guid.

CALL FUNCTION 'MDM_GET_NEXT_GUID'

IMPORTING

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.

ENDLOOP.

append lines of lt_temp_partner TO it_partner.

LOOP AT it_orgdata INTO ls_orgdata_wa WHERE p_guid =

ls_current_item_guid.

CALL FUNCTION 'MDM_GET_NEXT_GUID'

IMPORTING

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.

ENDLOOP.

append lines of lt_temp_orgdata TO it_orgdata.

endloop.

endif.

endif.

es_header = ls_header.

et_item[] = it_item[].

et_account[] = it_account[].

et_partner[] = it_partner[].

et_orgdata[] = it_orgdata[].

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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!

-Seyed

Former Member
0 Kudos

Well, the above notes is applicable only for SRM_SERVER550 ( SRM 5.0)

We have SRM_SERVER500 ( SRM 4.0 ) and we didnt apply this note because of the version.

However, I've opened a message with SAP. Hope they get back with a similar note for SRM 4.0

I checked the standard code in SRM 4.0 and it is in need of a correction. The subsequent logic after the BBP_DOC_CHANGE_BADI CALL only updates changes to all the items passed to the BADI. It simply ignores the new items added inside the BADI.

-Seyed

Former Member
0 Kudos

Hi Seyed,

Did you get any success so far regarding this??

Kim