1

このコードは、すべてのAXシステム(アイテムと倉庫の変更)で実行できる必要があります。問題は、CustInvoiceJourが時々返されないことです。奇妙なことに、同じ関係で「select custInvoiceJour」を実行すると、それが見つかりますか?これはどのように可能ですか?

static void Job59(Args _args)
{
    CustInvoiceTrans            custInvoiceTrans;
    CustInvoiceJour             custInvoiceJour;
    InventTable             inventTable;
    QueryBuildRange             rangeItem;
    Query                       query;
    QueryBuildDataSource        qbds1;
    QueryBuildDataSource        qbds2;
    QueryBuildDataSource        qbds3;
    QueryRun                    qr;
    ;

    query = new Query();
    qbds1 = query.addDataSource(tablenum(CustInvoiceTrans));
    qbds2 = qbds1.addDataSource(tablenum(CustInvoiceJour));
    qbds2.relations(true);

    qbds2.addRange(fieldnum(CustInvoiceJour, SalesType)).value('!' + enum2str(SalesType::ReturnItem));
    rangeItem = qbds1.addRange(fieldnum(CustInvoiceTrans, ItemId));
    qbds1.addRange(fieldnum(CustInvoiceTrans, InvoiceDate)).value(queryRange(@'8/1/2011', @'8/31/2011'));
    qbds2.orderMode(OrderMode::OrderBy);
    qbds2.addOrderByField(fieldnum(CustInvoiceJour, DlvCountryRegionId));
    qbds2.addOrderByField(fieldnum(CustInvoiceJour, DlvState));
    qbds3 = qbds1.addDataSource(tablenum(InventDim));
    qbds3.relations(true);
    qbds3.joinMode(JoinMode::ExistsJoin);
    qbds3.addRange(fieldnum(InventDim, InventLocationId)).value(SysQuery::value('FG'));


    select firstonly inventTable
        where inventTable.ItemId    == '44831';

    info (strfmt("%1", inventTable.ItemId));
    rangeItem.value(inventTable.ItemId);

    qr = new QueryRun(query);
    while (qr.next())
    {
        custInvoiceTrans    = qr.get(tablenum(CustInvoiceTrans));
        custInvoiceJour     = qr.get(tablenum(CustInvoiceJour));

        if (!custInvoiceJour)
        {
            info ("Not found");
            select firstonly custInvoiceJour
                where custInvoiceJour.SalesId               == custInvoiceTrans.SalesId     &&
                      custInvoiceJour.InvoiceId             == custInvoiceTrans.InvoiceId   &&
                      custInvoiceJour.InvoiceDate           == custInvoiceTrans.InvoiceDate &&
                      custInvoiceJour.numberSequenceGroup   == custInvoiceTrans.numberSequenceGroup;
            if (custInvoiceJour)
                info("Found it");
        }
    }
}

デバッガーはこれらをクエリとして表示します。

NAME:
    qbds1
VALUE:
    SELECT * FROM CustInvoiceTrans ORDER BY CustInvoiceJour.DlvCountryRegionId ASC, CustInvoiceJour.DlvState ASC WHERE ((ItemId = N'44831')) AND ((InvoiceDate>={ts '2011-08-01 00:00:00.000'} AND InvoiceDate<={ts '2011-08-31 00:00:00.000'})) EXISTS JOIN * FROM InventDim WHERE CustInvoiceTrans.InventDimId = InventDim.inventDimId AND ((InventLocationId = N'FG'))

NAME:
    qbds2
VALUE:
    SELECT * FROM CustInvoiceJour WHERE CustInvoiceTrans.SalesId = CustInvoiceJour.SalesId AND CustInvoiceTrans.InvoiceId = CustInvoiceJour.InvoiceId AND CustInvoiceTrans.InvoiceDate = CustInvoiceJour.InvoiceDate AND CustInvoiceTrans.numberSequenceGroup = CustInvoiceJour.numberSequenceGroup AND ((NOT (SalesType = 4)))


NAME:
    qbds3
VALUE:
    SELECT * FROM InventDim WHERE CustInvoiceTrans.InventDimId = InventDim.inventDimId AND ((InventLocationId = N'FG'))
4

1 に答える 1

2

qbds1の値が表示されませんJOIN * FROM CustInvoiceJour WHERE ...(qbds2に参加しました)。

コードに追加qbds2.fetchMode(QueryFetchMode::One2One);すれば、すべて問題ないはずです。

PS逆に行うことをお勧めします。qbds1のCustInvoiceJourとqbds2のCustInvoiceTrans(デフォルトのfetchModeを使用)の場合、この問題はまったく発生しません。

于 2012-09-08T00:39:31.790 に答える