cancel
Showing results for 
Search instead for 
Did you mean: 

BAdI to change pur group

Former Member
0 Kudos

Hi guys.

SRM 4.0, server 5.0. We have several different company codes within our PPOMA, and in our case 1 company code equals 1 purchasing group. Some users are what we call "cross functional" meaning that they can buy from other company codes than the one they are usually assigned to. Additional company codes and locations are simply added as attributes, but when it comes to the purchasing group I need some kind of automatic behaviour. This is what I have in mind:

When the user is changing the company code the location is also changed in the same run. I would like to use the BAdI BBP_PGRP_ASSIGN_BADI to then also trigger an automatic change of the purchasing group that would then match the company code. Something like "when company code '1001' then purchasing group = '547'."

Doesn't this sound possible? Or have I perhaps misunderstood the use of the BAdI mentioned?

Thanks for info.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use various Business Add-Ins provided by SRM system to meet your requirements.

Technically, it's possible using the BADIs

BBP_DOC_CHANGE_BADI BAdI for Changing EBP Purchasing Documents

BBP_PGRP_ASSIGN_BADI EBP Purchasing Documents: Assign Purchasing Group(s)

BBP_PGRP_FIND Shopping Cart: Determine Responsible Purchasing Group(s)

BBP_CREATE_BE_RQ_NEW Exit while creating a purchase requisition in backend system

BBP_CREATE_REQ_BACK OLD Exit while creating a purch. req. in backend system

Here is the sample code for changing the already determined Purchasing groups in SRM System.

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

************************************************************************

Hope this will help.

Refer the foll thread for more details:

BR,

Disha.

Pls reward points for useful answers

Former Member
0 Kudos

Great answer, Disha. Lots of stuff I am sure I can use.

So basically you would suggest me to use the DOC_CHANGE BAdI instead of the PGRP changing/finding BAdI's?

Former Member
0 Kudos

Hi,

Yes.Implement the DOC_CHANGE BAdI .I have succesfully done this at my place and have given you the sample code.

BR,

Disha.

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

Answers (1)

Answers (1)

Former Member
0 Kudos

Oh and also; does anybody know of a template for using this BAdI?