Sysda Classes with example
class RunnableClass1
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
//SysDa insetopertaion includes using two API's
//SysDainsertobject - used to create insert_recordset statement
//SysDainsertstatement - used to perform insert_recordset operation
//sample query
//insert_recordset CustomRDPTmpTable(AccountNum, BankAccount, ContactPersonId, CustGroup, Currency)
//select AccountNum, BankAccount, ContactPersonId, CustGroup, Currency from CustTable
//where CustTable.AccountNum == 'BRMF-000001'
public static void main(Args _args)
{
//first part- using sysdainsertobject
//Target table
CustomRDPTmpTable customtable;
//initialize sysdainsertobject
var insertobject = new SysDaInsertObject(customtable);
//add fields to be inserted in target table
insertobject.fields()
.add(fieldStr(CustomRDPTmpTable, AccountNum))
.add(fieldStr(CustomRDPTmpTable, BankAccount))
.add(fieldStr(CustomRDPTmpTable, ContactPersonId))
.add(fieldStr(CustomRDPTmpTable, Currency))
.add(fieldStr(CustomRDPTmpTable, CustGroup));
//insert_recordset CustomRDPTmpTable(AccountNum, BankAccount, ContactPersonId, CustGroup, Currency)
//Second part- creating select statement using SysDaqueryobject
//source table
CustTable custtable;
//intialize sysdaqueryobject
var qe = new SysDaQueryObject(custtable);
//select fields from source table
//select AccountNum, BankAccount, ContactPersonId, CustGroup, Currency from CustTable
var s1 = qe.projection()
.add(fieldStr(CustTable, AccountNum))
.add(fieldStr(CustTable, BankAccount))
.add(fieldStr(CustTable, ContactPersonId))
.add(fieldStr(CustTable, Currency))
.add(fieldStr(CustTable, CustGroup));
//adding where clause
qe.whereClause(new SysDaEqualsExpression(
new SysDaFieldExpression(custtable, fieldStr(CustTable, AccountNum)),
new SysDaValueExpression('BRMF-000001')));
//now select query is complete
//select AccountNum, BankAccount, ContactPersonId, CustGroup, Currency from CustTable
//where CustTable.AccountNum == 'BRMF-000001'
//third part - Assign the query to insert statement
insertobject.Query(qe);
//fourth part - using SysDainsetstatement
//execute the query using executequery method
var insertstatement = new SysDaInsertStatement();
ttsbegin;
insertstatement.executeQuery(insertobject);
ttscommit;
//printing target values
CustomRDPTmpTable customloc;
select * from customloc where AccountNum == 'BRMF-000001';
Info(any2Str(customloc.AccountNum) + " " + any2Str(customloc.Currency) + " " + any2Str(customloc.CustGroup));
}
}
containerLineQueryObject.whereClause(new SysDaEqualsExpression(
new SysDaFieldExpression(containerLineInventDim, fieldStr(InventDim, InventDimId)),
new SysDaFieldExpression(_containerLine, fieldStr(WHSContainerLine, InventDimId)))
.and(new SysDaEqualsExpression(
new SysDaFieldExpression(containerLineInventDim, fieldStr(InventDim, InventStatusId)),
new SysDaFieldExpression(_loopInventDim, fieldStr(InventDim, InventStatusId)))));
------------------------------------------------------------------------------------------------------
For the Update_recordset, you’ll create QueryObjects the same as Insert_recordset(), and pass that to a update object and setup the ‘settingClause’. This will also need to be extended.
AllFieldTypesTable source;
var qe = new SysDaQueryObject(Source);
var uo = new SysDaUpdateObject(source);
uo.settingClause()
.add(fieldStr(AllFieldTypesTable, Id), new SysDaPlusExpression(new SysDaFieldExpression(source, fieldStr(AllFieldTypesTable, Id)), new SysDaValueExpression(100)))
.add(fieldStr(AllFieldTypesTable, String), new SysDaValueExpression("Banana"));
new SysDaUpdateStatement().execute(uo);
class RunnableClass1
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
//SysDa insetopertaion includes using two API's
//SysDainsertobject - used to create insert_recordset statement
//SysDainsertstatement - used to perform insert_recordset operation
//sample query
//insert_recordset CustomRDPTmpTable(AccountNum, BankAccount, ContactPersonId, CustGroup, Currency)
//select AccountNum, BankAccount, ContactPersonId, CustGroup, Currency from CustTable
//where CustTable.AccountNum == 'BRMF-000001'
public static void main(Args _args)
{
//first part- using sysdainsertobject
//Target table
CustomRDPTmpTable customtable;
//initialize sysdainsertobject
var insertobject = new SysDaInsertObject(customtable);
//add fields to be inserted in target table
insertobject.fields()
.add(fieldStr(CustomRDPTmpTable, AccountNum))
.add(fieldStr(CustomRDPTmpTable, BankAccount))
.add(fieldStr(CustomRDPTmpTable, ContactPersonId))
.add(fieldStr(CustomRDPTmpTable, Currency))
.add(fieldStr(CustomRDPTmpTable, CustGroup));
//insert_recordset CustomRDPTmpTable(AccountNum, BankAccount, ContactPersonId, CustGroup, Currency)
//Second part- creating select statement using SysDaqueryobject
//source table
CustTable custtable;
//intialize sysdaqueryobject
var qe = new SysDaQueryObject(custtable);
//select fields from source table
//select AccountNum, BankAccount, ContactPersonId, CustGroup, Currency from CustTable
var s1 = qe.projection()
.add(fieldStr(CustTable, AccountNum))
.add(fieldStr(CustTable, BankAccount))
.add(fieldStr(CustTable, ContactPersonId))
.add(fieldStr(CustTable, Currency))
.add(fieldStr(CustTable, CustGroup));
//adding where clause
qe.whereClause(new SysDaEqualsExpression(
new SysDaFieldExpression(custtable, fieldStr(CustTable, AccountNum)),
new SysDaValueExpression('BRMF-000001')));
//now select query is complete
//select AccountNum, BankAccount, ContactPersonId, CustGroup, Currency from CustTable
//where CustTable.AccountNum == 'BRMF-000001'
//third part - Assign the query to insert statement
insertobject.Query(qe);
//fourth part - using SysDainsetstatement
//execute the query using executequery method
var insertstatement = new SysDaInsertStatement();
ttsbegin;
insertstatement.executeQuery(insertobject);
ttscommit;
//printing target values
CustomRDPTmpTable customloc;
select * from customloc where AccountNum == 'BRMF-000001';
Info(any2Str(customloc.AccountNum) + " " + any2Str(customloc.Currency) + " " + any2Str(customloc.CustGroup));
}
}
containerLineQueryObject.whereClause(new SysDaEqualsExpression(
new SysDaFieldExpression(containerLineInventDim, fieldStr(InventDim, InventDimId)),
new SysDaFieldExpression(_containerLine, fieldStr(WHSContainerLine, InventDimId)))
.and(new SysDaEqualsExpression(
new SysDaFieldExpression(containerLineInventDim, fieldStr(InventDim, InventStatusId)),
new SysDaFieldExpression(_loopInventDim, fieldStr(InventDim, InventStatusId)))));
------------------------------------------------------------------------------------------------------
For the Update_recordset, you’ll create QueryObjects the same as Insert_recordset(), and pass that to a update object and setup the ‘settingClause’. This will also need to be extended.
AllFieldTypesTable source;
var qe = new SysDaQueryObject(Source);
var uo = new SysDaUpdateObject(source);
uo.settingClause()
.add(fieldStr(AllFieldTypesTable, Id), new SysDaPlusExpression(new SysDaFieldExpression(source, fieldStr(AllFieldTypesTable, Id)), new SysDaValueExpression(100)))
.add(fieldStr(AllFieldTypesTable, String), new SysDaValueExpression("Banana"));
new SysDaUpdateStatement().execute(uo);