If you try to send data from server class to form with TempDB by parameter you'll see no data will be came. You may select In Memory table or use linkPhysicalTableInstance method to link two TempDB table:
Class:
public static server void populateData(MyTempTable _tmp)
{
MyTempTable tmp;
...
...
tmp.linkPhysicalTableInstance(_tmp);
...
...
return;
}
Form:
MyClass::populateData(MyTempTable);
MyTempTable_DS.research();
MyTempTable_DS.refresh();
7 Temmuz 2017 Cuma
4 Ocak 2017 Çarşamba
AXAPTA - Synchronize tables
That code works on common situation my colleauge found from web (don't know the source):
Dictionary dict;
int idx, lastIdx, totalTables;
TableId tableId;
Application application;
SysOperationProgress progress;
StackBase errorStack;
ErrorTxt errorTxt;
;
application = new Application();
dict = new Dictionary();
totalTables = dict.tableCnt();
progress = new SysOperationProgress();
progress.setTotal(totalTables);
progress.setCaption("@SYS90206");
errorStack = new StackBase(Types::String);
lastIdx = 3000;
try
{
for (idx = lastIdx+1; idx <= totalTables; idx++)
{
tableId = dict.tableCnt2Id(idx);
progress.setText(dict.tableName(tableId));
lastIdx = idx;
application.dbSynchronize(tableId, false, true, false);
progress.incCount();
}
}
catch (Exception::Error)
{
errorTxt = strFmt("Error on table: '%1' (%2) ", tableId, dict.tableName(tableId));
errorStack.push(errorTxt);
retry;
}
setPrefix("@SYS86407");
errorTxt = errorStack.pop();
while (errorTxt)
{
error(errorTxt);
errorTxt = errorStack.pop();
}
Dictionary dict;
int idx, lastIdx, totalTables;
TableId tableId;
Application application;
SysOperationProgress progress;
StackBase errorStack;
ErrorTxt errorTxt;
;
application = new Application();
dict = new Dictionary();
totalTables = dict.tableCnt();
progress = new SysOperationProgress();
progress.setTotal(totalTables);
progress.setCaption("@SYS90206");
errorStack = new StackBase(Types::String);
lastIdx = 3000;
try
{
for (idx = lastIdx+1; idx <= totalTables; idx++)
{
tableId = dict.tableCnt2Id(idx);
progress.setText(dict.tableName(tableId));
lastIdx = idx;
application.dbSynchronize(tableId, false, true, false);
progress.incCount();
}
}
catch (Exception::Error)
{
errorTxt = strFmt("Error on table: '%1' (%2) ", tableId, dict.tableName(tableId));
errorStack.push(errorTxt);
retry;
}
setPrefix("@SYS86407");
errorTxt = errorStack.pop();
while (errorTxt)
{
error(errorTxt);
errorTxt = errorStack.pop();
}
12 Aralık 2016 Pazartesi
AX 2012 - Run Questionnaires with X++ and get Answer table answer Id
There are lots of pages about questionnaires at the web. So I won't tell anything about using and run
questionnaires from menus.
KMCollection - Questionnaire records table. kmCollectionId is key field.
KMVirtualNetworkAnswerTable - Answers table. kmVirtualNetworkAnswerTableId is key field. Result is saved at evaluation field as failed/passed or empty.
KMVirtualNetworkAnswerLine - Answers lines table.
Run Questionnaire with code:
KMQuestionnaireRun o = new CrsKMQuestionnaireRun();
o.set(KMQuestionnaireRunMode::All,myKMCollectionId, DirPersonUser::find(curUserId()).party());
o.run();
Run Answer form with code:
KMVirtualNetworkAnswerTable answerTable;
Args args = new Args();
RecId recId = DirPersonUser::find(curUserId()).party();
select firstOnly answerTable
where answerTable.kmVirtualNetworkAnswerTableId == this.AnswerId;
args.record(answerTable);args.caller(o);
new MenuFunction(menuItemDisplayStr(KMKnowledgeCollectorUserResults), MenuItemType::Display).run(args);
I extended KMQuestionnaireRun_Win32 class for save KMVirtualNetworkAnswerTable's ID field to my table at my caller form:
class myKMQuestionnaireRun extends KMQuestionnaireRun_Win32
{
recId myRecId;
}
I added a parm method for save caller table RecId:
RecId parmMyRecId(RecId _recId = myRecId)
{
myRecId =_recId;
return myRecId;
}
Derived end method of MQuestionnaireRun_Win32:
public void end(KMVirtualNetworkAnswerTableId _kmVirtualNetworkAnswerTableId)
{
myCallerTable tbl; //Questionnaries formunu çağıran tablo
super(_kmVirtualNetworkAnswerTableId);
if (_kmVirtualNetworkAnswerTableId == "")
return;
ttsBegin;
update_recordSet tbl setting AnswerId = _kmVirtualNetworkAnswerTableId
where tbl.RecId == myRecId;
ttsCommit;
}
And call from my table:
...
myKMQuestionnaireRun o = new myKMQuestionnaireRun();
myQTable c;
o.parmMyRecId(this.RecId);
o.set(KMQuestionnaireRunMode::All,this.KMCollectionId, DirPersonUser::find(curUserId()).party());
o.run();
...
questionnaires from menus.
KMCollection - Questionnaire records table. kmCollectionId is key field.
KMVirtualNetworkAnswerTable - Answers table. kmVirtualNetworkAnswerTableId is key field. Result is saved at evaluation field as failed/passed or empty.
KMVirtualNetworkAnswerLine - Answers lines table.
Run Questionnaire with code:
KMQuestionnaireRun o = new CrsKMQuestionnaireRun();
o.set(KMQuestionnaireRunMode::All,myKMCollectionId, DirPersonUser::find(curUserId()).party());
o.run();
Run Answer form with code:
KMVirtualNetworkAnswerTable answerTable;
Args args = new Args();
RecId recId = DirPersonUser::find(curUserId()).party();
select firstOnly answerTable
where answerTable.kmVirtualNetworkAnswerTableId == this.AnswerId;
args.record(answerTable);args.caller(o);
new MenuFunction(menuItemDisplayStr(KMKnowledgeCollectorUserResults), MenuItemType::Display).run(args);
I extended KMQuestionnaireRun_Win32 class for save KMVirtualNetworkAnswerTable's ID field to my table at my caller form:
class myKMQuestionnaireRun extends KMQuestionnaireRun_Win32
{
recId myRecId;
}
I added a parm method for save caller table RecId:
RecId parmMyRecId(RecId _recId = myRecId)
{
myRecId =_recId;
return myRecId;
}
Derived end method of MQuestionnaireRun_Win32:
public void end(KMVirtualNetworkAnswerTableId _kmVirtualNetworkAnswerTableId)
{
myCallerTable tbl; //Questionnaries formunu çağıran tablo
super(_kmVirtualNetworkAnswerTableId);
if (_kmVirtualNetworkAnswerTableId == "")
return;
ttsBegin;
update_recordSet tbl setting AnswerId = _kmVirtualNetworkAnswerTableId
where tbl.RecId == myRecId;
ttsCommit;
}
And call from my table:
...
myKMQuestionnaireRun o = new myKMQuestionnaireRun();
myQTable c;
o.parmMyRecId(this.RecId);
o.set(KMQuestionnaireRunMode::All,this.KMCollectionId, DirPersonUser::find(curUserId()).party());
o.run();
...
9 Ağustos 2016 Salı
AXAPTA - Invent on hand
//source: http://microsoft-dynamics-ax-erp.blogspot.com.tr/2012/07/find-inventonhand-in-axapta-x.html
static InventOnHand findOnHandByLocationId(ItemId _itemId, InventLocationId _inventLocationId = "")
{
InventDim inventDim;
InventDimParm inventDimParm;
InventOnHand inventOnHand = new InventOnHand();
;
if (_inventLocationId == "")
return InventOnhand::newItemId(_itemId);
//Take a combination of dimension , against which you want to find the stock
inventDim.InventLocationId = _inventLocationId;
//Set the flag for the selected dimensions as active
inventDimParm.initFromInventDim(inventDim);
//Initialize the inventSumDateDim with Date,item,dimension and dim parameter
inventOnHand = InventOnHand::newParameters(_itemid,
inventDim,
inventDimParm);
return inventOnHand;
}
or:
//http://daxtechies.blogspot.com/2013/03/to-find-stock-on-hand-in-ax-through-x.html
static InventOnHand findOnHandByLocationId(ItemId _itemId, InventLocationId _inventLocationId = "")
{
InventDim inventDim;
InventDimParm inventDimParm;
InventOnHand inventOnHand = new InventOnHand();
;
if (_inventLocationId == "")
return InventOnhand::newItemId(_itemId);
//Take a combination of dimension , against which you want to find the stock
inventDim.InventLocationId = _inventLocationId;
//Set the flag for the selected dimensions as active
inventDimParm.initFromInventDim(inventDim);
//Initialize the inventSumDateDim with Date,item,dimension and dim parameter
inventOnHand = InventOnHand::newParameters(_itemid,
inventDim,
inventDimParm);
return inventOnHand;
}
or:
//http://daxtechies.blogspot.com/2013/03/to-find-stock-on-hand-in-ax-through-x.html
InventSum inventsum;
Qty availableQty = 0;
;
select sum(PostedQty),
sum(Received),
sum(Deducted),
sum(Registered),
sum(Picked),
sum(ReservPhysical),
sum(Ordered),
sum(Arrived),
sum(ReservOrdered),
sum(OnOrder) from inventsum
where inventsum.ItemId == "KCYIWU001";
if (inventsum)
{
availableQty = inventsum.PostedQty
+ inventsum.Received
- inventsum.Deducted
+ inventsum.Registered
- inventSum.Picked
- inventSum.ReservPhysical
+ inventsum.Ordered
+ inventsum.Arrived
- inventsum.ReservOrdered
- inventsum.OnOrder;
}
24 Haziran 2016 Cuma
AXAPTA - Clear left open QTY's at a transfer order
If a transfer order haven't got completed and that left QTY's related with an output order and reserved, Functions->Deliver remainder->Cancel quantity button will not work. It'll get an error about "there's not enough QTY with ordered" and quit. It's about that QTY reserved with output order and can't unreserve (At least I couldn't a way) direct with one line code. If you even unreserve from menu, relation will still stay and you'll get that error again. In first tie with output order should be break. I couldn't a way break relation with standart code and found this way, it seem works:
InventTransferTable header;
InventTransferLine line;
WMSOrderTrans orderTrans;
InventTrans inventTrans;
;
while select header
where header.TransferId == myTransferId
join forupdate line
where line.TransferId == header.TransferId &&
(line.QtyRemainReceive > 0 || line.QtyRemainShip>0)
{
ttsbegin;
while select orderTrans
where orderTrans.inventTransId == line.InventTransId &&
orderTrans.expeditionStatus != WMSExpeditionStatus::Complete &&
orderTrans.expeditionStatus != WMSExpeditionStatus::Cancelled &&
orderTrans.expeditionStatus != WMSExpeditionStatus::CancelledSW
{
WmsPickingLineCancel::newWMSPickingLineCancel(orderTrans).run();
}
while select forupdate inventTrans
where (inventTrans.StatusIssue == StatusIssue::ReservPhysical ||
(inventTrans.TransChildRefId != "" &&
inventTrans.TransChildType == InventTransChildType::WMSOrder) ) &&
inventTrans.InventTransId == line.InventTransId
{
inventTrans.TransChildRefId = "";
inventTrans.TransChildType = InventTransChildType::None;
inventTrans.update();
InventUpd_Reservation::newInventDim(InventMovement::construct(inventTrans,InventMovSubType::None),
inventtrans.inventDim(),2,false).updateNow();
}
line.QtyRemainReceive = 0;
line.QtyRemainShip = 0;
line.AutoReservation = NoYes::No;
line.update();
ttscommit;
}
InventTransferTable header;
InventTransferLine line;
WMSOrderTrans orderTrans;
InventTrans inventTrans;
;
while select header
where header.TransferId == myTransferId
join forupdate line
where line.TransferId == header.TransferId &&
(line.QtyRemainReceive > 0 || line.QtyRemainShip>0)
{
ttsbegin;
while select orderTrans
where orderTrans.inventTransId == line.InventTransId &&
orderTrans.expeditionStatus != WMSExpeditionStatus::Complete &&
orderTrans.expeditionStatus != WMSExpeditionStatus::Cancelled &&
orderTrans.expeditionStatus != WMSExpeditionStatus::CancelledSW
{
WmsPickingLineCancel::newWMSPickingLineCancel(orderTrans).run();
}
while select forupdate inventTrans
where (inventTrans.StatusIssue == StatusIssue::ReservPhysical ||
(inventTrans.TransChildRefId != "" &&
inventTrans.TransChildType == InventTransChildType::WMSOrder) ) &&
inventTrans.InventTransId == line.InventTransId
{
inventTrans.TransChildRefId = "";
inventTrans.TransChildType = InventTransChildType::None;
inventTrans.update();
InventUpd_Reservation::newInventDim(InventMovement::construct(inventTrans,InventMovSubType::None),
inventtrans.inventDim(),2,false).updateNow();
}
line.QtyRemainReceive = 0;
line.QtyRemainShip = 0;
line.AutoReservation = NoYes::No;
line.update();
ttscommit;
}
8 Haziran 2016 Çarşamba
AXAPTA - Cancel a WMS picking list or cancel line of picking list
Cancel whole list:
Cancel a line:
WMSPickingRouteCancel::newWMSPickingRoute(wMSPickingRoute).run();
Cancel a line:
WMSPickingLineCancel::newWMSPickingLineCancel(wMSOrderTrans).run();
6 Mayıs 2016 Cuma
AXAPTA - Sign function doesn't work correctly
Sign function doesn't work correctly in AX 2009 and 2012. It should returns -1 for negative numbers, 0 for zero and +1 for positive numbers. But it gives -1 for negative and +1 for others.
Sign at Global:
static real sign(real num)
{
return num >= 0 ? 1 : -1;
}
My correction:
static int sign(real num)
{
if (num < 0)
return -1;
else
return num > 0 ? 1 : 0;
}
Sign at Global:
static real sign(real num)
{
return num >= 0 ? 1 : -1;
}
My correction:
static int sign(real num)
{
if (num < 0)
return -1;
else
return num > 0 ? 1 : 0;
}
Kaydol:
Kayıtlar (Atom)