Friday, April 16, 2010

Creating Sales order and Posting it through X++

Creating a Sales Order through X++

static void createsalesorder(Args _args)
{
    NumberSeq numberSeq;
    SalesTable salesTable;
    SalesLine salesLine;
    ;
    ttsbegin;
 numberSeq=NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().numberSequence,true);
    salesTable.SalesId = numberSeq.num();
    salesTable.initValue();
    salesTable.CustAccount = '1301';
    salesTable.initFromCustTable();
    if(SalesTable.SalesId)
    {
    salesTable.insert();
    numberseq.used();
    }
    else
    {
    numberseq.abort();
    }
    salesLine.SalesId = salesTable.SalesId;
    salesLine.ItemId = '1101';
    salesline.SalesQty=100.00;
    salesLine.createLine(true, true, true, true, true, true);
    ttscommit;
}
And the next job is for Posting the above Sales Order Created


static void PostingsalesOrder(Args _args)
{
  SalesTable salesTable;
  SalesFormLetter salesFormLetter=salesFormLetter::construct(Documentstatus::Invoice);
  ;
  salesTable=salesTable::find("SO-101363");
  salesFormLetter.update(salesTable,SystemDateGet(),SalesUpdate::All,AccountOrder::None,false,false);
  info ("Invoice Successfully Generated");
}

No comments:

Post a Comment