here we are assuming that all the lines have been packed and we are going o invoice a single line.
static void Rohit_partialSOWorking(Args _args)
{
//salesTable = SalesTable::find('IN000000456');
salesFormLetter salesFormLetter;
salesFormletterParmData salesFormLetterParmData;
salesParmUpdate salesParmUpdate;
salesParmTable salesParmTable;
salesParmLine salesParmLine;
salesTable salesTable;
salesLine salesLine;
boolean ret;
salesTable = salesTable::find('IN000000456');
try
{
ttsBegin;
// Create salesParamUpdate table
salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Invoice,VersioningUpdateType::Initial);
salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
salesFormLetterParmData.createData(false);
salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
// Set salesParmTable table
salesParmTable.clear();
salesParmTable.TransDate = SystemDateGet();
salesParmTable.Ordering = DocumentStatus::Invoice;
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();
// Set salesParmLine table
select salesLine
where salesLine.salesId == salesTable.salesId
&& salesLine.LineNum == 2;
//&& salesLine.ItemId == _itemId;
{
salesParmLine.InitFromsalesLine(salesLine);
salesParmLine.DeliverNow = 2;
salesParmLine.ParmId = salesParmTable.ParmId;
salesParmLine.TableRefId = salesParmTable.TableRefId;
salesParmLine.setQty(DocumentStatus::Invoice, false, true);
salesParmLine.setLineAmount();
salesParmLine.insert();
}
salesFormLetter = salesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.transDate(systemDateGet());
salesFormLetter.proforma(false);
salesFormLetter.specQty(salesUpdate::All);
salesFormLetter.salesTable(salesTable);
salesFormLetter.parmId(salesParmTable.ParmId);
salesFormLetter.salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
salesFormLetter.run();
ttsCommit;
}
catch (Exception::Error)
{
ret = false;
}
}
static void Rohit_partialSOWorking(Args _args)
{
//salesTable = SalesTable::find('IN000000456');
salesFormLetter salesFormLetter;
salesFormletterParmData salesFormLetterParmData;
salesParmUpdate salesParmUpdate;
salesParmTable salesParmTable;
salesParmLine salesParmLine;
salesTable salesTable;
salesLine salesLine;
boolean ret;
salesTable = salesTable::find('IN000000456');
try
{
ttsBegin;
// Create salesParamUpdate table
salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Invoice,VersioningUpdateType::Initial);
salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
salesFormLetterParmData.createData(false);
salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
// Set salesParmTable table
salesParmTable.clear();
salesParmTable.TransDate = SystemDateGet();
salesParmTable.Ordering = DocumentStatus::Invoice;
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();
// Set salesParmLine table
select salesLine
where salesLine.salesId == salesTable.salesId
&& salesLine.LineNum == 2;
//&& salesLine.ItemId == _itemId;
{
salesParmLine.InitFromsalesLine(salesLine);
salesParmLine.DeliverNow = 2;
salesParmLine.ParmId = salesParmTable.ParmId;
salesParmLine.TableRefId = salesParmTable.TableRefId;
salesParmLine.setQty(DocumentStatus::Invoice, false, true);
salesParmLine.setLineAmount();
salesParmLine.insert();
}
salesFormLetter = salesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.transDate(systemDateGet());
salesFormLetter.proforma(false);
salesFormLetter.specQty(salesUpdate::All);
salesFormLetter.salesTable(salesTable);
salesFormLetter.parmId(salesParmTable.ParmId);
salesFormLetter.salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
salesFormLetter.run();
ttsCommit;
}
catch (Exception::Error)
{
ret = false;
}
}
using above Code getting deadlock error when concurrent users posting from other application to AX via web service : Posting of sales order line wise:
ReplyDeleteCannot edit a record in Sales order line - update table (SalesParmLine). Line number: 0,0000000000.
Deadlock, where one or more users have simultaneously locked the whole table or part of it.