Skip to Content
0
Oct 30, 2009 at 10:27 AM

Strange result accessing an SRM DB table - maybe a buffer issue?

75 Views

Hi all SAP SRM gurus,

I'm working on a custom form on an old SRM system (SRM 3, BBPCRM 400) that should allow the user to copy a purchase order to a newer one. So far, I found a particular situation I have to analize in deep and for which I'd ask your help/suggestion.

This is the scenario: in this highly customized system it may occur that a service item position misses an entry in BBP_PDBEI table. If such is the case, the order can't be distributed to the backend system due to an error on the R/3 side.

In order to prevent this issue during the copy process of a purchase order, I simply check whether the new order items have an entry in BBP_PDBEI table: first of all, here's a sketch of the creation of the new PO:

Get the source PO details via BBP_PD_PO_GETDETAIL;

Modify header structures in order to get them suitable and launch a BBP_PD_PO_CREATE; here we have a new purchase order, without positions since I passed just header's information;

Prepare structures (items, acc assignment, partners, etc...) and lauch a BBP_PD_PO_UPDATE on the new PO to add all the data for the new order;

BBP_PD_PO_SAVE and BAPI_TRANSACTION_COMMIT.

So far, everything seems to be ok.

Now, I simply call a GETDETAIL on the new purchase order, getting the ITEMS table. This is the (trivial) code to verify each item has its own entry in BBP_PDBEI:

CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
  EXPORTING
    i_guid            = new_header-guid
    i_with_itemdata   = 'X'
  TABLES
    e_item            = lt_items_d[]    .
LOOP AT lt_items_d INTO ls_item_d WHERE product_type = '02' AND
   itm_type = 'HIER'.  "there are the pos. I have to check
  "1
  SELECT SINGLE * FROM bbp_pdbei INTO wa_pdbei WHERE guid = ls_item_d-guid.
  IF sy-subrc <> 0.
    "2
    "prepare an entry for BBP_PDBEI and add it to the DB table & commit work.

Edited by: Matteo Montalto on Oct 30, 2009 11:38 AM