cancel
Showing results for 
Search instead for 
Did you mean: 

Changing P Grp in shopping cart item

Former Member
0 Kudos

Hi Experts,

I am trying to change P Grp in shopping cart item. I have below questions.

1. I am trying to change using BADI BBP_PGRP_ASSIGN_BADI but unable to change it in shopping cart item.

2. Do i need to use BADI BBP_DOC_CHANGE_BADI?

3. Is it possible to change P grp belonging to other P org without changing P org?

Thanks & Regards,

Kamal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this sample code.

METHOD if_ex_bbp_doc_change_badi~bbp_sc_change.

data:

ls_header TYPE bbp_pds_sc_header_d,

ls_item TYPE bbps_sc_item_badi,

ls_orgdata TYPE bbp_pds_org,

ls_purch_grps TYPE bbps_om_pgr_light,

lt_purch_grps TYPE TABLE OF bbps_om_pgr_light INITIAL

SIZE 5.

*--- Get the shopping cart header details

CALL FUNCTION 'BBP_PD_SC_GETDETAIL'

EXPORTING

i_guid = is_header-guid

IMPORTING

e_header = ls_header.

  • Map header data

MOVE-CORRESPONDING is_header TO es_header.

  • Map Item data

LOOP AT it_item INTO ls_item.

APPEND ls_item TO et_item.

ENDLOOP.

et_orgdata[] = it_orgdata[].

  • For every purchasing organization, get the corresponding

  • purchasing group assigned in the Organization structure

CALL FUNCTION 'BBP_OM_FIND_PURCH_GRPS_BEI'

EXPORTING

read_purch_org = 'X'

IMPORTING

pgrp_tab_ext = lt_purch_grps.

  • change the purch org id and purch grp id in et_orgdata

LOOP AT it_orgdata INTO ls_orgdata.

CLEAR: ls_item.

READ TABLE et_item INTO ls_item WITH KEY guid = ls_orgdata-p_guid.

IF sy-subrc EQ 0.

CLEAR: ls_purch_grps.

  • Use ls_purch_grps to update org data based on changed purch org

LOOP AT lt_purch_grps INTO ls_purch_grps.

IF ls_purch_grps-purch_orgx+10(4) EQ ls_item-be_pur_org AND

ls_purch_grps-purch_grpx+10(3) EQ ls_item-be_pur_group.

ls_orgdata-proc_group_ot = ls_purch_grps-purch_grp-otype.

ls_orgdata-proc_group_id = ls_purch_grps-purch_grp-objid.

ls_orgdata-proc_org_resp_ot = ls_purch_grps-purch_org-otype.

ls_orgdata-proc_org_resp_id = ls_purch_grps-purch_org-objid.

ls_orgdata-proc_org_ot = ls_purch_grps-purch_org-otype.

ls_orgdata-proc_org_id = ls_purch_grps-purch_org-objid.

MODIFY et_orgdata FROM ls_orgdata TRANSPORTING proc_group_ot

proc_group_id

proc_org_resp_ot

proc_org_resp_id

proc_org_ot

proc_org_id

WHERE guid = ls_orgdata-guid.

EXIT.

ENDIF.

ENDLOOP.

ENDIF. " if sy-subrc eq 0 --> read table et_item

ENDLOOP. " loop at it_orgdata into ls_orgdata

ENDMETHOD.

The above code actually picks the right P grp from the Org structure and assigns the same in the SC.Also the assignement can be done in the way you want it .The logic needs to be written in the BADI "BBP_DOC_CHANGE_BADI".

BR,

Disha.

Pls reward points for useful answers.

Former Member
0 Kudos

Hi Disha,

I will assign full points to you. Please answer my 3rd question if you can.

3. Is it possible to change P grp belonging to other P org?

Is it possible to assign P org and p gp to user to which he is not assigned.

Thanks & Regards,

Kamal

Former Member
0 Kudos

Hi,

The purchasing group and Purchasing Org in the SC can be changed to any value(not necessary the one to whcih he has been assigned in the Org structure) but accordingly the logic needs to be written in the BADI .

The sample code determines the P grp and Porg to whcih the user is assigned in the Org structure and then changes the value accordingly.You can accordingly change the Logic to determine the P grp/org as per your reqt.

BR,

Disha.

Pls reward points for useful answers.

Former Member
0 Kudos

Thanks a lot Disha.

I will try it and let you whether it's successfull or not. Full points assigned to you.

Regards,

Kamal

Former Member
0 Kudos

Hi Disha,

I have tested it and found that i can not assign P grp of any other P org to which user is not assigned. If you have encountered/solved this problem earlier, please let me know.

Thanks & Regards,

Kamal

Former Member
0 Kudos

Hi,

Send me your source code at disha_1008@yahoo.co.in

BR,

Disha.

Former Member
0 Kudos

Hi Disha,

I am testing it with hard coding P grp and P org. Here is my code, please suggest.

lw_pgrp-proc_group_ot = 'O'.

lw_pgrp-proc_group_id = '50001083'.

lw_pgrp-proc_org_resp_ot = 'O'.

lw_pgrp-proc_org_resp_id = '50001082'.

lw_pgrp-proc_org_ot = 'O'.

lw_pgrp-proc_org_id = '50001082'.

MODIFY et_orgdata FROM lw_pgrp TRANSPORTING proc_group_ot

proc_group_id

proc_org_resp_ot

proc_org_resp_id

proc_org_ot

proc_org_id

WHERE p_guid = gw_item-guid.

Thanks & Regards,

Kamal

Former Member
0 Kudos

I am testing in that area too

Here are my finding:

1) If you receive message Purchasing Group XXX is not assigned to Purchasing Organization YYY then you can deactivate it via Influence message control in customizing (message BBP_PD 019 )

2) If you problem is (in classic scenario) that what you receive as POrg and PGrp in backend are the ones before change it is because SRM does not keep consistence between ET_ORGDATA and ET_ITEM, then you need to change the fields BE_PUR_GROUP and BE_PUR_ORG in ET_ITEM too

If this helps you, assign points

Thanks

RD

Former Member
0 Kudos

Hi Disha

I am triing to use this code for assign the correct purchasing group in external requirements but an error is occuring, taxes are not calculated.

Is there some change is this code that I must do ?

Thanks

Nilson

Answers (2)

Answers (2)

khan_voyalpadusman
Active Contributor
0 Kudos

Hi,

I have replied to your thread with text 'BADI BBP_PGRP_ASSIGN ' ,

Former Member
0 Kudos

Hi,

By using, Redistribute Workload one can change the Purchasing group of the shopping cart line item.

Thanks & Regards,

Ramkumar