woensdag 18 mei 2011

Form DataSource Query: show Select statements

Add these 2 methods to the Global Class:

public static void showFormQueries(FormRun _fr)
{
    Counter         dsCount = _fr.dataSourceCount();
    Counter         c;
    Name            frName = _fr.name();
    ;
    setPrefix(strfmt("@SYS76681", "@SYS6890", frName, strfmt("@SYS76498", dsCount, strlwr(dsCount==1?"@SYS56294":"@SYS26774"))));
    for (c=1; c <= dsCount; c++)
        showFormDataSourceQuery(_fr.dataSource(c));
}

public static void showFormDataSourceQuery(FormDataSource _fds)
{
    Name    fdsName     = _fds.name();
    Name    tableName   = tableId2Name(_fds.table());
    ;
    setPrefix(strfmt("%1%2", fdsName, (fdsName!=tableName)?strfmt(" (%1: %2)", "@SYS8868", tableName):""));
    info(_fds.query().dataSourceNo(1).toString());
}

 

As an example,  we can use it in the form SalesTable.run method:

void  run()
{
    int designatedTabNo = 1;
    ;

    if (!advanced)
    {
        designatedTabNo = 2;
    }
    else if (this.isCalledFromListPage())
    {
        designatedTabNo = 3;
    }

    SysListPageHelper::handleRunPreSuper(element, tabHeader, designatedTabNo, designatedTabNo);
    super();
    SysListPageHelper::handleRunPostSuper(element, tabHeader);
    global::aduShowFormQueries(element);
}

Which yields:

Form SalesTable (11 data sources)
SalesTable
    SELECT * FROM SalesTable USING INDEX SalesIdx WHERE ((NOT (ReturnStatus = 4) AND NOT (ReturnStatus = 1)))
SalesLine
    SELECT * FROM SalesLine USING INDEX SalesLineIdx WHERE ((((SalesLine.ReturnStatus != 1) || (SalesLine.ExpectedRetQty < 0)&&(SalesLine.ReturnStatus == 1)))) AND SalesTable.SalesId=SalesLine.SalesId JOIN * FROM InventDim WHERE SalesLine.InventDimId = InventDim.inventDimId
InventDim
    SELECT * FROM SalesLine USING INDEX SalesLineIdx WHERE ((((SalesLine.ReturnStatus != 1) || (SalesLine.ExpectedRetQty < 0)&&(SalesLine.ReturnStatus == 1)))) AND SalesTable.SalesId=SalesLine.SalesId JOIN * FROM InventDim WHERE SalesLine.InventDimId = InventDim.inventDimId
InterCompanyPurchSalesReference
    SELECT * FROM InterCompanyPurchSalesReference WHERE SalesTable.SalesId=InterCompanyPurchSalesReference.SalesId JOIN * FROM PurchTable WHERE InterCompanyPurchSalesReference.PurchId = PurchTable.PurchId
PurchTable_Reference (Table: PurchTable)
    SELECT * FROM InterCompanyPurchSalesReference WHERE SalesTable.SalesId=InterCompanyPurchSalesReference.SalesId JOIN * FROM PurchTable WHERE InterCompanyPurchSalesReference.PurchId = PurchTable.PurchId
SalesTable_Reference (Table: SalesTable)
    SELECT * FROM SalesTable WHERE ((SalesId = N'PO000024'))
ShipCarrierAddress (Table: Address)
    SELECT FIRSTONLY * FROM Address USING INDEX TypeIdx WHERE ((type = 11)) AND SalesTable.RecId=Address.AddrRecId AND SalesTable.TableId=Address.AddrTableId
ShipCarrierAddressInLine (Table: Address)
    SELECT FIRSTONLY * FROM Address USING INDEX TypeIdx WHERE ((type = 11)) AND SalesLine.RecId=Address.AddrRecId AND SalesLine.TableId=Address.AddrTableId
DPInventSum (Table: InventSum)

DPInventDim (Table: InventDim)

ADUPriceDiscDetail1 (Table: ADUPriceDiscDetail)
    SELECT * FROM ADUPriceDiscDetail WHERE SalesLine.ADUPriceDiscDetailId=ADUPriceDiscDetail.ADUPriceDiscDetailId

Geen opmerkingen:

Een reactie plaatsen