BAPI ProfitCenter
Issue
On the first execute of the ProfitCenter SmartObject, results are returned as expected. Subsequent executions of the SmartObject return no results. The logs created by ERPConnect show that on subsequent executions SAP returns a KM000 “No data found” message in the BAPIRETURN structure. This indicates that the call goes to SAP, but based on the inputs no data was found in the SAP table.
The BAPI_PROFITCENTER_GETLIST BAPI requires one input (CONTROLLINGAREA) and two or three optional inputs (DATE, PERSONINCHARGE). When you reflect the structure of the BAPI some of those optional inputs have default values assigned. PERSONINCHARGE for example has “%” assigned, a SAP wildcard. The BAPI needs valid search inputs to return data.
Cause
With UseCache set to True, K2 caches the structure of the BAPI and doesn't reflect it again. While this speeds up the overall execution and gets rid of repetitive SAP queries to reflect the structure of every BAPI, with this BAPI (BAPI_PROFITCENTER_GETLIST) we lose the default values as the cached object values are reset for new inputs. When the SmartObject is executed with no inputs there are also no optional inputs sent to SAP. The BAPI requires at least a date and a wildcard input to return valid data.
Resolution
When executing the SmartObject you should always send through the optional parameters for this BAPI.
There are a number of ways to achieve this:
- Use the SmartObject API and manually assign the optional values to the SmartObject client object before execution
- If using Smartforms, then the inputs could be bound to hardcoded values or search boxes
- Create a custom Method in the Service Object that assigns the values during the Mapping transformation to the BAPI