cancel
Showing results for 
Search instead for 
Did you mean: 

how to obtain sql query result in JavaScript

Former Member
0 Kudos

hello, i want to know if this is possible : i have a Javascript function that make this:


var szPLANT = document.getElementById("hid_Plant").value;
   var szLINE = document.brs_Line.getSelectedItem();
   var cell = document.brs_Cell.getSelectedItem();
   var GetLineDownload = document.GetLineDownload.getQueryObject();
   document.GetLineDownload.getQueryObject().setParam(1,szLINE);
   document.GetLineDownload.getQueryObject().setParam(2,cell);
   document.GetLineDownload.executeCommand(); 

but i to catch the result of the sql ...to use in another things in this function...how to to this?..like this:

 result = document.GetLineDownload.results

regards

Mário

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Mario,

After passing parameters you need to use either one of the metod:

document.GetLineDownload.refresh();
            OR
document.GetLineDownload.update(true);

You can use grid to display the results. If you want to see the particular cell value results use as below

document.GRIDAPPLET.getGridObject().getCellValue(ROWNUMBER,COLNUMBER);

You can refer Javascript Assistant available.

-Suresh

Former Member
0 Kudos

i think that you dont understand my problem i have this code:


var szPLANT = document.getElementById("hid_Plant").value;
var szLINE = document.brs_Line.getSelectedItem();
var cell = document.brs_Cell.getSelectedItem();
var GetLineDownload = document.GetLineDownload.getQueryObject();
document.GetLineDownload.getQueryObject().setParam(1,szLINE);
document.GetLineDownload.getQueryObject().setParam(2,cell);
document.GetLineDownload.executeCommand(); 

i catch the values and then pass it to the parameters of my sql query...now i want to receive the result of this sql query...after the executeCommand and use this result in a job...previous the job works fine because receive the linenumber in final result...now i have the szLINE and cell and after passing the values i want to receive the linenumber in good format again..

regards and thanks one more time

Mário

Former Member
0 Kudos

im sorry my explaination was wrong i have an applet that runs an sql query that receive that parameters so...i want to put the result of the applet in a variable

regards

Mário

Former Member
0 Kudos

Mario,

your script suggests that you are using a iCommand query. The iCommand is used to execute a query that does not return a value, like an update, insert or delete query.

If you are expecting a result, you would normally use an iGrid, and then you can use the functions that Suresh proposed to read out the result cells. If you do not want the iGrid to be displayed, but only need the values in your JavaScript, then you can omit the "DisplayTemplate" parameter in your iGrid so it won't be displayed on the web page.

You can however read the values from the iCommand also by using the function "iCommand.getValue(Col, Row)".

Please have a look at [http://help.sap.com/saphelp_xmii120/helpdata/en/44/d91ad2d06f3ee2e10000000a114a6b/content.htm].

Michael

Edited by: Michael Otto on Nov 13, 2009 1:25 PM

Former Member
0 Kudos

thanks a lot..i already looking for that stuff in the Sap Mii iCommando help

regards and thanks for the help

Mário

Former Member
0 Kudos

It's a bit different approach, but take a look at [this thread.|] It uses AJAX to get the query results, and through the results into a JS object.

Former Member
0 Kudos

Ryan,

thanks for this idea. I found an interesting blog from Abesh about this: [AJAX + xMII Illuminator Services = A Database Browser !|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6003] [original link is broken] [original link is broken] [original link is broken];. It helped me to do some first steps with Ajax and MII.

Michael

Former Member
0 Kudos

hi, i have this code:


var szPLANT = document.getElementById("hid_Plant").value;
var szLINE = document.brs_Line.getSelectedItem();
var cell = document.brs_Cell.getSelectedItem();

var GetLineDownload = document.GetLineDownload.getQueryObject();
document.GetLineDownload.getQueryObject().setParam(1,szLINE);
document.GetLineDownload.getQueryObject().setParam(2,cell);
document.GetLineDownload.executeCommand();
var result = document.GetLineDownload.getValue(1,1);

the variable result is always empty to i have to make an refresh or update?

regards

Mário

Former Member
0 Kudos

Check the values of document.GetLineDownload.getRowCount() and document.GetLineDownload.getColumnCount() to confirm that the data is being received properly. Also check document.GetLineDownload.queryObject().getStatusMessage().

Former Member
0 Kudos

Try using this statement.

document.GetLineDownloadt.getFirstValue("<Column Name>").

Ram

Answers (1)

Answers (1)

Former Member
0 Kudos

Mario,

think this is solved now! Talk to Ricardo.

Cheers.

Pedro