How to specify the table name by using variables to output CSV

Use this Forum to post your “How to …” questions about your use of aXes. This is not a technical support forum. Both the aXes Support Team at LANSA and other aXes customers may answer your questions. LANSA cannot guarantee the accuracy of any information posted by customers.

Moderator: jeanmichel

Post Reply
MegumiSawada
Posts: 3
Joined: 06 Jan 2017, 16:12

How to specify the table name by using variables to output CSV

Post by MegumiSawada »

Hi,

The customer would like to output CSV data from the table using selectSQLcommand like Tutorial 6 - Tables and XML Documents.

They would like to specified the table name by using variables ('B'+JOB number).

Is it possible to specify the name of table (which output CSV data from) by using variables?
If Yes, could you please let me kno how?

e.g.
DefineObjectInstance {
className = "DynamicTable",
name = "Example2",
source = "sql",
selectSQLcommand = "EMPNO, SURNAME FROM DCXPGMLIB.<<File name variables>>",
resultColumnNames = { "TEXT1", "TEXT2" },
};

I appreciate your kind advice.

Best Regards,
Megumi Sawada
User avatar
jeanmichel
Posts: 109
Joined: 23 May 2014, 11:37
Location: Sydney

Re: How to specify the table name by using variables to output CSV

Post by jeanmichel »

The format is the same as how sql variables are defined in WHERE statement.
Example, in tables_dynamic.txt file define the following:
DefineObjectInstance {
className = "DynamicTable",
name = "Example2",
source = "sql",
selectSQLcommand = "EMPNO, SURNAME FROM DCXPGMLIB.:SQLVariableTableName",
resultColumnNames = { "TEXT1", "TEXT2" },
};

In AXES, example, in a button to output CSV, add the following script on its onClick property.
-------------------------------------------------------------------------------------------------------------------------------

var requestdetails = { SQLVariableTableName:"<<table name>>" };
var result = TABLEMANAGER.convertDynamicTable( "Example2", USERENV.dynamicTablesFile, requestdetails );
if (result.error == false)
{
var URL = document.location.protocol + "//" + document.location.host + "/ts/" + result.outputFileName;
window.open(URL,"_blank");
}

-------------------------------------------------------------------------------------------------------------------------------

For dropdown eXtension set the following property:
sqlVariables: ENV.SQL.SQLVariableTableName = "<<table name>>";
Regards,

Jean-Michel Rapin

LANSA Pty Ltd
email: JeanMichel.Rapin@lansa.com.au
Address: 122 Arthur Street, North Sydney, NSW 2060, Australia
Tel: +61 289 070 262 http://www.lansa.com | http://blog.lansa.com |
MegumiSawada
Posts: 3
Joined: 06 Jan 2017, 16:12

Re: How to specify the table name by using variables to output CSV

Post by MegumiSawada »

Hi Jean-Michel,

Thank you for your reply.
The customer has successfully implemented it with your instruction!

Best Regards,
Megumi Sawada
Post Reply