Wednesday, 9 December 2015

a query with multiple datasource

public void lookup(FormControl _formControl, str _filterStr)
{
    Query                       query = new Query();
    QueryBuildDataSource        qbds;
    QueryBuildDataSource        qbdsJoin;
    SysTableLookup              sysTableLookup;
    CompanyInfo                 CompanyInfo;
   // super(_formControl, _filterStr);
    changeCompany(DMS_IMEIDelinkingTable.DataArea)
    {
        select firstOnly DMSDivisionCode
            from CompanyInfo
                where CompanyInfo.DataArea == DMS_IMEIDelinkingTable.DataArea;
        sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), _formControl);

        qbds = query.addDataSource(tableNum(InventTable));
        qbdsJoin = qbds.addDataSource(tableNum(DmsSkuDetailsTable));
        qbds.relations(false);
        qbds.fields().dynamic(NoYes::Yes);
        qbdsJoin.addLink( fieldNum(InventTable, ItemId),fieldNum(DmsSkuDetailsTable, ProductCode));
        qbdsJoin.joinMode(JoinMode::InnerJoin);
        qbdsJoin.addRange(fieldNum(DmsSkuDetailsTable,DivisionCode)).value(CompanyInfo.DMSDivisionCode);
        qbdsJoin.addOrderByField(fieldnum(DmsSkuDetailsTable, ProductCode));
        sysTableLookup.addLookupField(fieldnum(InventTable, ItemId));
        sysTableLookup.addLookupField(fieldnum(InventTable, NameAlias));
        qbds.orderMode(OrderMode::GroupBy);
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }
}

No comments:

Post a Comment

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...