cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass query result to HTML table?

Former Member
0 Kudos

Hi,

i want to get the query result in HTMl table instead of Display Grid. how to do it? i searched in help, it suggests use icommand to do this. but i dont know how to pass the select query result to HTML table.. please help me.

-senthil

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Senthil,

You can create an icommand query. You can then use the icommand retrieval methods to capture and manipulate the query data.

(http://help.sap.com/saphelp_xmii115/helpdata/en/Applet_Reference_Details/iCom

mand_Reference.htm)

Basically what we did was, use the getColumnCount() and getRowCount() methods, once you have these two numbers you can set two for loops and use String getValue(int ColID, int RowID) , within the for loops you can generate the inner html content and write the values either in a html table or html form (which is what we did). This seems to work well, I'm still playing around with it and may post this approach on sdn by end of this week.

Mahwish

Former Member
0 Kudos

You find better performance if you use the SERVLET as it delivers html to the browser directly. Using an iCommand requires an extra round trip and then manipulation via JavaScript on the client side.

Former Member
0 Kudos

Hi,

i tried with this method. i created applet by using icommand. then i tried this method. but it doesnt deliver any tables. if i have rowcount=5, column count =3 means i gave as

document.write("<table border=1>")

document.write("<tr><th>ID1</th><th>ID2</th></tr>")

for(i=1;i<=rowcount;i++)

{

document.write("<tr>")

for(j=1;j<=columncount;j++)

{

document.write("<td>"myapplet.getValue(i,j)"</td>")

}

document.write("</tr>")

}

document.write("</table>")

}

but no output here. only column heading only printed. even for thsi also it needs to refresh the page. and it display at top of the page..

how to solve it?

-senthil

Former Member
0 Kudos

When I wish to direct the results of a query directly to HTML table, I create a SQL query and push the results to an XSL stylesheet. The actual HTML code is simple:

<servlet name="Illuminator">

<param name="QueryTemplate"value="MyCompanyName/sqlShowData">

<param name="Stylesheet" value="http://localhost/MyCompanyName/SQLToHTMLForm.xsl">

</servlet>

There are a few example XSL stylesheets that come pre-installed with xMII that you can use for reference.

Former Member
0 Kudos

Hi Senthil,

Instead of document.write you can use tablename.insertRow() and tablename.insertCell() methods. we did it like the following, but our requirement was to output to a form element do you'll have to tweak:

for (i=1; i<=rowcnt; i++)

{

var rownum = tabname.insertRow()

for (j=1; j<colcnt; j++)

{

var valx = document.qry.getValue(i, j)

var addCell = rownum.insertCell(j-1)

addcell.innerHTML = "<input type='text' id='txt1', name='emp'" +valx +">"

}

}

Former Member
0 Kudos

Hi Senthil,

You'll want to use the SERVLET instead of an Applet. Check out this link in the help docs for more information,

http://help.sap.com/saphelp_xmii115/helpdata/en/Advanced_Topics/Customizing_Output/Customizing_Outpu...

The SERVLET will basically take the XML output from a query and transform it using XSL (that you can create) to generate any output format including a basic HTML table.