Thursday, August 30, 2012

AX2012 Layer's Modified

AX 2012 Layer's
There are three layers available only to Microsoft to deliver the base application. (The xxP layer indicates the patch layer for each application object layer).
SYS, SYP:- System layer: The standard application is developed in this lowest layer. This includes the core application and the localization for most countries.
GLS, GLP :- Globalization layer: Includes features developed for some countries that were not yet moved into the SYS layer.
FPK, FPP :-Feature Pack layer: Includes industry feature packs that are controlled by Microsoft.
There are three layers available to partners and ISVs.
SLN, SLP :- Solution layer: Includes Microsoft endorsed industry solutions.
ISV, ISP :- Independent Software Vendor layer: Includes generic or vertical solutions developed by ISV's.
VAR,VAP :- Value Added Reseller layer: Includes multi-customer solutions developed by VAR's.
There are two layers available to both partners and customers who have a license to access the AX source code.
CUS, CUP :- Customer layer: Includes customer specific functionality.
USR, USP :- User layer: Includes installation specific functionality and customizations.

AXAPTA 2012 WORKSPACE

Monday, July 23, 2012

Copying License in Dynamics Ax

Axapta stores the License data in the following two tables.
1.SysLicenseCodeSort
2.SysConfig
So if you copy data of these tables(from Running instance) and import at your instance , this will serve your purpose.

X++ code to create and post Inventory Movement Journal

Following is the sample job to show how we can create and post movement journal by
making use of available api's in the Dynamics Ax.
static void createMovJournal(Args _args)
{ InventJournalTable journalTable;
InventJournalTrans journalTrans;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventTable inventTable;
InventDim inventDim;
Counter cnt;
InventJournalCheckPost journalCheckPost = new InventJournalCheckPost();
;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
// Init JournalTable
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;
journalTable.JournalNameId = journalTableData.journalStatic().standardJournalNameId(journalTable.JournalType);
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
// Init JournalTrans
select firstonly inventTable;
for(cnt=1;cnt<10;cnt++)
{
journalTrans.clear();
journalTransData.initFromJournalTable();
journalTrans.TransDate = systemdateget() + 1 div 2;
journalTrans.ItemId = inventTable.ItemId;
journalTrans.Qty = 100;
journalTrans.CostAmount = 100;
// Dimension details
inventDim.InventLocationId = 'GW';
journalTrans.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
journalTransData.create();
}
journalTable.insert();
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())
InventJournalCheckPost::newPostJournal(journalTable).run();
}

X++ Code to find OnHand Stock for Item

In Dynamics Ax , use InventOnHand class for finding the stock of an item as shownbelow
static void findOnHand(Args _args)
{
InventDim inventDim;
InventDimParm inventDimParm;
Itemid itemid;
InventOnHand inventOnHand = new InventOnHand();
;
// take a sample item for testing
itemid = "20 MM RMC";
// take a combination of dimension , against which you want to find the stock
inventDim.InventLocationId = "GW";
//Set the flag for the selected dimensions as active.
inventDimParm.initFromInventDim(inventDim);
//initialize the inventonhand with item,dimension and dim paramter
inventOnHand.parmItemId(itemid);
inventOnHand.parmInventDim(inventDim);
inventOnHand.parmInventDimParm(inventDimParm);
// Retrieve the onhand info
info(strfmt("Available Physical: %1",
inventOnhand.availPhysical()));
info(strfmt("On order: %1",inventOnhand.onOrder()));
}

X++ code to find the Stock of Item by Date

static void findOnHand_ByDate(Args _args)
{
InventDim inventDim;
InventDimParm inventDimParm;
Itemid itemid;
InventOnHand inventOnHand = new InventOnHand();
InventSumDateDim inventSumDateDim;
TransDate transDate;
;
// take a sample item for testing
itemid = "20 MM RMC";
transDate = 13\01\2010;
// take a combination of dimension , against which you want to find the stock
inventDim.InventLocationId = "GW";
//Set the flag for the selected dimensions as active.
inventDimParm.initFromInventDim(inventDim);
//initialize the inventSumDateDim with Date,item,dimension and dim paramter
inventSumDateDim = InventSumDateDim::newParameters(transDate,
itemid,
inventDim,
inventDimParm);
// Retrieve the onhand info
info(strfmt("PostedQty: %1",inventSumDateDim.postedQty()));
info(strfmt("DeductedQty: %1",inventSumDateDim.deductedQty()));
info(strfmt("ReceivedQty: %1",inventSumDateDim.receivedQty()));
}

X++ code to create a customized lookup on form

Override the lookup method on Formdatasource field(on which you want to show lookup) , and copy the following code to your method.
Comment the super() method in the lookup.
public void lookup(FormControl _formControl, str _filterStr)
{
SysTableLookup sysTableLookup; // systemclass to create //customlookup
Query query;
QueryBuildDataSource qbd;
;
sysTableLookup = SysTableLookup::newParameters(
tablenum(InventTable),
_formcontrol);
// Construct query on the table,
// whose records you want to show as lookup.
query = new Query();
qbd = query.addDataSource(tablenum(InventTable));
qbd.addRange(fieldnum(InventTable,ItemType)).value(SysQuery::value(enum2str
(ItemType::Item)));
// add the fields to the lookup list
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemName));
// pass the query as parameter
// system will show the records in the lookup
// as per your query
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}