The following code gives an idea on how to create inbound load for outbound load. I added this method in the WHSShipConfirm.shipConfirmAllLoads() method. This is not the full code, but tells how I take the outbound load, create an inbound load in the other company and then use the whsInventTransSumDim table to get the sales line and create lines for that.
public void InterCompanyLoadCreate(WHSLoadTable outboundLoadTable)
{
WHSLoadTable loadTableInterCompany;
if (CustTable::find(OutBoundLoadTable.AccountNum).interCompanyTradingRelationActive())
{
changeCompany(CustTable::find(OutBoundLoadTable.AccountNum).interCompanyTradingPartnerCompanyID())
{
loadTableInterCompany.setLoadId();
loadTableInterCompany.LoadDirection = WHSLoadDirection::Inbound;
loadTableInterCompany.initFromLoadTemplateId(OutBoundLoadTable.LoadTemplateId);
loadTableInterCompany.LoadPaysFreight = NoYes::No;
loadTableInterCompany.InterCompanyCompanyId = OutBoundLoadTable.dataAreaId; //field created
loadTableInterCompany.InterCompanyLoadID = OutBoundLoadTable.LoadId;//field created
loadTableInterCompany.InterCompanyOrder = NoYes::Yes;//field created
loadTableInterCompany.assignOriginInfo(AddRemove::Add);
loadTableInterCompany.insert();
}
}
if (loadTableInterCompany)
{
while select whsloadLine
where whsloadLine.LoadId == OutBoundLoadTable.LoadId
{
select salesLine
where salesLine.InventTransId == whsloadLine.InventTransId;
select crossCompany WHSInventTransSumDim
where WHSInventTransSumDim.InventTransId == salesLine.InterCompanyInventTransId;
if (WHSInventTransSumDim)
{
changeCompany(loadTableInterCompany.dataAreaID)
this.parmLoadPlanningWorkbenchServerForm().createTmpLoadLinesPurchLines(false,WHSInventTransSumDim,counter);
++counter;
}
}
changeCompany(loadTableInterCompany.dataAreaId)
{
this.parmLoadPlanningWorkbenchServerForm().addLoadLines(loadTableInterCompany);
}
//add code to delete the created inbound load if no lines are created
}
}
public void InterCompanyLoadCreate(WHSLoadTable outboundLoadTable)
{
WHSLoadTable loadTableInterCompany;
if (CustTable::find(OutBoundLoadTable.AccountNum).interCompanyTradingRelationActive())
{
changeCompany(CustTable::find(OutBoundLoadTable.AccountNum).interCompanyTradingPartnerCompanyID())
{
loadTableInterCompany.setLoadId();
loadTableInterCompany.LoadDirection = WHSLoadDirection::Inbound;
loadTableInterCompany.initFromLoadTemplateId(OutBoundLoadTable.LoadTemplateId);
loadTableInterCompany.LoadPaysFreight = NoYes::No;
loadTableInterCompany.InterCompanyCompanyId = OutBoundLoadTable.dataAreaId; //field created
loadTableInterCompany.InterCompanyLoadID = OutBoundLoadTable.LoadId;//field created
loadTableInterCompany.InterCompanyOrder = NoYes::Yes;//field created
loadTableInterCompany.assignOriginInfo(AddRemove::Add);
loadTableInterCompany.insert();
}
}
if (loadTableInterCompany)
{
while select whsloadLine
where whsloadLine.LoadId == OutBoundLoadTable.LoadId
{
select salesLine
where salesLine.InventTransId == whsloadLine.InventTransId;
select crossCompany WHSInventTransSumDim
where WHSInventTransSumDim.InventTransId == salesLine.InterCompanyInventTransId;
if (WHSInventTransSumDim)
{
changeCompany(loadTableInterCompany.dataAreaID)
this.parmLoadPlanningWorkbenchServerForm().createTmpLoadLinesPurchLines(false,WHSInventTransSumDim,counter);
++counter;
}
}
changeCompany(loadTableInterCompany.dataAreaId)
{
this.parmLoadPlanningWorkbenchServerForm().addLoadLines(loadTableInterCompany);
}
//add code to delete the created inbound load if no lines are created
}
}
No comments:
Post a Comment