cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Table names from Query

Former Member
0 Kudos

Hi,

I have a Query which display some data in a grid.I want to know the names of the tables from which the data is fetched into the grid by using query.

Thanks And Regards,

Eswar

Accepted Solutions (0)

Answers (1)

Answers (1)

agentry_src
Active Contributor
0 Kudos

Selectively identifying the tables used in the query is not a separate property within the query.

However there is a property (Query) which contains the actual SQL Script of the query. You could probably put some string logic into an expression to extract names following the keywords "From" and "Join". A little complicated, but if your scripts are fairly simple or similar, you could probably put it together pretty easily.

Regards,

Mike

Former Member
0 Kudos

Hi,

You can try this line of code in your page.

document.<applet_name>.getQueryObject().getTables()

Let me know if this works.

Regards,

Gita

Former Member
0 Kudos

Hi Gita,

I tried like as u said.but it is not working.Its giving undefined.

Thanks And Regards

Eswar

jcgood25
Active Contributor
0 Kudos

I think you should be working more closely with your TCS colleague:

Per the other thread you'll see that when using Query mode the portions of the select statement are kept separately and could be retrieved for simple queries. Columns, Tables, FilterExpr, SortExpr, and others would be available to you in the query object (http://help.sap.com/saphelp_mii121/helpdata/en/45/cca31a93696f74e10000000a1553f6/content.htm)

If you are using a FixedQuery you could consider using

[Param.1]

for the FROM clause and then you could simply request document.APPLETNAME.getQueryObject().getParam(1) to retrieve it at runtime, otherwise you will have to parse the Query property string yourself.

Try using

SELECT * FROM [Param.1]

and defaulting the value Employees in the Parameters tab of the Template, then you can easily retrieve this in javascript with the syntax above.