saprfc

SAP NW RFC is using old function parameters. Cache? How to reset metadata?


I've encountered an issue with SAP NW RFC, when I'm trying to obtain the metadata for a custom function module my customer has written, I get the following error when calling RfcGetStringLength:

Return code: RFC_ILLEGAL_STATE

RFC error group: EXTERNAL_RUNTIME_FAILURE

Error Key: RFC_ILLEGAL_STATE

Error message: Trying to access row values in a table which does not have any rows yet

My code was working against the customer's function module before they changed one of the (structure) parameters. After the change we are seeing this error.

I'm becoming more and more convinced that the SAP NW RFC metadata cache is holding stale metadata from before the structure was changed, and I'd like to delete the cached metadata to confirm my hypothesis. However, I'm not certain where the metadata is cached in the file system. My client program is running on Windows Server 2016.


Solution

  • Metadata is cached only in memory - but permanently for the runtime duration of your application process. During runtime you can clear the metadata cache via API calls, e.g. via RfcClearRepository.

    Anyway, your error message shows that the table, which you are accessing, is empty. Before accessing fields in the current table row always make sure that the table is not empty so that the implicit row cursor is valid, i.e. check with API RfcGetRowCount.