Setting the "Usecache" option to True on a K2 Connect Service Instance: Expected behavior

  • 24 February 2022
  • 0 replies
  • 24 views

Userlevel 5
Badge +20
 

Setting the "Usecache" option to True on a K2 Connect Service Instance: Expected behavior

kbt143957

PRODUCT
K2 connect
BASED ON
K2 connect 4.7.3
This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
LEGACY/ARCHIVED CONTENT
This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.

Objective

When making use of K2 Connect for SAP, there is a parameter in the K2 Connect Service Instance named "UseCache".

With UseCache set to True, K2 caches the structure of the BAPI and does not request it again for every Connect SmartObject execution. This speeds up the overall execution and gets rid of repetitive SAP queries to reflect the structure of every BAPI.

When executing a Connect SmartObject with no input properties, and the SAP BAPI has a default value defined, results are returned on the first execution. When the SmartObject is executed subsequent times with no input properties, no results are returned.

 

 

Before You Begin

The "UseCache" feature is a function of the ERPConnect client SDK, used to cache information about BAPIs (Tables, Structures, Fields). It does not cache data. The caching option helps with lowering the amount of calls to SAP to retrieve information about a BAPI. E.g. if a BAPI consists of 10 inner structures and tables we would have to make 11 calls to SAP to get information about the BAPI. This would have to be repeated every time the SmartObject is executed with caching disabled. With caching on, we only need to get the information once per connection session.

When the information about the BAPI is retrieved, ERPConnect constructs a local object. That object might then also have any default values set on its properties obtained from the BAPI. When we use ERPConnect to execute that BAPI, it will overwrite the property values with anything we specify and using the cached object, construct a Netweaver RFC object to execute against SAP. After execution, any property values are set back to null by ERPConnect to be ready for the next call. This will also include any default values that was previously set.

On the next execution, if no value is assigned as an input property, an empty value will be sent to SAP (current state of the cached metadata object) and no data will be returned by SAP.

How-to Steps

There are a couple of options that work with this scenario:

1. Make sure that an Input Property value is always supplied to the SmartObject and sent to the BAPI for the field from K2.
2. Change the BAPI to check if the field is null, then set the Default value again.

3. It is minimally intrusive and considered good practice in ABAP developments. Adding the following lines to the BAPI source fixes the issue:

IF [SAP PROPERTY] IS INITIAL.
 [SAP PROPERTY] = '[Default Value]'.
ENDIF.

0 replies

Be the first to reply!

Reply