1)Update Intercompany infomation
void updateNewDimension()
{
/**
Add by Jimmy 2010-07-12
update New dimension
*/
SalesLine UpInterSOCN,UpInterSOHK;
PurchLine _purchLine;
// SalesLine _salesLine;
;
if(salesLine.isInterCompanyOrder())
{
changecompany(salesLine.salesTable().InterCompanyCompanyId)
{
select firstonly _purchLine
index hint PurchLineIdx
where _purchLine.InventTransId == salesLine.InterCompanyInventTransId ;
ttsbegin;
select firstonly forupdate UpInterSOCN
index hint SalesLineIdx
where UpInterSOCN.InventTransId == _purchLine.InventRefTransId;
if (UpInterSOCN)
{
UpInterSOCN.NewDimension = salesLine.NewDimension;
UpInterSOCN.doUpdate();
}
ttscommit;
}
}
else
{
if(salesLine.salesTable().InterCompanyAutoCreateOrders)
{
select firstonly _purchLine
index hint PurchLineIdx
where _purchLine.InventRefTransId == SalesLine.InventTransId;
if (PurchTable::find(_purchLine.PurchId).InterCompanyCompanyId)
{
ChangeCompany(PurchTable::find(_purchLine.PurchId).InterCompanyCompanyId)
{
ttsbegin;
select firstonly forupdate UpInterSOHK
index hint SalesLineIdx
where UpInterSOHK.InventTransId == _purchLine.InterCompanyInventTransId;
if(UpInterSOHK)
{
UpInterSOHK.NewDimension = SalesLine.NewDimension;
UpInterSOHK.doUpdate();
}
ttscommit;
}
}
}
}
}
2)check intercompany delivery date
static void Jimmy_CheckIntercompanyOrderDeliveryDate(Args _args)
{
SalesLine SalesLineHK,SalesLineCN;
PurchLine PurchLineHK;
Container con;
int i;
;
//qcn
setprefix("Different delivery date!");
changecompany("qcn")
{
while select SalesLineCN
where SalesLineCN.SalesStatus == SalesStatus::Backorder
&& SalesLineCN.InterCompanyInventTransId != ""
{
con = ["qhk"];
select firstonly crosscompany:con PurchLineHK
where PurchLineHK.InventTransId == SalesLineCN.InterCompanyInventTransId
&& PurchLineHK.InterCompanyInventTransId != "";
select firstonly crosscompany:con SalesLineHK
where SalesLineHK.SalesId == PurchLineHK.InventRefId //CN SO
&& SalesLineHK.InventRefTransId == PurchLineHK.InventTransId;
if(SalesLineHK)
{
if(SalesLineCN.ConfirmedDlv != SalesLineHK.ConfirmedDlv)
{
i++;
info(strfmt("%6 - SO: %1,ItemId: %2,HK: %3,CN: %4,HK PO: %5",
i,SalesLineHK.SalesId,SalesLineHK.ItemId,SalesLineHK.ConfirmedDlv,
SalesLineCN.ConfirmedDlv,PurchLineHK.DeliveryDate));
}
}
}
}
//qhk
setprefix("Different delivery date!");
changecompany("QHK")
{
while select SalesLineHK
where SalesLineHK.SalesStatus == SalesStatus::Backorder
&& SalesLineHK.InventRefType == InventRefType::Purch
{
PurchLineHK = PurchLine::findInventTransId(SalesLineHK.InventRefTransId);
//if(SalesLineHK.interCompanySalesLineExist())
if(PurchLineHK.InterCompanyInventTransId)
{
CON = ["QCN"];
select firstonly crosscompany:con SalesLineCN
where SalesLineCN.SalesId == SalesLineHK.SalesId
&& SalesLineCN.InterCompanyInventTransId == PurchLineHK.InventTransId;
if(SalesLineCN.ConfirmedDlv != SalesLineHK.ConfirmedDlv)
{
i++;
info(strfmt("%6 - SO: %1,ItemId: %2,HK: %3,CN: %4,HK PO: %5",
i,SalesLineHK.SalesId,SalesLineHK.ItemId,SalesLineHK.ConfirmedDlv,
SalesLineCN.ConfirmedDlv,PurchLineHK.DeliveryDate));
}
}
}
}
info(strfmt("total %1 records",i));
}