cancel
Showing results for 
Search instead for 
Did you mean: 

BADI BBP_PGRP_FIND

Former Member
0 Kudos

Hello All,

Can you please guide me to develop a program logic to default the purchasing group in

the shopping cart based on the plant / product category via BADI BBP_PGRP_FIND.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

write the code into the method DETERMINE_RESP_PGRP

Take the help from the below code.

DATA: lv_sy_subrc TYPE sy-subrc.

DATA: lv_local TYPE logsys,

lv_logical_system TYPE bbp_attr_sys.

DATA: ls_prcat TYPE comt_category,

lv_src_system TYPE bbp_category_src_sys.

DATA: ls_object TYPE hrrootob,

ls_search_prcat TYPE bbps_attr_prcat_single,

ls_search_porg TYPE hrobjid.

data: lv_sycode like syst-tcode.

*----

-


  • This is a copy of the standard SRM logic in

  • BBP_OM_DETERMINE_RESP_PGRP

  • except line

  • IF is_resp_item_data-logical_system = lv_local.

  • CLEAR lv_logical_system.

*----

-


Case Sy-MANDT.

WHEN '750'. "Government Procurement only

  • Get local system

call function 'BBP_LOGSYS_READ'

IMPORTING

e_my_logsys = lv_local.

  • Evaluation of the product category info

if not is_resp_item_data-category is initial.

  • derive LogSys and ID from the category GUID

call function 'COM_CATEGORY_READ'

EXPORTING

iv_category_guid = is_resp_item_data-category

IMPORTING

es_category = ls_prcat

EXCEPTIONS

others = 1.

lv_sy_subrc = sy-subrc.

if lv_sy_subrc <> 0. " category-ID not found

raise cat_not_found.

endif.

elseif not is_resp_item_data-category_id is initial.

  • product categories, which are not part of the BBP master data

ls_prcat-category_id = is_resp_item_data-category_id.

ls_prcat-logsys = is_resp_item_data-product_src_sys.

endif.

  • Evaluation of info about target system

if is_resp_item_data-logical_system = lv_local.

if sy-tcode eq 'BBP_BID_INV' and

sy-ucomm eq 'POCR'.

lv_logical_system = '*'.

else .

lv_logical_system = ls_prcat-logsys.

endif.

endif.

*=======================================================================

  • Find responsible purchasing groups

*=======================================================================

  • Fill et_purch_data

ls_object-otype = is_object-otype.

ls_object-objid = is_object-objid.

ls_search_prcat-catid = ls_prcat-category_id.

ls_search_prcat-logsys = ls_prcat-logsys.

  • Fill et_purch_data

call function 'BBP_OM_FIND_SC'

exporting

  • prefetch_id = lv_prefetch_id " parallel processing

search_for = ls_object

search_logsys = lv_logical_system

search_catid = ls_search_prcat

search_porg = ls_search_porg

importing

hitlist = et_purch_data

exceptions

internal_error = 1

nothing_found = 2

no_authority = 3

others = 4.

lv_sy_subrc = sy-subrc.

if lv_sy_subrc = 1.

raise cat_not_found.

elseif lv_sy_subrc = 2.

raise no_resp_pgrp.

elseif lv_sy_subrc = 3.

raise no_pgrp.

endif.

*----

-


  • Return default purchasing group

lv_sycode = sy-tcode.

if lv_sycode = 'BBPSC01'.

  • Do local purch group for Shopping carts only, but not for extreqs

clear lv_logical_system.

call function 'BBP_OM_FIND_SC'

exporting

  • prefetch_id = lv_prefetch_id " parallel processing

search_for = ls_object

search_logsys = lv_logical_system

search_catid = ls_search_prcat

search_porg = ls_search_porg

importing

hitlist = et_purch_data

exceptions

internal_error = 1

nothing_found = 2

no_authority = 3

others = 4.

lv_sy_subrc = sy-subrc.

if lv_sy_subrc = 1.

raise cat_not_found.

elseif lv_sy_subrc = 2.

raise no_resp_pgrp.

elseif lv_sy_subrc = 3.

raise no_pgrp.

endif.

loop at et_purch_data into es_purch_data where logical_system eq

space.

endloop.

else. " Now look for extreq's

  • Take the first entry as default purchasing group

if is_resp_item_data-proc_group is initial.

check sy-mandt eq '750'.

data: lv_comp(30) type c.

lv_comp = is_resp_item_data-ordered_prod.

check lv_comp is not initial.

shift lv_comp left deleting leading

'ABCDEFGHIJKLMNOPQRSTUVWXYZ-_0'.

concatenate 'T' '*' lv_comp into lv_comp.

loop at et_purch_data into es_purch_data where be_pur_org = 'GOVP'

.

if es_purch_data-be_pur_group cp lv_comp.

exit.

endif.

endloop.

if sy-subrc <> 0.

raise no_resp_pgrp. "Keine verantw. Einkäufergruppe gefunden

endif.

  • Or take the proposal when given

elseif not is_resp_item_data-proc_group is initial.

read table et_purch_data

with key proc_group-otype = is_resp_item_data-proc_group-otype

proc_group-objid = is_resp_item_data-proc_group-objid

into es_purch_data.

if sy-subrc <> 0. "Proposal not valied -> take the first

read table et_purch_data into es_purch_data index 1.

if sy-subrc <> 0.

raise no_resp_pgrp. "Keine verantw. Einkäufergruppe gefunden

endif.

endif.

endif.

endif.

when others. "--> "Reanimate" Standard-PGRP-finding:

  • Get local system

CALL FUNCTION 'BBP_LOGSYS_READ'

IMPORTING

e_my_logsys = lv_local.

  • Evaluation of the product category info

IF NOT is_resp_item_data-category IS INITIAL.

  • derive LogSys and ID from the category GUID

CALL FUNCTION 'COM_CATEGORY_READ'

EXPORTING

iv_category_guid = is_resp_item_data-category

IMPORTING

es_category = ls_prcat

EXCEPTIONS

OTHERS = 1.

lv_sy_subrc = sy-subrc.

IF lv_sy_subrc <> 0. " category-ID not found

RAISE cat_not_found.

ENDIF.

ELSEIF NOT is_resp_item_data-category_id IS INITIAL.

  • product categories, which are not part of the BBP master data

ls_prcat-category_id = is_resp_item_data-category_id.

ls_prcat-logsys = is_resp_item_data-product_src_sys.

ENDIF.

  • Evaluation of info about target system

IF is_resp_item_data-logical_system = lv_local.

CLEAR lv_logical_system.

ELSEIF is_resp_item_data-logical_system IS INITIAL.

lv_logical_system = '*'.

ELSE.

lv_logical_system = is_resp_item_data-logical_system.

ENDIF.

*======================================================================

  • Find responsible purchasing groups

*======================================================================

  • Fill et_purch_data

ls_object-otype = is_object-otype.

ls_object-objid = is_object-objid.

ls_search_prcat-catid = ls_prcat-category_id.

ls_search_prcat-logsys = ls_prcat-logsys.

  • Fill et_purch_data

CALL FUNCTION 'BBP_OM_FIND_SC'

EXPORTING

  • prefetch_id = lv_prefetch_id " parallel processing

search_for = ls_object

search_logsys = lv_logical_system

search_catid = ls_search_prcat

search_porg = ls_search_porg

IMPORTING

hitlist = et_purch_data

EXCEPTIONS

internal_error = 1

nothing_found = 2

no_authority = 3

OTHERS = 4.

lv_sy_subrc = sy-subrc.

IF lv_sy_subrc = 1.

RAISE cat_not_found.

ELSEIF lv_sy_subrc = 2.

RAISE no_resp_pgrp.

ELSEIF lv_sy_subrc = 3.

RAISE no_pgrp.

ENDIF.

*----

-


  • Return default purchasing group

  • Take the first entry as default purchasing group

IF is_resp_item_data-proc_group IS INITIAL.

READ TABLE et_purch_data INTO es_purch_data INDEX 1.

IF sy-subrc <> 0.

RAISE no_resp_pgrp. "Keine verantw. Einkäufergruppe gefunden

ENDIF.

  • Or take the proposal when given

ELSEIF NOT is_resp_item_data-proc_group IS INITIAL.

READ TABLE et_purch_data

WITH KEY proc_group-otype = is_resp_item_data-proc_group-otype

proc_group-objid = is_resp_item_data-proc_group-objid

INTO es_purch_data.

IF sy-subrc <> 0. "Proposal not valied -> take the first

READ TABLE et_purch_data INTO es_purch_data INDEX 1.

IF sy-subrc <> 0.

RAISE no_resp_pgrp. "Keine verantw. Einkäufergruppe gefunden

ENDIF.

ENDIF.

ENDIF.

ENDCASE. "SY-MANDT

Regards,

Sachin

Former Member
0 Kudos

Hello sachin ,

Many thanks for the reply.

I looked at that code, but it does not help. The reason is that we want to determine the purchasing org or purchasing group by some criteria of the shopping cart. Plant would be one of it. The problem is when we are implementing this badi, we don't have any information of the shopping cart so that we can find the plant or company code.

I feel we could use BBP_PD_SC_GETDETAIL via GUID or shopping cart number but the shopping cart GUID is not being passed into the badi.

Can you please advice.

Thanks & Regards,

Kavitha.

Former Member
0 Kudos

Hi,

I did not get you this badi is used to determine the Responsible Purchasing Group(s) yourself.

"For Shopping cart: The purchasing group is determined using the item data and the user. In the standard functionality, product and organizational responsibility is taken into account".

Note:- This BADI is called during the creation of SC so how can you get the SC No. in this BADI.

Can you just give me the details of your requirement and the Business Process what you want?

Regards,

Sachin

Former Member
0 Kudos

Hello Sachin,

Many thanks for the clarrification.

I need to default the purchasing group in the shopping cart based on the plant / product category

using BADI BBP_PGRP_FIND.

Regards,

Kavitha.

Former Member
0 Kudos

Hi Kavitha,

Ok. this is what exactly heppenning in the code which I have given you.

this function call CALL FUNCTION 'BBP_OM_FIND_SC'

gives all the responsible purchasing groups for the corresponding product category.

then you can loop on the hitlist export parameter and pass the purchasing group which you want to default in to the ET_PURCH_DATA and ES_PRCH_DATA.

take the help of your technical person and write the logic with the help of the code which i have given.

Regards,

Sachin

Former Member
0 Kudos

Hello sachin,

The FM BBP_OM_FIND_SC helps in bringing the responsible purchasing group,but how to get the plant or company code from the shopping cart so that we could make a decision on to what purchasing group to use.

We will probably have a plant, company code and purchasing group in a

Z-table, so that we can choose the correct combination.

The problem with this badi is that it does not bring in any shopping

cart data.

Can you please tell how to bring in the plant or company code into this badi.

Regards,

kavitha.

Former Member
0 Kudos

Hi,

Use this function module 'BBP_LOCMAP_BUFFER'.

This will give you the data of all plants, company code and the respective user id(business partner)

Regards,

Sachin

Answers (0)