Saturday, May 15, 2010
Friday, May 14, 2010
Finding OnHand Info of an Item
OnHand Info of an Item
static void FindingOnHandInfo(Args _args)
{
ItemId itemId;
InventDim inventDimCriteria;
InventDimParm inventDimParm;
InventOnhand inventOnhand = new InventOnhand();
;
// Specify the item to get onhand info on
itemId = "1001";
// Specify the dimensions you want
// to filter the onhand info on
inventDimCriteria.InventColorId = "02";
// Set the parameter flags active
// according to which of the dimensions
// in inventDimCriteria that are set
inventDimParm.initFromInventDim(inventDimCriteria);
// Specify the inventDim,
// inventDimParm and itemId
inventOnhand.parmInventDim(inventDimCriteria);
inventOnhand.parmInventDimParm(inventDimParm);
inventOnhand.parmItemId(itemId);
// Retrieve the onhand info
info(strfmt("Available Physical: %1",
inventOnhand.availPhysical()));
info(strfmt("On order: %1",inventOnhand.onOrder()));
}
The Output of the following Job will be as follows
Only one Post today Coz was really busy with the work :(
But Still keep on checking the blogs many more to come
Till then keep on DAXing.......Happy DAX-ing :)
and yes Happy Weekend too...........................
static void FindingOnHandInfo(Args _args)
{
ItemId itemId;
InventDim inventDimCriteria;
InventDimParm inventDimParm;
InventOnhand inventOnhand = new InventOnhand();
;
// Specify the item to get onhand info on
itemId = "1001";
// Specify the dimensions you want
// to filter the onhand info on
inventDimCriteria.InventColorId = "02";
// Set the parameter flags active
// according to which of the dimensions
// in inventDimCriteria that are set
inventDimParm.initFromInventDim(inventDimCriteria);
// Specify the inventDim,
// inventDimParm and itemId
inventOnhand.parmInventDim(inventDimCriteria);
inventOnhand.parmInventDimParm(inventDimParm);
inventOnhand.parmItemId(itemId);
// Retrieve the onhand info
info(strfmt("Available Physical: %1",
inventOnhand.availPhysical()));
info(strfmt("On order: %1",inventOnhand.onOrder()));
}
The Output of the following Job will be as follows
Only one Post today Coz was really busy with the work :(
But Still keep on checking the blogs many more to come
Till then keep on DAXing.......Happy DAX-ing :)
and yes Happy Weekend too...........................
Friday, May 7, 2010
Using Some of the basic objects of the Query Framework in X++ or AX2009
Using the basic objects in the query framework like Query, QueryBuildDataSource, QueryBuildFieldList, QueryBuildRange, QueryRun
static void Query(Args _args)
{
Query query = new Query(); //Creating a Object of Query Framework
QueryBuildDataSource queryBuild;
QueryBuildFieldList queryList;
QueryBuildRange qbr;
QueryRun qr;
CustTable custTable;
;
queryBuild = query.addDataSource(tableNum(CustTable));//Adding Datasource to Query
queryList = queryBuild.fields(); //Adding fields to Datasource of Query
queryList.addField(fieldNum(CustTable, AccountNum));
queryList.addField(fieldNum(CustTable, CustGroup)); // Adding the fields to querybuildfieldlist
queryList.addField(fieldNum(CustTable, Currency));
qbr = querybuild.addRange(fieldnum(CustTable,AccountNum)); // Adding Range to the Datasource of Query
qbr.value("1000..1300");//Adding value to the range of the Datasource
qr = new QueryRun(query);//Creating the Object of the Queryrun and passing the query object to excute the Query
while (qr.next())
{
custTable = qr.get(tableNum(CustTable)); // Getting the value of the Query in the relevant buffer
//custTable = qr.getNo(1); You can also write this commented code instead of the above one
info(strfmt("%1, %2, %3", custTable.AccountNum, custTable.CustGroup, custTable.Currency));
}
}
The Output will be as follows
As you all most be knowing that the CustTable in Dynamics AX is having so many entries but then also the Query is displaying only 8 records that is because we have applied the range on query and the value of the range in the query is 1000..1300 . It means that it will only fetch those records who have account numbers between 1000 and 1300
Keep on DAX- ing !!! Its fun
And watch out for more DAX-Ideas Coming up your way :)
Transfer Journal for an Item in AX2009
Posting the Transfer Journal for a Item using X++ code in AX2009
static void CreateTransferJournal(Args _args)
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventJournalCheckPost inventJournalCheckPost;
NumberSeq num;
boolean _throwserror=true;
boolean _showinforesult=true;
InventDim frominventDim,ToinventDim;
;
ttsbegin;
inventJournalTable.clear();
num = new NumberSeq();
num = NumberSeq::newGetNum(InventParameters::numRefTransferId());
inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().TransferJournalNameId));
inventJournalTable.Description = "Inventory Transfer Journal";
inventJournalTable.SystemBlocked = true;
inventJournalTable.insert();
info("Entry Inserted");
info(strfmt("The Voucher generated is %1",inventJournalTable.JournalId));
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.ItemId = "1101";
frominventDim.InventLocationId="21";
//frominventDim.configId = "02";
frominventDim.inventSiteId ="2";
ToinventDim.InventLocationId = "34";
ToinventDim.InventSiteId = "3";
// ToinventDim.configId = "02";
ToinventDim = InventDim::findOrCreate(ToinventDim);
frominventDim = InventDim::findOrCreate(frominventDim);
inventJournalTrans.InventDimId = frominventDim.inventDimId;
inventJournalTrans.initFromInventTable(InventTable::find("1101"));
inventJournalTrans.Qty = 10;
inventJournalTrans.ToInventDimId = ToinventDim.inventDimId;
inventJournalTrans.TransDate = SystemDateget();
inventJournalTrans.insert();
inventJournalCheckPost = InventJournalCheckPost::newJournalCheckPost(JournalCheckpostType::Post,inventJournalTable);
inventJournalCheckPost.parmThrowCheckFailed(_throwserror);
inventJournalCheckPost.parmShowInfoResult(_showinforesult);
inventJournalCheckPost.run();
inventJournalTable.SystemBlocked = false;
inventJournalTable.update();
ttscommit;
}
Subscribe to:
Posts (Atom)