Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: How to get the JSON output format from an procedure call using XSJS

$
0
0

Just a little preview that in SP9, not of this processing will be necessary. We have a new library that is already finished and will ship in SP9 called XSProcedures. It simplifies calling stored procedures from XSJS and allows the use of JSON for input parameter tables. It also returns all results not as Record Set objects but as JSON.

 

Here is an example from the content we will teach at TechEd && d-code this year:

 

 

$.import("sap.hana.xs.libs.dbutils", "procedures");
var XSProc = $.sap.hana.xs.libs.dbutils.procedures;
XSProc.setTempSchema($.session.getUsername().toUpperCase());
function getAddressesByRole() {
var partnerRole = $.request.parameters.get("PartnerRole").toUpperCase();  var conn = $.db.getConnection();



//*********************************************
//     Call procedure using the xsProcedure API
//*********************************************



var getBpAddressesByRole = XSProc.procedureOfSchema("SAP_HANA_EPM_NEXT",
           "sap.hana.democontent.epmNext.procedures::get_bp_addresses_by_role");    var results = getBpAddressesByRole( { IM_PARTNERROLE: partnerRole}, conn );
//You can reference the output parameter directly as well ... results.EX_BP_ADDRESSES    var jsonOut = results;   //You can reference the output parameter directly as well ... results.EX_BP_ADDRESSES    conn.close();






// Pass output to response

$.response.status = $.net.http.OK;

$.response.contentType = "application/json";

$.response.setBody(JSON.stringify(jsonOut));
}

Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>