Friday, April 3, 2015

Creating Sales Order Using X++ in AX 2012

Creating Sales Order And Posting Sales Order Invoice 

static void Esh_CreateSO(Args _args)
{
    // Create the Sales Order

    SalesTable salesTable;
    NumberSeq NumberSeq;
    SalesId sid;
    SalesLine sl;
    SalesFormLetter salesFormLetter;
    ;
    NumberSeq =NumberSeq::newGetNum(SalesParameters::numRefSalesId() , true);
    sid=NumberSeq.num();
    salesTable.SalesId = sid;
    salesTable.initValue();
    salesTable.CustAccount = "US-006";
    salesTable.initFromCustTable();
    salesTable.insert();

    //Create the Sales Line with the created Sales Order
    sl.SalesId=sid;
    sl.ItemId="A0001";
    sl.InventDimId="000458";
    sl.PriceUnit=3750.00;
    sl.SalesQty=5;
    sl.CreateLine(NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes);

    info("Sales Order Created with Line");
 
    //Posting Sales Order 
    salesFormLetter=SalesFormLetter::construct(DocumentStatus::PackingSlip);
    salesFormLetter.update(SalesTable::find(sid));
    salesFormLetter.update(salesTable,systemDateGet(),SalesUpdate::All,AccountOrder::None, NoYes::No,NoYes::Yes);
    info("Sales Order Status is Delivered");
 

    //Post the Sales Order Invoice
    salesFormLetter=SalesFormLetter::construct(DocumentStatus::Invoice);
    salesFormLetter.update(SalesTable::find(sid));
    info(strFmt("%1 Sales Order Posted and Final Status is Invoiced",salesTable.SalesId));

}

1 comment:

  1. https://www.youtube.com/playlist?list=PLWSxgDbjVWTjxvgnaAZ0iK8o5dYHAYhrq

    Collection of Microsoft ERP Clips || ERP Licensing, Technical, Functional ,Manager Learning Videos Listing

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// ...