Hi All,

Please find the below code specially who is working on server side java script using this program you can easily download the data from the cloud.

$.import(“sap.hana.democontent.epm.services”,”messages”);

var MESSAGES=$.sap.hana.democontent.epm.services.messages;

function performMultiply(){

var body=”;

var num1 = $.request.parameters.get(‘num1’);

var num2 = $.request.parameters.get(‘num2’);

var answer;

answer = num1 * num2;      

body = answer.toString();

$.response.setBody(body);

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

}

function downloadExcel(){ 

    var body = ”;  

    var query = ‘SELECT TOP 500 \”TextId\”,\”Language\”,\”ISOLanguage\”, \”Text\”‘

     + ‘FROM \”SAP_HANA_EPM_DEMO\”.\”sap.hana.democontent.epm.data::texts” order by \”TextId\”‘; 

 

    $.trace.debug(query); 

    var conn = $.db.getConnection(); 

    var pstmt = conn.prepareStatement(query); 

    var rs = pstmt.executeQuery(); 

 

    body = “TextId \tLanguage \tISOLanguage \tText\n”; 

 

   while(rs.next())

   { 

        body += rs.getString(1)+ 

“\t”+rs.getString(2)+”\t”+rs.getString(3)+”\t”+rs.getString(4)+”\n”; 

    } 

 

    $.response.setBody(body);     

    $.response.contentType = ‘application/vnd.ms-excel; charset=utf-16le’; 

    $.response.headers.set(‘Content-Disposition’,’attachment; filename=Excel.xls’); 

    $.response.headers.set(‘access-control-allow-origin’,’*’); 

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

var  aCmd  =  $.request.parameters.get(‘cmd’);

switch  (aCmd)  {

case  “multiply”:

performMultiply();

break;

case “Excel”:

           downloadExcel();

           break;

default:

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

// $.response.setBody(‘Invalid  Command:  ‘+aCmd);

$.response.setBody(MESSAGES.getMessage(‘SEPM_ADMIN’,’002′,aCmd));

}

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply