I have two solutions to post a packing slip through X++. Please change the cod accordingly.
Solution - 1 - The best way to post packing slips
---------------------
//Variable declaration
SalesFormLetter_PackingSlip salesFormLetter_PackingSlip;
salesFormLetter salesFormLetter;
salesFormletterParmData salesFormLetterParmData;
SalesParmTable salesParmTable;
SalesParmLine salesParmLine;
salesLine salesLine, salesLineUpd;
salesParmUpdate salesParmUpdate;
SalesTable salestable = SalesTable::find(_SalesTable.SalesId, true);
CustPackingSlipJour custPackingSlipJour;
TransDate PackingSlipDate = str2Date(dataContract.parmPackinSlipDate(), 213);
;
//Code starts from here
if (salestable && salestable.SalesStatus == SalesStatus::Backorder)
{
ttsbegin;
salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::PackingSlip, VersioningUpdateType::Initial);
salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
salesFormLetterParmData.createData(false);
salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
salesParmTable.clear();
salesParmTable.TransDate = PackingSlipDate;
salesParmTable.Ordering = DocumentStatus::PackingSlip;
salesParmTable.ParmJobStatus = ParmJobStatus::Waiting;
salesParmTable.salesId = salesTable.salesId;
salesParmTable.salesName = salesTable.salesName;
salesParmTable.DeliveryName = salesTable.DeliveryName;
salesParmTable.DeliveryPostalAddress = salesTable.DeliveryPostalAddress;
salesParmTable.CustAccount = salesTable.CustAccount;
salesParmTable.CurrencyCode = salesTable.CurrencyCode;
salesParmTable.InvoiceAccount = salesTable.InvoiceAccount;
salesParmTable.ParmId = salesParmUpdate.ParmId;
salesParmTable.insert();
while select salesLine where salesLine.SalesId == salestable.SalesId
{
salesParmLine.InitFromsalesLine(salesLine);
salesParmLine.DeliverNow = salesLine.SalesQty;
salesParmLine.ParmId = salesParmTable.ParmId;
salesParmLine.TableRefId = salesParmTable.TableRefId;
salesParmLine.setQty(DocumentStatus::PackingSlip, false, true);
salesParmLine.setLineAmount(salesLine);
salesParmLine.insert();
}
salesFormLetter_PackingSlip = salesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter_PackingSlip.transDate(PackingSlipDate);
salesFormLetter_PackingSlip.proforma(false);
salesFormLetter_PackingSlip.specQty(salesUpdate::All);
salesFormLetter_PackingSlip.salesTable(salesTable);
salesFormLetter_PackingSlip.parmId(salesParmTable.ParmId);
salesFormLetter_PackingSlip.salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
salesFormLetter_PackingSlip.run();
if (salesFormLetter_PackingSlip.parmJournalRecord().TableId == tableNum(custPackingSlipJour))
{
custPackingSlipJour = salesFormLetter_PackingSlip.parmJournalRecord();
info(custPackingSlipJour.PackingSlipId);
}
ttscommit;
}
Solution - 2
---------------------
class Test_PostPackingSlip
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
SalesTable _SalesTable;
CustPackingSlipJour custPackingSlipJour;
str datepost = "08/12/2019";
TransDate PackingSlipDate = str2Date(datepost, 213);
SalesFormLetter_PackingSlip salesFormLetter_PackingSlip;
ttsbegin;
_SalesTable = SalesTable::find("SO00125117");
if (_SalesTable && _SalesTable.SalesStatus == SalesStatus::Backorder)
{
salesFormLetter_PackingSlip = SalesFormLetter::construct(DocumentStatus::PackingSlip);
// Post the invoice
salesFormLetter_PackingSlip.update(_SalesTable, PackingSlipDate, SalesUpdate::All, AccountOrder::None, false, false); // Set to true to print the packingslip
}
if (salesFormLetter_PackingSlip.parmJournalRecord().TableId == tableNum(custPackingSlipJour))
{
custPackingSlipJour = salesFormLetter_PackingSlip.parmJournalRecord();
info(custPackingSlipJour.PackingSlipId);
}
ttsCommit;
}
}
Solution - 3
------------------
class SW_TestClass
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
MenuFunction menuFunction;
salestable _SalesTable = SalesTable::find("SO00125111");
Args args = new Args();
args.record(_SalesTable);
menuFunction = new MenuFunction(menuitemActionStr(SalesFormLetter_PackingSlip), MenuItemType::Action);
if (menuFunction && menuFunction.checkAccessRights())
{
menuFunction.run(args);
}
}
}
Solution - 1 - The best way to post packing slips
---------------------
//Variable declaration
SalesFormLetter_PackingSlip salesFormLetter_PackingSlip;
salesFormLetter salesFormLetter;
salesFormletterParmData salesFormLetterParmData;
SalesParmTable salesParmTable;
SalesParmLine salesParmLine;
salesLine salesLine, salesLineUpd;
salesParmUpdate salesParmUpdate;
SalesTable salestable = SalesTable::find(_SalesTable.SalesId, true);
CustPackingSlipJour custPackingSlipJour;
TransDate PackingSlipDate = str2Date(dataContract.parmPackinSlipDate(), 213);
;
//Code starts from here
if (salestable && salestable.SalesStatus == SalesStatus::Backorder)
{
ttsbegin;
salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::PackingSlip, VersioningUpdateType::Initial);
salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
salesFormLetterParmData.createData(false);
salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
salesParmTable.clear();
salesParmTable.TransDate = PackingSlipDate;
salesParmTable.Ordering = DocumentStatus::PackingSlip;
salesParmTable.ParmJobStatus = ParmJobStatus::Waiting;
salesParmTable.salesId = salesTable.salesId;
salesParmTable.salesName = salesTable.salesName;
salesParmTable.DeliveryName = salesTable.DeliveryName;
salesParmTable.DeliveryPostalAddress = salesTable.DeliveryPostalAddress;
salesParmTable.CustAccount = salesTable.CustAccount;
salesParmTable.CurrencyCode = salesTable.CurrencyCode;
salesParmTable.InvoiceAccount = salesTable.InvoiceAccount;
salesParmTable.ParmId = salesParmUpdate.ParmId;
salesParmTable.insert();
while select salesLine where salesLine.SalesId == salestable.SalesId
{
salesParmLine.InitFromsalesLine(salesLine);
salesParmLine.DeliverNow = salesLine.SalesQty;
salesParmLine.ParmId = salesParmTable.ParmId;
salesParmLine.TableRefId = salesParmTable.TableRefId;
salesParmLine.setQty(DocumentStatus::PackingSlip, false, true);
salesParmLine.setLineAmount(salesLine);
salesParmLine.insert();
}
salesFormLetter_PackingSlip = salesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter_PackingSlip.transDate(PackingSlipDate);
salesFormLetter_PackingSlip.proforma(false);
salesFormLetter_PackingSlip.specQty(salesUpdate::All);
salesFormLetter_PackingSlip.salesTable(salesTable);
salesFormLetter_PackingSlip.parmId(salesParmTable.ParmId);
salesFormLetter_PackingSlip.salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
salesFormLetter_PackingSlip.run();
if (salesFormLetter_PackingSlip.parmJournalRecord().TableId == tableNum(custPackingSlipJour))
{
custPackingSlipJour = salesFormLetter_PackingSlip.parmJournalRecord();
info(custPackingSlipJour.PackingSlipId);
}
ttscommit;
}
Solution - 2
---------------------
class Test_PostPackingSlip
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
SalesTable _SalesTable;
CustPackingSlipJour custPackingSlipJour;
str datepost = "08/12/2019";
TransDate PackingSlipDate = str2Date(datepost, 213);
SalesFormLetter_PackingSlip salesFormLetter_PackingSlip;
ttsbegin;
_SalesTable = SalesTable::find("SO00125117");
if (_SalesTable && _SalesTable.SalesStatus == SalesStatus::Backorder)
{
salesFormLetter_PackingSlip = SalesFormLetter::construct(DocumentStatus::PackingSlip);
// Post the invoice
salesFormLetter_PackingSlip.update(_SalesTable, PackingSlipDate, SalesUpdate::All, AccountOrder::None, false, false); // Set to true to print the packingslip
}
if (salesFormLetter_PackingSlip.parmJournalRecord().TableId == tableNum(custPackingSlipJour))
{
custPackingSlipJour = salesFormLetter_PackingSlip.parmJournalRecord();
info(custPackingSlipJour.PackingSlipId);
}
ttsCommit;
}
}
Solution - 3
------------------
class SW_TestClass
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
MenuFunction menuFunction;
salestable _SalesTable = SalesTable::find("SO00125111");
Args args = new Args();
args.record(_SalesTable);
menuFunction = new MenuFunction(menuitemActionStr(SalesFormLetter_PackingSlip), MenuItemType::Action);
if (menuFunction && menuFunction.checkAccessRights())
{
menuFunction.run(args);
}
}
}
Seed Packing, Pharma Packing, Food Packing Visit Us At
ReplyDeletecontract packing
I like models private text. It can be really good to seek out a person demonstrate around thoughts within the main and perhaps wholesomeness in such a special vitally important market might be effortlessly expert. Finance
ReplyDeleteThis latest is called commercial form because of transmitting the sources to others, but even in this occasion, it is the element of financial system of the manufacture and corporation. finmaxfx.com
ReplyDeletefind that only the nice brokers stay in the forex trading industry. On an individual level nevertheless online forex trading
ReplyDeleteThis latest is called commercial form because of transmitting the sources to others, but even in this occasion, it is the element of financial system of the manufacture and corporation.ubanker
ReplyDeleteReally appreciate your work and thank you.
ReplyDeleteI am using the solution 1 mentioned above and its failed once the packing slip has been cancelled.
Can you please verify the same? I am also trying to find. I am using PU 41.
Thanks for sharing us.
ReplyDeletepożyczka w 5 minut bez zaświadczeń