Monday, 7 December 2015

Creation,Confirm,Picking,Packing and Invoice of sales order through X++ code : 

Creation:

static void Sak_SalesOrderCreate(Args _args)
{
NumberSeq numberSeq;
SalesTable salesTable;
SalesLine salesLine;
InventDim   inventdim;
ttsBegin;
numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
numberSeq.used();
salesTable.SalesId = numberSeq.num();
salesTable.initValue();
salesTable.CustAccount = 'US-007';
salesTable.CurrencyCode = 'INR';
salesTable.LanguageId = "en-us";
salesTable.CustGroup = '30';
salesTable.InvoiceAccount = 'US-007';
salesTable.initFromCustTable();
if (!salesTable.validateWrite())
{
throw Exception::Error;
}
salesTable.insert();
salesLine.SalesId = salesTable.SalesId;
salesLine.ItemId = 'D0002';
salesLine.InventDimId = inventdim.inventDimId;
InventDim.InventLocationId = '11';
inventdim.InventSiteId = '1';
salesLine.createLine(true, true, true, true, true, true);
ttsCommit;
info(strFmt("Sales order '%1' has been created", salesTable.SalesId));
}
  

Confirmation : 


static void Sak_confirmSalesOrder (Args _args)
{
        SalesTable salesTable;
        SalesFormLetter salesFormLetter ;
        SalesTable = SalesTable::find('001011');
        salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
        salesFormLetter.update(salesTable);
        info(strFmt(" sales order Confirm '%1' has been ", salesTable.SalesId));

}

 

Picking :

 

static void Sak_SalesOrder_UpdatePickingList(Args _args)
{
    SalesFormLetter_PickingList salesFormLetter;
    SalesTable      salesTable = salesTable::find('001011');
    salesFormLetter = SalesFormLetter_PickingList::newPickingList();
    salesFormLetter.transDate(systemDateGet());
    salesFormLetter.update(salesTable,
                            systemdateget(),
                            SalesUpdate::All,
                            AccountOrder::None,
                            NoYes::No,
                            NoYes::No);
}

 

Packing:

 

static void Sak_postSalesPackingslip(Args _args)
{
SalesTable salesTable = SalesTable::find('001011');
SalesFormLetter salesFormLetter;

salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All);
}

 

Invoice:

 

static void Sak_postSalesInvoice(Args _args)
{
// Define a class variable according to the  type of posting being performed
SalesFormLetter_Invoice invoice;
SalesTable salesTable;
// Select the salesTable to update
salesTable = SalesTable::find('001011');
// Create a new object of the SalesFormLetter_Invoice by using the construct-method in //SalesFormLetter
invoice = SalesFormLetter::construct(DocumentStatus::Invoice);
// Post the invoice of SO
invoice.update(salesTable, SystemDateGet(), SalesUpdate::All,AccountOrder::None, false, true);
// Set to true to print the invoice
}



No comments:

Post a Comment