Creating SO with X++ code in ax 2012 r3
static void SO_shiv(Args _args)
{
NumberSeq numberSeq;
SalesTable salesTable;
SalesLine salesline;
SalesFormLetter salesFormLetter;
;
ttsBegin;
numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
numberSeq.used();
salesTable.SalesId = numberSeq.num(); // salestable
salesTable.initValue();
salesTable.CustAccount='US-002';
salesTable.initFromCustTable();
salesTable.insert();
salesline.SalesId = salesTable.SalesId; // saleline
salesline.ItemId = "sunglasses";
salesline.createLine(true,true,true,true,true);
ttsCommit;
info(strFmt("%1 SO is created",salesTable.SalesId));//SO Created
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);//SO Confirmed
salesFormLetter.update(salesTable);
info(strFmt("%1 SO is Confirmed",salesTable.SalesId));
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);//SO Invoiced
salesFormLetter.update(salesTable);
info(strFmt("%1 SO is Invoiced ",salesTable.SalesId));
}
//Creating PO with X++ code in ax 2012 r3
static void PO_shiv(Args _args)
{
NumberSeq numberseq;
PurchTable purchtable;
PurchLine purchline;
PurchFormLetter purchformletter;
;
ttsbegin;
numberseq = NumberSeq::newGetNum(PurchParameters::numRefPurchId());
numberseq.used();
purchtable.PurchId = numberseq.num();
purchtable.initValue();
purchtable.initFromVendTable(VendTable::find('1100'));
if(!purchtable.validateWrite())
{
throw exception::Error;
}
purchtable.insert();
purchline.PurchId=purchtable.PurchId;
purchline.ItemId ='Duke Bike 700';
purchline.createLine(true,true,true,true,true,true);
ttsCommit;
info(strFmt("%1 Purchase order is created ",purchtable.PurchId));//Po created
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);// PO confirm
purchformLetter.update(purchtable,Purchtable.PurchId);
info(strFmt("%1 PO is Confirmed ",purchtable.PurchId));
purchformletter = PurchFormLetter::construct(DocumentStatus::ReceiptsList);// Receipt List
purchformletter.update(purchtable,purchtable.PurchId);
info(strFmt("%1 PO ReciptList created ",purchtable.PurchId));
purchformletter = PurchFormLetter::construct(DocumentStatus::Invoice);// PO Invoiced
purchformletter.update(purchtable,purchtable.PurchId);//here PO no default as Invoice no is taken
info(strFmt("%1 PO is invoiced",purchtable.PurchId));
//Note Please Make Sure that the item should have default,purch,sales,inventory site and warehouse settings
//(i.e go to item edit >manage inventory>defaultordersettings,site order settings)
}
static void SO_shiv(Args _args)
{
NumberSeq numberSeq;
SalesTable salesTable;
SalesLine salesline;
SalesFormLetter salesFormLetter;
;
ttsBegin;
numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
numberSeq.used();
salesTable.SalesId = numberSeq.num(); // salestable
salesTable.initValue();
salesTable.CustAccount='US-002';
salesTable.initFromCustTable();
salesTable.insert();
salesline.SalesId = salesTable.SalesId; // saleline
salesline.ItemId = "sunglasses";
salesline.createLine(true,true,true,true,true);
ttsCommit;
info(strFmt("%1 SO is created",salesTable.SalesId));//SO Created
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);//SO Confirmed
salesFormLetter.update(salesTable);
info(strFmt("%1 SO is Confirmed",salesTable.SalesId));
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);//SO Invoiced
salesFormLetter.update(salesTable);
info(strFmt("%1 SO is Invoiced ",salesTable.SalesId));
}
//Creating PO with X++ code in ax 2012 r3
static void PO_shiv(Args _args)
{
NumberSeq numberseq;
PurchTable purchtable;
PurchLine purchline;
PurchFormLetter purchformletter;
;
ttsbegin;
numberseq = NumberSeq::newGetNum(PurchParameters::numRefPurchId());
numberseq.used();
purchtable.PurchId = numberseq.num();
purchtable.initValue();
purchtable.initFromVendTable(VendTable::find('1100'));
if(!purchtable.validateWrite())
{
throw exception::Error;
}
purchtable.insert();
purchline.PurchId=purchtable.PurchId;
purchline.ItemId ='Duke Bike 700';
purchline.createLine(true,true,true,true,true,true);
ttsCommit;
info(strFmt("%1 Purchase order is created ",purchtable.PurchId));//Po created
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);// PO confirm
purchformLetter.update(purchtable,Purchtable.PurchId);
info(strFmt("%1 PO is Confirmed ",purchtable.PurchId));
purchformletter = PurchFormLetter::construct(DocumentStatus::ReceiptsList);// Receipt List
purchformletter.update(purchtable,purchtable.PurchId);
info(strFmt("%1 PO ReciptList created ",purchtable.PurchId));
purchformletter = PurchFormLetter::construct(DocumentStatus::Invoice);// PO Invoiced
purchformletter.update(purchtable,purchtable.PurchId);//here PO no default as Invoice no is taken
info(strFmt("%1 PO is invoiced",purchtable.PurchId));
//Note Please Make Sure that the item should have default,purch,sales,inventory site and warehouse settings
//(i.e go to item edit >manage inventory>defaultordersettings,site order settings)
}
No comments:
Post a Comment