cancel
Showing results for 
Search instead for 
Did you mean: 

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

matteo_montalto
Contributor
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

matteo_montalto
Contributor
0 Kudos

Solved. A simple COMMIT WORK was not sufficient since an update task started before might not be finished in time for the query. A COMMIT WORK AND WAIT does the job

matteo_montalto
Contributor
0 Kudos

Here comes the trouble... If I follow in debug mode this code, everything goes fine. If I don't, sometimes happens that in new PO a service position misses the entry in BBP_PDBEI. Obviously, the "source" PO is exactly the same. I tried to put a "TRANSFER TO fs_log" statement in order to trace a log of execution in both point "1 and "2, seeing that... In the wrong case, the statement:

SELECT SINGLE * FROM bbp_pdbei INTO wa_pdbei WHERE guid = ls_item_d-guid.

gives a sy-subrc = 0 even though checking the table this seems not to be true.

Can anybody suggest me a way to investigate this? Should it be a buffer problem? I tried to place some BBP_BUFFER_RESET call in my code but this often lead to a dump message "buffer table is not updated" (probably that's because I did not understand how these buffers work in SAP SRM).

Any help's welcome!

Thank you in advance.

ps: message split in two parts due to a strange display error merging these two pieces.. does anyone knows why sometimes using the CODE directive things appears messed up once posted?

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

matteo_montalto
Contributor
0 Kudos

Hello again,

I was wondering if there's a way to monitor changes from a dictionary table like BBP_PDBEI. I'd like to know, seen that the SELECT query has a positive result but after the document has been saved, WHERE exactly the entry initially found in the DB table has been deleted.

Is there any chance to understand it in SRM ?

Thanks again.