AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX: Программирование
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 14.11.2006, 11:50   #1  
Cornflower is offline
Cornflower
Участник
 
4 / 10 (1) +
Регистрация: 06.09.2005
Query из 7 таблиц
Добрый день.
Я написала метод для заполнения tmpтаблицы, но у меня почему-то не вытаскиваются данные из таблиц. Получается что когда подцеляю 5 каких-либо все данные есть, подцепляю еще 2, данные не вытаскиваются.... Причем они меняются, то из одной таблицы нет данных, то из других. Я как большой новичек разобраться в чем дело не могу. Приму замечания даже по-поводу правильности синтаксиса. Так как подсказать мне даже в этом некому. У меня 2 варианта, либо я неправильно делаю, либо действительно больше 5 таблиц в query использовать нельзя.
Вот мой код:
static server ERP_tmpMythOLAPPurch CreateTmpTable (TransDate StartDate,
TransDate EndDate,
wfStructStr _ItemKey,
wfStructStr _ItemGroupKey,
wfStructStr _LocationKey,
wfStructStr _ProjectKey,
wfStructStr _SbytNaprKey,
wfStructStr _AccountKey)
{
InventTrans _inventTrans;
InventTable _inventTable;
VendInvoiceTrans _vendInvoiceTrans;
PurchTable _purchTable;
VendPackingSlipTrans _vendPackingSlipTrans;
VendTable _vendTable;
InventDim _inventDim;

Query QTmpTable;
QueryRun QRunTmpTable;

QueryBuildDataSource qInventTrans;
QueryBuildDataSource qInventTable;
QueryBuildDataSource qPurchTable;
QueryBuildDataSource qVendTable;
QueryBuildDataSource qVendPackingSlipTrans;
QueryBuildDataSource qVendInvoiceTrans;
QueryBuildDataSource qInventDim;

QueryBuildRange _FinProjectRange;
QueryBuildRange _FinSbytNaprRange;
QueryBuildRange _AccountIDRange;
QueryBuildRange _ItemIDRange;
QueryBuildRange _ItemGroupIDRange;
QueryBuildRange _LocationIDRange;

ERP_tmpMythOLAPPurch _tmpMythOLAPPurch;
;
// Собираем все необходимые данные для нашего отчета

QTmpTable = new Query();

qInventTrans=QTmpTable.addDataSource(TableNum(InventTrans), "InventTrans");
qInventTrans.orderMode(OrderMode::GroupBy);
qInventTrans.addSortField(FieldNum(InventTrans, TransRefID));
qInventTrans.addSortField(FieldNum(InventTrans, InventTransID));
qInventTrans.addSortField(FieldNum(InventTrans, Direction));
qInventTrans.addSortField(FieldNum(InventTrans, DateExpected));
qInventTrans.addSortField(FieldNum(InventTrans, DatePhysical));
qInventTrans.addSortField(FieldNum(InventTrans, DateFinancial));
qInventTrans.addSortField(FieldNum(InventTrans, ItemID));
qInventTrans.addSortField(FieldNum(InventTrans, CurrencyCode));
qInventTrans.addSelectionField(FieldNum(InventTrans, TransRefID));
qInventTrans.addSelectionField(FieldNum(InventTrans, InventTransID));
qInventTrans.addSelectionField(FieldNum(InventTrans, Direction));
qInventTrans.addSelectionField(FieldNum(InventTrans, DateExpected));
qInventTrans.addSelectionField(FieldNum(InventTrans, DatePhysical));
qInventTrans.addSelectionField(FieldNum(InventTrans, DateFinancial));
qInventTrans.addSelectionField(FieldNum(InventTrans, ItemID));
qInventTrans.addSelectionField(FieldNum(InventTrans, CurrencyCode));
qInventTrans.addSelectionField(FieldNum(InventTrans, Qty), SelectionField::Sum);
qInventTrans.addSelectionField(FieldNum(InventTrans, CostAmountPosted), SelectionField::Sum);
qInventTrans.addSelectionField(FieldNum(InventTrans, CostAmountAdjustment), SelectionField::Sum);
qInventTrans.addRange(FieldNum(InventTrans,TransType)).value(QueryValue(InventTransType::Purch));
qInventTrans.addRange(FieldNum(InventTrans,DateFinancial)).value(Date2StrUsr(StartDate)+ ".." + Date2StrUsr(EndDate));
if (_ItemKey.empty()==False) qInventTrans.addRange(FieldNum(InventTrans, ItemId)).value(_ItemKey.get());

qInventTable=qInventTrans.addDataSource(TableNum(InventTable), "InventTable");
qInventTable.orderMode(OrderMode::GroupBy);
qInventTable.addSortField(FieldNum(InventTable, ItemName));
qInventTable.addSortField(FieldNum(InventTable, NameAlias));
qInventTable.addSortField(FieldNum(InventTable, ItemGroupId));
qInventTable.addSelectionField(FieldNum(InventTable, ItemName));
qInventTable.addSelectionField(FieldNum(InventTable, NameAlias));
qInventTable.addSelectionField(FieldNum(InventTable, ItemGroupId));
qInventTable.joinMode(JoinMode::InnerJoin);
qInventTable.fetchMode(0);
qInventTable.addLink(FieldNum(InventTrans, ItemID), FieldNum(InventTable, ItemID));
if (_ItemGroupKey.empty()==False) qInventTable.addRange(FieldNum(InventTable, ItemGroupId)).value(_ItemGroupKey.get());

qVendInvoiceTrans=qInventTrans.addDataSource(TableNum(VendInvoiceTrans), "VendInvoiceTrans");
qVendInvoiceTrans.orderMode(OrderMode::GroupBy);
qVendInvoiceTrans.addSortField(FieldNum(VendInvoiceTrans, InvoiceID));
qVendInvoiceTrans.addSortField(FieldNum(VendInvoiceTrans, RecID));
qVendInvoiceTrans.addSortField(FieldNum(VendInvoiceTrans, LineAmount));
qVendInvoiceTrans.addSortField(FieldNum(VendInvoiceTrans, TaxAmount));
qVendInvoiceTrans.addSortField(FieldNum(VendInvoiceTrans, Dimension));
qVendInvoiceTrans.addSelectionField(FieldNum(VendInvoiceTrans, InvoiceID));
qVendInvoiceTrans.addSelectionField(FieldNum(VendInvoiceTrans, RecID));
qVendInvoiceTrans.addSelectionField(FieldNum(VendInvoiceTrans, LineAmount));
qVendInvoiceTrans.addSelectionField(FieldNum(VendInvoiceTrans, TaxAmount));
qVendInvoiceTrans.addSelectionField(FieldNum(VendInvoiceTrans, Dimension));
qVendInvoiceTrans.joinMode(JoinMode::InnerJoin);
qVendInvoiceTrans.fetchMode(0);
qVendInvoiceTrans.addLink(FieldNum(InventTrans, InventTransID), FieldNum(VendInvoiceTrans, InventTransID));
if (_SbytNaprKey.empty()==False) qVendInvoiceTrans.addRange(FieldId2Ext(FieldNum(VendInvoiceTrans, Dimension),2)).value(_SbytNaprKey.get());
if (_ProjectKey.empty()==False) qVendInvoiceTrans.addRange(FieldId2Ext(FieldNum(VendInvoiceTrans, Dimension),3)).value(_ProjectKey.get());


qPurchTable=qInventTrans.addDataSource(TableNum(PurchTable), "PurchTable");
qPurchTable.orderMode(OrderMode::GroupBy);
qPurchTable.addSortField(FieldNum(PurchTable, OrderAccount));
qPurchTable.addSelectionField(FieldNum(PurchTable, OrderAccount));
qPurchTable.addSelectionField(FieldNum(PurchTable, ERP_Description));
qPurchTable.joinMode(JoinMode::InnerJoin);
qPurchTable.fetchMode(0);
qPurchTable.addLink(FieldNum( InventTrans, TransRefID), FieldNum(PurchTable, PurchID));
if (_AccountKey.empty()==False) qPurchTable.addRange(FieldNum(PurchTable, OrderAccount)).value(_AccountKey.get());

qVendPackingSlipTrans=qInventTrans.addDataSource(TableNum(VendPackingSlipTrans), "VendPackingSlipTrans");
qVendPackingSlipTrans.orderMode(OrderMode::GroupBy);
qVendPackingSlipTrans.addSortField(FieldNum(VendPackingSlipTrans, ReturnActionID));
qVendPackingSlipTrans.addSortField(FieldNum(VendPackingSlipTrans, Name));
qVendPackingSlipTrans.addSortField(FieldNum(VendPackingSlipTrans, PurchUnit));
qVendPackingSlipTrans.addSelectionField(FieldNum(VendPackingSlipTrans, ReturnActionId));
qVendPackingSlipTrans.addSelectionField(FieldNum(VendPackingSlipTrans, Name));
qVendPackingSlipTrans.addSelectionField(FieldNum(VendPackingSlipTrans, PurchUnit));
qVendPackingSlipTrans.joinMode(JoinMode::InnerJoin);
qVendPackingSlipTrans.fetchMode(0);
qVendPackingSlipTrans.addLink(FieldNum(InventTrans, InventTransID), FieldNum(VendPackingSlipTrans, InventTransID));

qVendTable=qPurchTable.addDataSource(TableNum(VendTable), "VendTable");
qVendTable.orderMode(OrderMode::GroupBy);
qVendTable.addSortField(FieldNum(VendTable, NameAlias));
qVendTable.addSelectionField(FieldNum(VendTable, NameAlias));
qVendTable.joinMode(JoinMode::InnerJoin);
qVendTable.fetchMode(0);
qVendTable.addLink(FieldNum(PurchTable, OrderAccount), FieldNum(VendTable, AccountNum));


qInventDim=qVendInvoiceTrans.addDataSource(TableNum(InventDim), "InventDim");
qInventDim.orderMode(OrderMode::GroupBy);
qInventDim.addSortField(FieldNum(InventDim, InventLocationID));
qInventDim.addSortField(FieldNum(InventDim, ERP_Project));
qInventDim.addSortField(FieldNum(InventDim, ERP_JrPerson));
qInventDim.addSortField(FieldNum(InventDim, InventBatchId));
qInventDim.addSelectionField(FieldNum(InventDim, InventLocationID));
qInventDim.addSelectionField(FieldNum(InventDim, ERP_Project));
qInventDim.addSelectionField(FieldNum(InventDim, ERP_JrPerson));
qInventDim.addSelectionField(FieldNum(InventDim, InventBatchId));
qInventDim.joinMode(JoinMode::InnerJoin);
qInventDim.fetchMode(0);
qInventDim.addLink(FieldNum(VendInvoiceTrans, InventDimID), FieldNum(InventDim, InventDimID));
if (_LocationKey.empty()==False) qInventDim.addRange(FieldNum(InventDim, InventLocationId)).value(_LocationKey.get());


QRunTmpTable=new QueryRun(QTmpTable) ;

while (QRunTmpTable.next())
{
_inventTrans =QRunTmpTable.get(TableNum(InventTrans));
_inventTable =QRunTmpTable.get(TableNum(InventTable));
_vendInvoiceTrans =QRunTmpTable.get(TableNum(VendInvoiceTrans));
_purchTable =QRunTmpTable.get(TableNum(PurchTable));
_vendPackingSlipTrans =QRunTmpTable.get(TableNum(VendPackingSlipTrans));
_vendTable =QRunTmpTable.get(TableNum(VendTable));
_inventDim =QRunTmpTable.get(TableNum(InventDim));

_tmpMythOLAPPurch.clear();

_tmpMythOLAPPurch.DateExpected=_inventTrans.DateExpected;
_tmpMythOLAPPurch.DateFinancial=_inventTrans.DateFinancial;
_tmpMythOLAPPurch.DatePhysical=_inventTrans.DatePhysical;
_tmpMythOLAPPurch.Dimension=_vendInvoiceTrans.Dimension;
_tmpMythOLAPPurch.Direction=_inventTrans.Direction;
_tmpMythOLAPPurch.TotalAmount=_vendInvoiceTrans.LineAmount+_vendInvoiceTrans.TaxAmount;
_tmpMythOLAPPurch.RecId1=_vendInvoiceTrans.RecId;
_tmpMythOLAPPurch.CostAmountAdjustment=_inventTrans.CostAmountAdjustment;
_tmpMythOLAPPurch.CostAmountPosted=_inventTrans.CostAmountPosted;
_tmpMythOLAPPurch.CurrencyCode=_inventTrans.currencyCode;
_tmpMythOLAPPurch.InvoiceId=_vendInvoiceTrans.InvoiceId;
_tmpMythOLAPPurch.ItemId=_inventTrans.ItemId;
_tmpMythOLAPPurch.Qty =_inventTrans.Qty;
_tmpMythOLAPPurch.TransRefId=_inventTrans.TransRefId;
_tmpMythOLAPPurch.ItemGroupId=_inventTable.ItemGroupId;
_tmpMythOLAPPurch.ItemName=_inventTable.itemName;
_tmpMythOLAPPurch.NameAlias=_inventTable.NameAlias;
_tmpMythOLAPPurch.ERP_JrPerson=_inventDim.ERP_JrPerson;
_tmpMythOLAPPurch.ERP_Project=_inventDim.ERP_Project;
_tmpMythOLAPPurch.inventBatchId=_inventDim.inventBatchId;
_tmpMythOLAPPurch.InventLocationId=_inventDim.InventLocationId;
_tmpMythOLAPPurch.ERP_Description=_purchTable.ERP_Description;
_tmpMythOLAPPurch.OrderAccount=_purchTable.OrderAccount;
_tmpMythOLAPPurch.ReturnActionId=_vendPackingSlipTrans.ReturnActionId;
_tmpMythOLAPPurch.Name=_vendPackingSlipTrans.Name;
_tmpMythOLAPPurch.PurchUnit=_vendPackingSlipTrans.PurchUnit;
_tmpMythOLAPPurch.VendNameAlias=_vendTable.NameAlias;
_tmpMythOLAPPurch.InventTransId=_inventTrans.InventTransId;

_tmpMythOLAPPurch.write();
}
return _tmpMythOLAPPurch;
}
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Dynamics AX: QueryRun and Query Objects - Binding operation failed to allocate buffer space Blog bot DAX Blogs 0 03.04.2009 08:05
palleagermark: Sample union query from AX 2009 Blog bot DAX Blogs 0 11.07.2008 20:05
Dynamics AX Geek: Using query() Blog bot DAX Blogs 0 28.10.2006 16:40
Установка условия ИЛИ (OR) в Query Zeratul DAX: Программирование 3 22.06.2006 14:28
Проблема с составлением Query axaLearner DAX: Программирование 10 01.12.2005 15:00
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:31.