// Cancel Purchase Order
--> Open order Purchase order line
-->Partial Product Receipt line also through x++
private void toCancelPo()
{
//info(strFmt("%1 -- %2 ",transDate,purchaseOrder));
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbrPurchId,qbrDate;
QueryRun qr;
List _list = New List(Types::String);
ListIterator lt;
str 100 PurchNumber;
;
query = new query();
qbds= query.addDataSource(tableNum(PurchTable));
qbds.addRange(fieldNum(PurchTable,PurchaseType)).value("Purch");
qbds.addRange(fieldNum(PurchTable,PurchStatus)).value("Backorder");
if (transDate != dateNull())
{
qbds.addRange(fieldNum(PurchTable,CreatedDateTime)).value(SysQuery::range(fromdate,transDate));
}
//info(strFmt("%1 -- %2 -- %3",fromdate,transDate,purchaseOrder));
//qbds.addRange(fieldNum(PurchTable,OrderAccount)).value("R0003");
if (purchaseOrder != "")
{
_list = Global::strSplit(purchaseOrder,";");
lt = new ListIterator(_list);
while(lt.more())
{
purchNum += lt.value();
lt.next();
}
for(i = 0; i<= conLen(purchNum);i++)
{
PurchNumber = conPeek(purchNum,i);
qbds.addRange(fieldNum(PurchTable,PurchId)).value(PurchNumber);
}
}
qr = new QueryRun(query);
while(qr.next())
{
purchTable = qr.get(tableNum(PurchTable));
ttsBegin;
while select forupdate purchLine
where purchLine.PurchId == purchTable.PurchId
&& purchLine.PurchStatus == PurchStatus::Backorder
join inventTrans
join inventTransOrigin
where inventTransOrigin.RecId == inventTrans.InventTransOrigin
&& inventTransOrigin.InventTransId == purchLine.InventTransId
{
//while select
//{
if(inventTrans.StatusReceipt == StatusReceipt::Ordered)
{
//purchLine.selectForUpdate(true);
purchLine.RemainInventPhysical = 0.00;
purchLine.RemainPurchPhysical = 0.00;
purchLine.reread();
purchLine.update();
InventMovement::bufferSetRemainQty(purchLine);
}
// }
}
ttsCommit;
}
}
--> Open order Purchase order line
-->Partial Product Receipt line also through x++
private void toCancelPo()
{
//info(strFmt("%1 -- %2 ",transDate,purchaseOrder));
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbrPurchId,qbrDate;
QueryRun qr;
List _list = New List(Types::String);
ListIterator lt;
str 100 PurchNumber;
;
query = new query();
qbds= query.addDataSource(tableNum(PurchTable));
qbds.addRange(fieldNum(PurchTable,PurchaseType)).value("Purch");
qbds.addRange(fieldNum(PurchTable,PurchStatus)).value("Backorder");
if (transDate != dateNull())
{
qbds.addRange(fieldNum(PurchTable,CreatedDateTime)).value(SysQuery::range(fromdate,transDate));
}
//info(strFmt("%1 -- %2 -- %3",fromdate,transDate,purchaseOrder));
//qbds.addRange(fieldNum(PurchTable,OrderAccount)).value("R0003");
if (purchaseOrder != "")
{
_list = Global::strSplit(purchaseOrder,";");
lt = new ListIterator(_list);
while(lt.more())
{
purchNum += lt.value();
lt.next();
}
for(i = 0; i<= conLen(purchNum);i++)
{
PurchNumber = conPeek(purchNum,i);
qbds.addRange(fieldNum(PurchTable,PurchId)).value(PurchNumber);
}
}
qr = new QueryRun(query);
while(qr.next())
{
purchTable = qr.get(tableNum(PurchTable));
ttsBegin;
while select forupdate purchLine
where purchLine.PurchId == purchTable.PurchId
&& purchLine.PurchStatus == PurchStatus::Backorder
join inventTrans
join inventTransOrigin
where inventTransOrigin.RecId == inventTrans.InventTransOrigin
&& inventTransOrigin.InventTransId == purchLine.InventTransId
{
//while select
//{
if(inventTrans.StatusReceipt == StatusReceipt::Ordered)
{
//purchLine.selectForUpdate(true);
purchLine.RemainInventPhysical = 0.00;
purchLine.RemainPurchPhysical = 0.00;
purchLine.reread();
purchLine.update();
InventMovement::bufferSetRemainQty(purchLine);
}
// }
}
ttsCommit;
}
}
No comments:
Post a Comment