Hi,
In this post we will learn the below using X++ :
1) How to Create Sales Order
2) How to Create Sales Order Line
3) How to Post Sales Order
Code :
public static void SalesOrderDemo(Args _s)
{
// Create the Sales Order
SalesTable salesTable;
NumberSeq NumberSeq;
SalesId sid;
SalesLine sl;
SalesFormLetter fl;
;
NumberSeq =NumberSeq::newGetNum(SalesParameters::numRefSalesId() , true);
sid=NumberSeq.num();
salesTable.SalesId = sid;
salesTable.initValue();
salesTable.CustAccount = "1101";
salesTable.initFromCustTable();
salesTable.insert();
//Create the Sales Line with the created Sales Order
sl.SalesId=sid;
sl.ItemId="1101";
sl.CreateLine(NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes);
info("Sales Order Created with Line");
//How to Post the Sales Order Invoice
fl=SalesFormLetter::construct(DocumentStatus::Invoice);
fl.update(SalesTable::find(sid));
info("Sales Order Posted");
}
In this post we will learn the below using X++ :
1) How to Create Sales Order
2) How to Create Sales Order Line
3) How to Post Sales Order
Code :
public static void SalesOrderDemo(Args _s)
{
// Create the Sales Order
SalesTable salesTable;
NumberSeq NumberSeq;
SalesId sid;
SalesLine sl;
SalesFormLetter fl;
;
NumberSeq =NumberSeq::newGetNum(SalesParameters::numRefSalesId() , true);
sid=NumberSeq.num();
salesTable.SalesId = sid;
salesTable.initValue();
salesTable.CustAccount = "1101";
salesTable.initFromCustTable();
salesTable.insert();
//Create the Sales Line with the created Sales Order
sl.SalesId=sid;
sl.ItemId="1101";
sl.CreateLine(NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes);
info("Sales Order Created with Line");
//How to Post the Sales Order Invoice
fl=SalesFormLetter::construct(DocumentStatus::Invoice);
fl.update(SalesTable::find(sid));
info("Sales Order Posted");
}
Hi , While running this code
ReplyDeleteIts says update has been cancelled error . can u help in this?
Hi Mani,
ReplyDeleteIn this code you use your existing salesTable.CustAccount or also use your existing ItemId.
After that if same error occur you should be debug your code................!!
Hi,
DeleteThank u for ur reply . I already using my existing objects only but the issue was not related this. I rectified those ,its working fine.
Thank u so much
Thanks a lot for this post.
ReplyDelete