Note: In the below code, I am calling it from .Net using WCF parameter.
[SysEntryPointAttribute(true),
AifCollectionTypeAttribute('return', Types::String)]
public SalesId salesLineCancel(AMSSalesOrderContract _SOContract)
{
boolean ret;
SalesId lSalesID;
SalesLine lSalesLine;
InventTrans lInventTrans;
str errorStr;
errorStr = this.validateInterfaceData(_SOContract);
if ( errorStr!= "")
{
return errorStr;
}
try
{
/////////////////// CHANGE COMPANY/////////////////////
changeCompany(_SOContract.company())
{
//Validate data
errorStr = this.validateData(_SOContract);
if (errorStr != "")
{
return errorStr;
}
ttsBegin;
//Add your own logic to select and pass a specific sales line.
lSalesLine.clear();
if (literator != null)
{
lSalesLineContract = literator.value();
/*select firstOnly forUpdate lSalesLine
where lSalesLine.PurchorderFormNum == lSalesLineContract.purchorderFormNum();*/
select firstOnly forUpdate lSalesLine
where lSalesLine.SalesId == lSalesLineContract.salesId();
}
if(lSalesLine)
{
//lInventTrans = InventTrans::findTransId(lSalesLine.InventTransId);
if ( lSalesLine.SalesStatus != SalesStatus::Backorder)
{
lSalesID = strFmt("@SYS4004577",lSalesLine.SalesId, lSalesLine.SalesStatus );
// ret = SalesUpdateRemain::updateDeliveryRemainder(lSalesLine, 0, 0);
}
//Open order
else
{
//pass three parameters
//1.SalesLine buffer
//2.remainSalesPhysical, pass it as zero as you want to cancel full line
//3.remainInventPhysical, pass it as zero as you want to cancel full line
ret = SalesUpdateRemain::updateDeliveryRemainder(lSalesLine, 0, 0);
if(ret)
{
lSalesID = strFmt("Sales Line # %1: of Sales id # %2 is Canceled",lSalesLine.LineNum, lSalesLine.SalesId);
}
}
}
else
{
lSalesID = strFmt("Sales line not found/Invalid Line");
}
ttsCommit;
}
}
catch
{
error("Sales line got exception while attempting to be cancelled.");
}
return lSalesID;
}
[SysEntryPointAttribute(true),
AifCollectionTypeAttribute('return', Types::String)]
public SalesId salesLineCancel(AMSSalesOrderContract _SOContract)
{
boolean ret;
SalesId lSalesID;
SalesLine lSalesLine;
InventTrans lInventTrans;
str errorStr;
errorStr = this.validateInterfaceData(_SOContract);
if ( errorStr!= "")
{
return errorStr;
}
try
{
/////////////////// CHANGE COMPANY/////////////////////
changeCompany(_SOContract.company())
{
//Validate data
errorStr = this.validateData(_SOContract);
if (errorStr != "")
{
return errorStr;
}
ttsBegin;
//Add your own logic to select and pass a specific sales line.
lSalesLine.clear();
if (literator != null)
{
lSalesLineContract = literator.value();
/*select firstOnly forUpdate lSalesLine
where lSalesLine.PurchorderFormNum == lSalesLineContract.purchorderFormNum();*/
select firstOnly forUpdate lSalesLine
where lSalesLine.SalesId == lSalesLineContract.salesId();
}
if(lSalesLine)
{
//lInventTrans = InventTrans::findTransId(lSalesLine.InventTransId);
if ( lSalesLine.SalesStatus != SalesStatus::Backorder)
{
lSalesID = strFmt("@SYS4004577",lSalesLine.SalesId, lSalesLine.SalesStatus );
// ret = SalesUpdateRemain::updateDeliveryRemainder(lSalesLine, 0, 0);
}
//Open order
else
{
//pass three parameters
//1.SalesLine buffer
//2.remainSalesPhysical, pass it as zero as you want to cancel full line
//3.remainInventPhysical, pass it as zero as you want to cancel full line
ret = SalesUpdateRemain::updateDeliveryRemainder(lSalesLine, 0, 0);
if(ret)
{
lSalesID = strFmt("Sales Line # %1: of Sales id # %2 is Canceled",lSalesLine.LineNum, lSalesLine.SalesId);
}
}
}
else
{
lSalesID = strFmt("Sales line not found/Invalid Line");
}
ttsCommit;
}
}
catch
{
error("Sales line got exception while attempting to be cancelled.");
}
return lSalesID;
}
No comments:
Post a Comment