BAPI function caches data: In an InputScript I use the following BAPI call to read purchase orders (PO).

Call "BAPI_PO_GETDETAIL" ...

When I change the PO data in another session and read the PO again, I still obtain the old data. I have tried to clear the cache (ClearCallCache ) but this doesn't help. Could you please advise me.

The BAPI function probably reads the PO from an internal cache instead of from the database when you call it the second time.

For some BAPI functions this can be controlled via a special input parameter, but for this BAPI I haven't found a cache control parameter. In other cases there is a special BAPI that can be called to set the cache behaviour, but I didn't find such a call for this case.

In most cases it will help to call up the function BAPI_TRANSACTION_COMMIT before reading data, since this function module calls BUFFER_REFRESH_ALL after executing the commit, clearing all BAPI buffers:

Set V[wait] "X"

Call "BAPI_TRANSACTION_COMMIT" export.wait="wait"

Finally, here is a workaround for function modules which do not observe the logic used in BUFFER_REFRESH_ALL. Disconnect the RFC connection with

ProcessingOption RfcDisconnect="On"
   Call "BAPI_PO_GETDETAIL" ...
ProcessingOption RfcDisconnect="Off"

so that you work in a new RFC environment. The performance is slightly slower with this setting since a new RFC logon is necessary, but it will solve the BAPI cache problem.