Customised Look up methods:

Hi,
Usage of Look up methods:
Customized lookup methods:

Lookup using temporary table:

public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource qds1;
QueryBuildDataSource qds2;
QueryBuildRange qr1;
QueryBuildRange qr2;
QueryBuildRange qr3;
SysTableLookup sysTableLookup;
VendInvoiceJour VendInvoiceJour;
WHT_WithholdingTaxTrans WHT_WithholdingTaxTrans;
WHT_KRALookuptable WHT_KRALookuptable;
QueryRun qr;
;

delete_from WHT_KRALookuptable;
qds1 = query.addDataSource(tableNum(VendInvoiceJour));
qds2 = qds1.addDataSource(tableNum(WHT_WithholdingTaxTrans));
qds2.joinMode(JoinMode::InnerJoin);
qds2.addLink(fieldNum(WHT_WithholdingTaxTrans,Invoice), fieldNum(VendInvoiceJour,InvoiceId));
qds2.addLink(fieldNum(WHT_WithholdingTaxTrans,InvoiceAccount), fieldNum(VendInvoiceJour,InvoiceAccount));
qr1 = qds1.addRange(fieldNum(VendInvoiceJour, InvoiceAccount));
qr1.value(WHT_KRAreceiptUpdate.AccountNum);
qr2 = qds2.addRange(fieldNum(WHT_WithholdingTaxTrans, WHT_KRAStatus));
qr2.value(int2str(WHT_KRAStatus::Paid));
qr3 = qds2.addRange(fieldNum(WHT_WithholdingTaxTrans,WHT_DTA));
qr3.value(int2str(NoYes::No));
qr = new QueryRun(query);
while (qr.next())
{
VendInvoiceJour = qr.get(tablenum(VendInvoiceJour));
select WHT_KRALookuptable
where WHT_KRALookuptable.InvoiceId == VendInvoiceJour.InvoiceId
&& WHT_KRALookuptable.InvoiceAmount == VendInvoiceJour.InvoiceAmount;
if (!WHT_KRALookuptable)
{
select sum(WithholdingTaxAmount) from WHT_WithholdingTaxTrans
group by InvoiceAccount,Invoice
where WHT_WithholdingTaxTrans.InvoiceAccount == VendInvoiceJour.InvoiceAccount
&& WHT_WithholdingTaxTrans.Invoice == VendInvoiceJour.InvoiceId;
if (WHT_WithholdingTaxTrans)
{
WHT_KRALookuptable.WithholdingTaxAmount = WHT_WithholdingTaxTrans.WithholdingTaxAmount;
}
WHT_KRALookuptable.InvoiceId = VendInvoiceJour.InvoiceId;
WHT_KRALookuptable.InvoiceAmount = VendInvoiceJour.InvoiceAmount;
WHT_KRALookuptable.AccountNum = VendInvoiceJour.InvoiceAccount;
WHT_KRALookuptable.insert();
}
}
sysTableLookup = SysTableLookup::newParameters(tableNum(WHT_KRALookuptable),_formControl);
sysTableLookup.addLookupField(fieldNum(WHT_KRALookuptable, InvoiceId));
sysTableLookup.addLookupField(fieldNum(WHT_KRALookuptable, InvoiceAmount));
sysTableLookup.addLookupField(fieldNum(WHT_KRALookuptable, WithholdingTaxAmount));

//sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

Lookup using links

public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource qds1;
QueryBuildDataSource qds2;
QueryBuildRange qr1;
QueryBuildRange qr2;
QueryBuildLink queryBuildLink;
SysTableLookup sysTableLookup ;
WHT_WithholdingTaxTrans WHT_WithholdingTaxTrans;
VendInvoiceJour VendInvoiceJour;
;

select Invoice from WHT_WithholdingTaxTrans;
sysTableLookup = SysTableLookup::newParameters(tableNum(VendInvoiceJour),_formControl);
sysTableLookup.addLookupField(fieldNum(VendInvoiceJour, InvoiceId));
qds1 = query.addDataSource(tableNum(VendInvoiceJour));
qds2 = qds1.addDataSource(tableNum(WHT_WithholdingTaxTrans));
qds2.joinMode(JoinMode::InnerJoin);
qds2.addLink(fieldNum(WHT_WithholdingTaxTrans,Invoice ), fieldNum(VendInvoiceJour,InvoiceId));
qds2.addLink(fieldNum(WHT_WithholdingTaxTrans,InvoiceAccount ), fieldNum(VendInvoiceJour,InvoiceAccount));
qr1 = qds1.addRange(fieldNum(VendInvoiceJour, InvoiceAccount));
qr1.value(WHT_KRAreceiptUpdate.AccountNum);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

Normal lookup methods

void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(PurchLine), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
;

sysTableLookup.addLookupfield(fieldnum(PurchLine, InventTransId));
sysTableLookup.addLookupfield(fieldnum(PurchLine, ItemId));
sysTableLookup.addLookupfield(fieldnum(PurchLine, PurchUnit));
sysTableLookup.addLookupfield(fieldnum(PurchLine, LineAmount));
sysTableLookup.addLookupfield(fieldnum(PurchLine, RemainPurchPhysical));

queryBuildDataSource = query.addDataSource(tablenum(PurchLine));
queryBuildDataSource.addRange(fieldnum(PurchLine,PurchStatus)).value(queryValue(PurchStatus::Backorder));
queryBuildDataSource.addRange(fieldnum(PurchLine,PurchId)).value(purchTable.PurchId);
queryBuildDataSource.addRange(fieldnum(PurchLine,RemainPurchPhysical)).value(‘>0’);

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

In form datasource methods:

public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource queryDataSourceCode;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup;
TaxWithholdGroupData TaxWithholdGroupData;
str st;
;
if(LedgerJournalTrans.TaxWithholdGroup)
{
while select TaxWithholdGroupData where TaxWithholdGroupData.TaxWithholdGroup==LedgerJournalTrans.TaxWithholdGroup
{
if(st)
st=st+’,’+TaxWithholdGroupData.TaxWithholdCode;
else
st=TaxWithholdGroupData.TaxWithholdCode;
}
sysTableLookup=SysTableLookup::newParameters(tableNum(TaxWithholdTable),_formControl);
sysTableLookup.addLookupField(fieldNum(TaxWithholdTable, TaxWithholdCode));
sysTableLookup.addLookupField(fieldNum(TaxWithholdTable, TaxWithholdName));
queryDataSourceCode = query.addDataSource(tableNum(TaxWithholdTable));
queryBuildRange = queryDataSourceCode.addRange(fieldNum(TaxWithholdTable, TaxWithholdCode));
queryBuildRange.value(st);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
}

In form design methods:

public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(TaxWithholdTable), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
;

sysTableLookup.addLookupfield(fieldnum(TaxWithholdTable, TaxWithholdCode));
sysTableLookup.addLookupfield(fieldnum(TaxWithholdTable, TaxWithholdName));

queryBuildDataSource = query.addDataSource(tablenum(TaxWithholdTable));

queryBuildDataSource.addRange(fieldnum(TaxWithholdTable,TaxWithholdCode)).value(strfmt(‘!=%1’,TaxWithholdTable.TaxWithholdCode));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s