NY Reno
NY Reno

Reputation: 83

Procedure arguments are not passed to SAP CAP application

I have a SAP Cloud Application that is calling procedures. All the procedures that do not have arguments are working well, but I cannot get the procedure with arguments to work. I have narrowed it down to the following lines in my node.js service file:

const ip = [{"PID": PID}, {"CENTERLAT": CENTERLAT}, {"CENTERLONG": CENTERLONG}, {"PTOL": PTOL}, {"ETOL": ETOL}, {"CURRLAT": CURRLAT}, {"CURRLONG": CURRLONG}, {"OPEN_CLOSE": OPEN_CLOSE}, {"LDATE": LDATE}, {"LTIME": LTIME}]
const output = await dbConn.callProcedurePromisified(sp, ip)

The error that I am getting is:

{ code: -20007,
  message: 'Can not bind parameter(0).',
  sqlState: 'HY000' }
[2020-08-28T16:30:32.649Z | ERROR | 1987505]: An error occurred during serialization of the entity collection.
[2020-08-28T16:30:32.649Z | ERROR | 1987505]: Error stacktrace: SerializationError: An error occurred during serialization of the entity collection.

When I console.log ip, I get:

[ { PID: 'ab9359f1-2b72-4a4b-abf2-0295c7913b51' },
  { CENTERLAT: 32.352521 },
  { CENTERLONG: -117.632423 },
  { PTOL: 3.999999 },
  { ETOL: 5 },
  { CURRLAT: 32.321456 },
  { CURRLONG: -117.090456 },
  { OPEN_CLOSE: 'C' },
  { LDATE: '12122059' },
  { LTIME: '121259' } ]

My Procedure definition is:

PROCEDURE "PointPathDistance" (IN PID NVarChar(36),
                               IN CENTERLAT Double,
                               IN CENTERLONG Double,
                               IN PTOL Double
                               IN ETOL Double,
                               IN CURRLAT Double,
                               IN CURRLONG Double,
                               IN OPEN_CLOSE NVarChar(1),
                               IN LDATE NVarChar (8),
                               IN LTIME NVarChar(8),
                               out result "USERLOCATIONS")

Any ideas? Thanks.

Upvotes: 1

Views: 917

Answers (1)

NY Reno
NY Reno

Reputation: 83

I was doing this:

const {PID, CENTERLAT, CENTERLONG, PTOL, ETOL, CURRLAT, CURRLONG, OPEN_CLOSE, LDATE, LTIME} = req.data
const ip = [{"PID": PID}, {"CENTERLAT": CENTERLAT}, {"CENTERLONG": CENTERLONG}, {"PTOL": PTOL}, {"ETOL": ETOL}, {"CURRLAT": CURRLAT}, {"CURRLONG": CURRLONG}, {"OPEN_CLOSE": OPEN_CLOSE}, {"LDATE": LDATE}, {"LTIME": LTIME}]
const output = await dbConn.callProcedurePromisified(sp, req.data)

Basically deconstructing req.data into a code array and passing it into the callProcedurePromisified function.

Then, I thought why not just pass in req.data? as in the following:

const output = await dbConn.callProcedurePromisified(sp, req.data)

It works!!

Upvotes: 1

Related Questions