question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling function import from SAP Cloud SDK returns an empty object

See original GitHub issue

Describe the bug Calling a function import from SAP Cloud SDK returns an empty object, even though the call is successful. You can reproduce the issue by using the following git repository. https://github.com/miyasuta/sdk-function-import-test

To Reproduce Steps to reproduce the behavior:

  1. Develop a custom odata service which includes a function import.
  2. In a Cloud SDK app, generate an odata client using below command as explained here. sap-cloud-sdk generate-odata-client -i service-specification/ -o odata-client/
  3. Call the function import from the Cloud SDK app.
  4. When the function import gets called, it falls into then() block, meaning that the call was successful. However, the response object is empty.

Expected behavior Response object should be filled with returned data.

Screenshots Calling the OData function import directly image

Calling function import from Cloud SDK app (delivery data should be returned between {}) image

Used Versions:

  • node version via node -v: 12.16.1
  • npm version via npm -v: 6.14.4
  • SAP Cloud SDK version you used as dependency: 1.31.0

Code Examples My controller code is as below.

import { Controller, Get } from '@nestjs/common';
import { functionImports } from 'odata-client/catalog-service';


@Controller('get-delivery')
export class GetDeliveryController {
    @Get()
    getDeliveryInfo() {
        return new Promise((resolve, reject) => {
            functionImports.getDeliveryDate({})
            .execute({
                url: 'http://localhost:4004'                
            })
            .then(res => {
                resolve('Function call successful: ' + JSON.stringify(res))
            })
            .catch(error => {
                resolve('Error occurred: ' + JSON.stringify(error))
            })
        })
    }
}

Log file No error has occurred.

Additional context None

Please check the following points

  • [X ] Have you provided detailed description about your issue?
  • [X ] Have you shared all the necessary information to help the cloud-sdk developer reproduce the issue?
  • [ X] Have you provided the expected behaviour?
  • [ X] Have you attached some useful screenshots?
  • [ X] Have you provided the node/npm/cloud-sdk versions?
  • [ X] Have you shared your code snippets as a minial example?
  • Have you provided you log file or related error messages?
  • [ X] Have you searched for related issues on Stackoverflow or answers.sap.com?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
ZhongpinWangcommented, Apr 25, 2022

Hi @miyasuta, @gregorwolf, @zfrk,

We implemented the feature in @sap-cloud-sdk/odata-common: 2.3.0 to support the modification of the response data before deserialization.

Take the following response as an example:

{
  "d": {
    "GetAttachmentCount": {
      "AttachmentCount": 0
    }
  }
}

Now, you can pass dataAccessor function as a parameter to execute() to modify the response data before the deserialization:

functionImportsRequestBuilder.execute(
  destination,
  data => data.d.GetAttachmentCount
);

I hope it can help you solve the problem. Please re-open the issue if you have any further questions.

Best regards, Zhongpin Wang

0reactions
zfrkcommented, Feb 3, 2022

Hi @jjtang1985 ,

I had the same kind of issue as @gregorwolf on prem system.

deserializeComplexType(yourResponse.data.d.GetAttachmentCount, YourComplexType)

This is solved my problem, I got the result as I wanted.

image

Do you consider applying this to the “execute Function” ?

Regards,

Zafer

Read more comments on GitHub >

github_iconTop Results From Across the Web

SAP Cloud SDK: How to call a function import?
When funcGetDeliveryDate gets called, it falles into then() block, meaning that the call was successful. However, the response object is empty.
Read more >
SAPUI5 Function import usage - SAP Community
Hello, My colleague has implemented Function Import which downloads ... read instead of callFunction returned object had only empty fields.
Read more >
Module @sap/cloud-sdk-core
Returns an access token that can be used to call the given service. The token is fetched via a client credentials grant with...
Read more >
FluentHelperFunction (SAP Cloud SDK - Parent POM 3.3.1 API)
Returns : A list of the objects returned by the function call. Returns an empty list if the function did not return a...
Read more >
Module @sap/cloud-sdk-core
Internal representation of all parameters of a function import as a map ... Takes a JSON object returned by any of the calls...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found