Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Purchasing group from external requirements

Hello Everybody,

Please let me know if such behaviour is correct as I do not have any other way to verify it.

We are using Classic scenario. In SRM we have two purch. groups which have a function 'purchasing group' and are 'connected' with pur. groups from backend. We did not assign any product reponsibilities as buyers from both groups can order all products. I would expect, that when I transfer purchase requisition from the backend, system will assign it for sourcing to the right purchasing group in SRM: SRM purch. group = purch. req. line purch. group . In my case it always assigns the same purch. group. I have no idea why. Both are ok because if I remove the group from SRM then the whole sourcing goes to the other one.

Please advise. I will grant point for usefull answers.

kind regards,

Robert

Former Member
Former Member replied

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.

Regards

- Atul

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question