-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] Enhanced Usability for SAP JCo Function Execution in Ballerina with Multiple Parameters #6783
[Proposal] Enhanced Usability for SAP JCo Function Execution in Ballerina with Multiple Parameters #6783
Comments
When considering the use case for input parameters and output parameters in SAP JCo, the RFC accepts multiple values. To improve usability, we can introduce two functions in Ballerina: public type FieldType string|int|float|decimal|boolean|byte[]|time:Date|time:TimeOfDay|time:Utc|record {|FieldType...;|}|record {|FieldType...;|}[];
isolated remote function execute(string functionName, FieldType? importParams = (), typedesc<FieldType|FieldType[]|map<FieldType>|xml|json?> exportParams = <>) returns exportParams|Error;
isolated remote function executeWithMultipleParams(string functionName, FieldType[]|map<FieldType>? importParams = (), typedesc<FieldType|FieldType[]|map<FieldType>|xml|json?> exportParams = <>) returns exportParams|Error; The execute() function can be used when there is only one input parameter, and executeWithMultipleParams() can be used for multiple values. For the output return, all simple types can be used to bind to specific types: // Returns one string field
string result = check jcoClient->execute("functionName", "a");
// Returns multiple fields in order
FieldType[] results = check jcoClient->execute("functionName", "a");
// Returns multiple fields with parameter names
map<string> resultsMap = check jcoClient->execute("functionName", "a");
// Returns one JCoStructure
record{||} structure = check jcoClient->execute("functionName", "a");
// Returns one JCoStructure with parameter names
map<record{||}> structuresMap = check jcoClient->execute("functionName", "a");
// Returns a table
record{||}[] table = check jcoClient->execute("functionName", "a");
// Returns multiple tables in positional value
record{||}[][] tables = check jcoClient->execute("functionName", "a"); To handle the case where multiple JCoStructures are expected in an array, we introduce a special annotation: public annotation MultiStructure on type;
@MultiStructure
type MultipleValues record{||}[];
MultipleValues _ = check jcoClient->execute("", "a"); This exception addresses potential confusion when the user expects either one return value of table type or multiple JCoStructures in an array. Note on Data Mapping in Ballerina |
This proposal outlines the mapping of JCo data types to Ballerina data types for the SAP JCo Connector. The objective is to ensure accurate and efficient data exchange between SAP systems and Ballerina applications by providing clear and consistent mappings for both import (setters) and export (getters) parameter types.
JCo to Ballerina Data Type Mapping
string
string
string
int
int
int
int
float
decimal
byte[]
boolean
time:Date
time:TimeOfDay
time:Utc
string
string
decimal
string
record {}
record{}[]
The text was updated successfully, but these errors were encountered: