on 06-12-2012 4:09 PM
I need to retrieve the list of approved Vendors for a given Product Category. To do so I want the Vendor lists for the Product category and then the Approved Vendors for the Vendor list(s). I am looking for a more straightforward extract of the data than using Business partner roles, GUIDs, classes, methods, function modules etc, as we also need this for BW reporting too.
Can any techie please give me a helping hand, preferably what tables and key values are used without the use of Fms and methods? Thanks
If a preferred vendor partner is on the approved vendor list for the item category, the partner function can be changed to “approved” in method BBP_SC_CHANGE of BADI BBP_DOC_CHANGE_BADI implementation.
Note:
· The PARTNER_GUID on the item partner record is invalid as the vendor is filled in as a preferred vendor and the GUID is not known;
· When reading the partner records, the parent GUID(P_GUID) differs from the master data table parent GUID, as the partner parent GUID is the document item GUID.
Source code example:
method IF_EX_BBP_DOC_CHANGE_BADI~BBP_SC_CHANGE.
* ---------------------------------------------------------------------
* tables
* ----------------------------------------------------------------------
DATA: itab_pdlist TYPE TABLE OF BBP_PDS_AVL_PDLIST ,
itab_messages TYPE BBPT_PD_MESSAGES, " table type
itab_messages2 TYPE TABLE OF BBP_PDS_MESSAGES,
itab_PARTNER type TABLE OF BBP_PDS_PARTNER ,
itab_ITEM type TABLE OF BBP_PDS_AVL_ITEM_D ,
itab_STATUS type TABLE OF BBP_PDS_STATUS .
* ----------------------------------------------------------------------
* Data Definitions.
* ----------------------------------------------------------------------
DATA: ls_header TYPE bbp_pds_sc_header_u,
ls_item TYPE bbp_pds_sc_item_icu,
ls_account TYPE bbp_pds_acc,
ls_partner TYPE bbp_pds_partner,
ls_partner_md TYPE bbp_pds_partner, " master data partners
ls_org_data TYPE bbp_pds_org,
ls_hcf TYPE bbp_pds_hcf_sc,
ls_icf TYPE bbp_pds_icf_sc,
lw_category TYPE BBP_CATEGORY_GUID_RAW,
lw_category_id TYPE BBP_CATEGORY_ID,
lw_PROC_ORG TYPE BBP_PROC_ORG,
i_header TYPE bbp_pds_avl_header_d,
i_attach type BBPT_PDS_ATT_T,
ls_pdlist TYPE BBP_PDS_AVL_PDLIST,
lw_approved_flag type flag,
lw_preferred_idx type SYTABIX.
DATA: ls_avl TYPE BBPD_PD_INDEX,
lt_avl TYPE TABLE OF BBPD_PD_INDEX.
CONSTANTS:
c_vendor TYPE crmt_subobject_category_db
VALUE 'BUS2206001',
c_preferred_vendor TYPE crmt_partner_fct VALUE '00000039',
c_approved_vendor TYPE crmt_partner_fct VALUE '00000019',
c_true type XFELD value 'X',
c_read_init_parm type BBPS_PDLIST_HDR_READ_INITIAL
value ' X'.
* ----------------------------------------------------------------------
* Start of Processing
* ----------------------------------------------------------------------
* ----------------------------------------------------------------------
* For method BBP_SC_CHANGE, ensure that you fill all export parameters
* even if you wish to change only one parameter. After calling up the
* BAdI, the system can only work with the data in the export interface.
* The BAdI contains sample coding that you can use as a guide. If, for
* example, you wish to change only the export parameter ES_HEADER, you
* must still fill all the export parameters with the import data. This
* procedure ensures the integrity of the data and you can trace, for
* example, if an empty table has been deleted or if it has remained
* unchanged.
* ----------------------------------------------------------------------
* Importing parameters
es_header = is_header.
APPEND LINES OF it_item TO et_item.
APPEND LINES OF it_account TO et_account.
APPEND LINES OF it_partner TO et_partner.
APPEND LINES OF it_orgdata TO et_orgdata.
APPEND LINES OF it_hcf TO et_hcf.
APPEND LINES OF it_icf TO et_icf.
* Read org unit data for FM call "RJB
READ TABLE it_orgdata INDEX 1 into ls_org_data.
CONCATENATE ls_org_data-proc_org_ot ls_org_data-proc_org_id
into lw_PROC_ORG separated by space.
* ----------------------------------------------------------------------
* Start looping at the items itab.
* ----------------------------------------------------------------------
LOOP AT et_item INTO ls_item.
clear lw_approved_flag. "RJB
* ----------------------------------------------------------------------
* Check the partner records related to the line. If we find a preferred
* vendor, check in table BBPD_PD_INDEX to see if it is an approved
* vendor for the line item category. If it is, change the partner
* function code to the value for approved vendors.
* ----------------------------------------------------------------------
LOOP AT et_partner INTO ls_partner
WHERE p_guid = ls_item-guid " Parent guid of partner functions
AND partner_fct = c_preferred_vendor.
* if there is a preferred vendor partner, check if it is an approved vendor
* for the item category , populate partner function data and change partner
* function to approved
* Store preferred partner index
lw_preferred_idx = SY-TABIX.
* Get AVL (Approved vendor list)
move ls_item-category to lw_category .
move ls_item-category_id to lw_category_id .
CALL FUNCTION 'BBP_PD_AVL_GETLIST'
EXPORTING
I_CATEGORY = lw_CATEGORY
I_CATEGORY_ID = lw_category_id
I_PROC_ORG = lw_PROC_ORG
TABLES
E_PDLIST = itab_pdlist[]
E_MESSAGES = itab_messages.
* Build list of valid vendors for vendor list
LOOP at itab_pdlist into ls_pdlist.
CALL FUNCTION 'BBP_PD_AVL_GETDETAIL'
EXPORTING
I_GUID = ls_pdlist-GUID
I_ATTACH_WITH_DOC = c_true
I_WITH_ITEMDATA = c_true
IMPORTING
E_HEADER = i_header
ET_ATTACH = i_attach
TABLES
E_ITEM = itab_ITEM
E_PARTNER = itab_PARTNER
E_MESSAGES = itab_messages2
E_STATUS = itab_status.
* Get the approved vendor partner record for the preferred vendor
loop at itab_PARTNER into ls_partner_md " master data tab
where PARTNER_FCT = c_approved_vendor
and PARTNER_ID = ls_partner-PARTNER_ID
and DEL_IND IS INITIAL.
* update the prefered partner function with partner function information & change fxn to approved
ls_partner_md-P_GUID = ls_partner-P_GUID.
delete et_partner INDEX lw_preferred_idx.
insert ls_partner_md into et_partner INDEX lw_preferred_idx.
if sy-subrc = 0.
lw_approved_flag = c_true.
endif.
endloop.
endloop.
ENDLOOP. "(AT et_partner INTO ls_partner)
ENDLOOP. "(AT et_item INTO ls_item.)
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.