class NECInventoryOnhandReportDP extends SrsReportDataProviderPreProcessTempDB
{
NECInventoryOnhandTmp NECInventoryOnhandTmp, tmpTable;
InventSum inventSum, inventSumLocation, inventSumDim;
InventDim inventDim, inventDimFilter;
InventItemGroupItem inventItemGroupItem;
InventTable inventTable;
ReqItemTable reqItemTable;
NECInventoryOnhandReportContract contract;
ItemId itemId;
ItemGroupId itemGroupId;
EcoResCategoryId ecoResCategoryId;
NoYesId onhandStock;
InventLocationIdReqMain inventLocationIdReqMain;
EcoResProductCategory ecoResProductCategoryItem;
EcoResCategory ecoResCategoryItem;
str warehouse;
InventDimId inventDimId;
WHSInventStatus whsInventStatus;
QueryBuildDataSource qbdsInventTable;
//added by Naresh 4/10/2018 -start
Name warehousename;
InventBatchId batchnumber;
//Description transitid;
Qty transitqty;
InventLocation inventLocation;
InventSum inventsumqty;
InventDim inventDim1;
InventTransferTable inventTransferTable;
InventTransferLine inventTransferLine;
InventTrans inventTrans;
//added by Naresh 4/10/2018 -end
QueryBuildRange qbr;
QueryRun qr;
Query query = new Query();
[
SRSReportDataSetAttribute(tableStr(NECInventoryOnhandTmp))
]
public NECInventoryOnhandTmp getNECInventoryOnhandTmp()
{
select NECInventoryOnhandTmp;
return NECInventoryOnhandTmp;
}
public void processReport()
{
contract = this.parmDataContract() as NECInventoryOnhandReportContract;
itemId = contract.parmItemId();
itemGroupId = contract.parmItemGroupId();
ecoResCategoryId = contract.parmEcoResCategoryId();
onhandStock = contract.parmonhandStock();
inventLocationIdReqMain = contract.parmInventLocationIdReqMain();
qbdsInventTable = query.addDataSource(Tablenum(InventTable));
if(itemId != null)
{
qbdsInventTable.addRange(fieldnum(InventTable, ItemId)).value(itemId);
}
qr = new QueryRun(query);
this.runStatement();
}
private void runStatement()
{
//NS by NK on 29032018
while (qr.next())
{
inventTable = qr.get(tablenum(InventTable));
if(inventItemGroupItem)
{
select firstonly inventItemGroupItem
where inventItemGroupItem.ItemId == inventTable.ItemId
&& inventItemGroupItem.ItemGroupId == itemGroupId;
}
if(ecoResCategoryId)
{
select firstonly ecoResProductCategoryItem
where ecoResProductCategoryItem.Product == inventTable.Product
&& ecoResProductCategoryItem.Category == ecoResCategoryId;
}
while select AvailPhysical,PhysicalInvent,PostedValue from inventsum
where inventsum.Closed == NoYes::No
&& inventsum.ClosedQty == NoYes::No
&& inventsum.ItemId == inventTable.itemId
join inventDimFilter
// group by #InventDimGroupAllFields
where inventSum.InventDimId == inventDimFilter.InventDimId
&& inventDimFilter.InventLocationId
{
select firstonly whsInventStatus
where whsInventStatus.InventStatusId == inventDimFilter.InventStatusId;
if(((inventSum.AvailPhysical >=0 && onhandStock == true )|| (inventSum.AvailPhysical <= 0 && onhandStock == false)) &&
((inventLocationIdReqMain != null && inventLocationIdReqMain == inventDimFilter.InventLocationId) || !inventLocationIdReqMain ) &&
((itemGroupId != null && inventItemGroupItem) || !itemGroupId) &&
((ecoResCategoryId != 0 && ecoResProductCategoryItem) || !ecoResCategoryId)
&& ((whsInventStatus && whsInventStatus.InventStatusBlocking == False) || !whsInventStatus))
{
ttsbegin;
select firstonly forupdate NECInventoryOnhandTmp
where NECInventoryOnhandTmp.ItemId == inventTable.ItemId
&& NECInventoryOnhandTmp.InventLocationIdReqMain == inventDimFilter.InventLocationId;
if(NECInventoryOnhandTmp)
{
NECInventoryOnhandTmp.InventQtyPhysicalOnhand += inventSum.AvailPhysical;
//added by naresh 4/12/2018 - start
NECInventoryOnhandTmp.AvailablePhysical += inventSum.AvailPhysical;
NECInventoryOnhandTmp.PhysicalInventory += inventSum.PhysicalInvent;
NECInventoryOnhandTmp.financialCostAmount += inventSum.PostedValue;
//added by naresh 4/12/2018 - end
NECInventoryOnhandTmp.update();
}
else
{
inventDimId = inventDimFilter.inventDimId;
warehouse = inventDimFilter.InventLocationId;
//added by Naresh 4/12/2018 -start
batchnumber = inventdimfilter.inventbatchid;
transitqty = 0.0;
select inventlocation
where inventlocation.inventlocationid == warehouse;
if(inventlocation.inventlocationid)
{
warehousename = inventLocation.Name;
while select inventTransferTable
where inventTransferTable.InventLocationIdTransit == inventlocation.InventLocationIdTransit
&& inventTransferTable.InventLocationIdFrom == inventlocation.InventLocationId
&& inventTransferTable.TransferStatus == InventTransferStatus::Shipped
join inventTransferLine
where inventTransferLine.TransferId == inventTransferTable.TransferId
&& inventTransferLine.ItemId == inventTable.ItemId
if(inventTransferLine.TransferId)
{
transitqty += inventTransferLine.QtyShipped;
}
}
//added by Naresh 4/12/2018 -end
this.insertTmp();
}
ttscommit;
}
}
}
//NE by NK on 29032018
}
public void insertTmp()
{
ReqItemTable reqItemTableCurrent;
InventDim inventDimInventLocation;
NECInventoryOnhandTmp.clear();
NECInventoryOnhandTmp.ItemId = inventTable.ItemId;
NECInventoryOnhandTmp.ItemName = inventTable.itemName();
NECInventoryOnhandTmp.InventLocationIdReqMain = warehouse;
//added by naresh 4/11/2018 - start
NECInventoryOnhandTmp.inventBatchId = batchnumber;
NECInventoryOnhandTmp.Name = warehousename;
NECInventoryOnhandTmp.TransitTransfer = transitqty;
NECInventoryOnhandTmp.AvailablePhysical = inventSum.AvailPhysical;
NECInventoryOnhandTmp.PhysicalInventory = inventSum.PhysicalInvent;
NECInventoryOnhandTmp.financialCostAmount = inventSum.PostedValue;
//added by naresh 4/11/2018 - start
NECInventoryOnhandTmp.InventQtyPhysicalOnhand = inventSum.AvailPhysical; // inventSum.physicalInvent;
select firstonly reqItemTableCurrent
where reqItemTableCurrent.ItemId == NECInventoryOnhandTmp.ItemId
join inventDimInventLocation
where inventDimInventLocation.InventdimId == reqItemTableCurrent.CovInventDimId
&& inventDimInventLocation.InventLocationId == warehouse;
if(reqItemTableCurrent)
{
NECInventoryOnhandTmp.ReqGroupId = reqItemTableCurrent.ReqGroupId;
NECInventoryOnhandTmp.InventQtyMinOnhand = reqItemTableCurrent.MinInventOnhand;
NECInventoryOnhandTmp.InventQtyMaxOnhand = reqItemTableCurrent.MaxInventOnhand;
}
this.insertProductCategories(inventTable.ItemId);
NECInventoryOnhandTmp.SIP = this.getSIP(inventTable.ItemId);
NECInventoryOnhandTmp.insert();
}
private void insertProductCategories(ItemId _itemId)
{
EcoResProductCategory EcoResProductCategory;
EcoResCategory EcoResCategory,EcoResCategoryNext;
EcoResCategoryId parentCategory;
int i = 0;
List li = new List(Types::String);
ListEnumerator enumer;
NECInventoryOnhandTmp.EcoResCategoryName1 = "";
NECInventoryOnhandTmp.EcoResCategoryName2 = "";
NECInventoryOnhandTmp.EcoResCategoryName3 = "";
NECInventoryOnhandTmp.EcoResCategoryName4 = "";
NECInventoryOnhandTmp.EcoResCategoryName5 = "";
select * from EcoResCategory
join RecId from EcoResProductCategory
where EcoResCategory.RecId == EcoResProductCategory.Category
&& EcoResProductCategory.Product == InventTable::find(_itemId).Product;
parentCategory = EcoResCategory.ParentCategory;
li.addStart(EcoResCategory.Name);
while (parentCategory)
{
select * from EcoResCategory
where EcoResCategory.RecId == parentCategory;
parentCategory = EcoResCategory.ParentCategory;
li.addStart(EcoResCategory.Name);
}
enumer = li.getEnumerator();
while (enumer.moveNext())
{
i++;
if(i==1)
{
NECInventoryOnhandTmp.EcoResCategoryName5 = enumer.current();
}
else if(i==2)
{
NECInventoryOnhandTmp.EcoResCategoryName4 = enumer.current();
}
else if(i==3)
{
NECInventoryOnhandTmp.EcoResCategoryName3 = enumer.current();
}
else if(i==4)
{
NECInventoryOnhandTmp.EcoResCategoryName2 = enumer.current();
}
else if(i==5)
{
NECInventoryOnhandTmp.EcoResCategoryName1 = enumer.current();
}
}
}
public str getSIP(ItemId _itemId)
{
Str sales, Invent, purch;
str SIP;
sales = InventItemSalesSetup::findDefault(_itemId).Stopped == true ? "Y" : "N";
invent = InventItemInventSetup::findDefault(_itemId).Stopped == true ? "Y" : "N";
purch = InventItemPurchSetup::findDefault(_itemId).Stopped == true ? "Y" : "N";
SIP = strfmt("%1%2%3", sales, invent, purch);
if(SIP == "NNN")
{
SIP = "ACT";
}
else if(SIP == "YYY")
{
SIP = "INA";
}
return SIP;
}
public static NECInventoryOnhandReportDP construct()
{
return new NECInventoryOnhandReportDP();
}
}
{
NECInventoryOnhandTmp NECInventoryOnhandTmp, tmpTable;
InventSum inventSum, inventSumLocation, inventSumDim;
InventDim inventDim, inventDimFilter;
InventItemGroupItem inventItemGroupItem;
InventTable inventTable;
ReqItemTable reqItemTable;
NECInventoryOnhandReportContract contract;
ItemId itemId;
ItemGroupId itemGroupId;
EcoResCategoryId ecoResCategoryId;
NoYesId onhandStock;
InventLocationIdReqMain inventLocationIdReqMain;
EcoResProductCategory ecoResProductCategoryItem;
EcoResCategory ecoResCategoryItem;
str warehouse;
InventDimId inventDimId;
WHSInventStatus whsInventStatus;
QueryBuildDataSource qbdsInventTable;
//added by Naresh 4/10/2018 -start
Name warehousename;
InventBatchId batchnumber;
//Description transitid;
Qty transitqty;
InventLocation inventLocation;
InventSum inventsumqty;
InventDim inventDim1;
InventTransferTable inventTransferTable;
InventTransferLine inventTransferLine;
InventTrans inventTrans;
//added by Naresh 4/10/2018 -end
QueryBuildRange qbr;
QueryRun qr;
Query query = new Query();
[
SRSReportDataSetAttribute(tableStr(NECInventoryOnhandTmp))
]
public NECInventoryOnhandTmp getNECInventoryOnhandTmp()
{
select NECInventoryOnhandTmp;
return NECInventoryOnhandTmp;
}
public void processReport()
{
contract = this.parmDataContract() as NECInventoryOnhandReportContract;
itemId = contract.parmItemId();
itemGroupId = contract.parmItemGroupId();
ecoResCategoryId = contract.parmEcoResCategoryId();
onhandStock = contract.parmonhandStock();
inventLocationIdReqMain = contract.parmInventLocationIdReqMain();
qbdsInventTable = query.addDataSource(Tablenum(InventTable));
if(itemId != null)
{
qbdsInventTable.addRange(fieldnum(InventTable, ItemId)).value(itemId);
}
qr = new QueryRun(query);
this.runStatement();
}
private void runStatement()
{
//NS by NK on 29032018
while (qr.next())
{
inventTable = qr.get(tablenum(InventTable));
if(inventItemGroupItem)
{
select firstonly inventItemGroupItem
where inventItemGroupItem.ItemId == inventTable.ItemId
&& inventItemGroupItem.ItemGroupId == itemGroupId;
}
if(ecoResCategoryId)
{
select firstonly ecoResProductCategoryItem
where ecoResProductCategoryItem.Product == inventTable.Product
&& ecoResProductCategoryItem.Category == ecoResCategoryId;
}
while select AvailPhysical,PhysicalInvent,PostedValue from inventsum
where inventsum.Closed == NoYes::No
&& inventsum.ClosedQty == NoYes::No
&& inventsum.ItemId == inventTable.itemId
join inventDimFilter
// group by #InventDimGroupAllFields
where inventSum.InventDimId == inventDimFilter.InventDimId
&& inventDimFilter.InventLocationId
{
select firstonly whsInventStatus
where whsInventStatus.InventStatusId == inventDimFilter.InventStatusId;
if(((inventSum.AvailPhysical >=0 && onhandStock == true )|| (inventSum.AvailPhysical <= 0 && onhandStock == false)) &&
((inventLocationIdReqMain != null && inventLocationIdReqMain == inventDimFilter.InventLocationId) || !inventLocationIdReqMain ) &&
((itemGroupId != null && inventItemGroupItem) || !itemGroupId) &&
((ecoResCategoryId != 0 && ecoResProductCategoryItem) || !ecoResCategoryId)
&& ((whsInventStatus && whsInventStatus.InventStatusBlocking == False) || !whsInventStatus))
{
ttsbegin;
select firstonly forupdate NECInventoryOnhandTmp
where NECInventoryOnhandTmp.ItemId == inventTable.ItemId
&& NECInventoryOnhandTmp.InventLocationIdReqMain == inventDimFilter.InventLocationId;
if(NECInventoryOnhandTmp)
{
NECInventoryOnhandTmp.InventQtyPhysicalOnhand += inventSum.AvailPhysical;
//added by naresh 4/12/2018 - start
NECInventoryOnhandTmp.AvailablePhysical += inventSum.AvailPhysical;
NECInventoryOnhandTmp.PhysicalInventory += inventSum.PhysicalInvent;
NECInventoryOnhandTmp.financialCostAmount += inventSum.PostedValue;
//added by naresh 4/12/2018 - end
NECInventoryOnhandTmp.update();
}
else
{
inventDimId = inventDimFilter.inventDimId;
warehouse = inventDimFilter.InventLocationId;
//added by Naresh 4/12/2018 -start
batchnumber = inventdimfilter.inventbatchid;
transitqty = 0.0;
select inventlocation
where inventlocation.inventlocationid == warehouse;
if(inventlocation.inventlocationid)
{
warehousename = inventLocation.Name;
while select inventTransferTable
where inventTransferTable.InventLocationIdTransit == inventlocation.InventLocationIdTransit
&& inventTransferTable.InventLocationIdFrom == inventlocation.InventLocationId
&& inventTransferTable.TransferStatus == InventTransferStatus::Shipped
join inventTransferLine
where inventTransferLine.TransferId == inventTransferTable.TransferId
&& inventTransferLine.ItemId == inventTable.ItemId
if(inventTransferLine.TransferId)
{
transitqty += inventTransferLine.QtyShipped;
}
}
//added by Naresh 4/12/2018 -end
this.insertTmp();
}
ttscommit;
}
}
}
//NE by NK on 29032018
}
public void insertTmp()
{
ReqItemTable reqItemTableCurrent;
InventDim inventDimInventLocation;
NECInventoryOnhandTmp.clear();
NECInventoryOnhandTmp.ItemId = inventTable.ItemId;
NECInventoryOnhandTmp.ItemName = inventTable.itemName();
NECInventoryOnhandTmp.InventLocationIdReqMain = warehouse;
//added by naresh 4/11/2018 - start
NECInventoryOnhandTmp.inventBatchId = batchnumber;
NECInventoryOnhandTmp.Name = warehousename;
NECInventoryOnhandTmp.TransitTransfer = transitqty;
NECInventoryOnhandTmp.AvailablePhysical = inventSum.AvailPhysical;
NECInventoryOnhandTmp.PhysicalInventory = inventSum.PhysicalInvent;
NECInventoryOnhandTmp.financialCostAmount = inventSum.PostedValue;
//added by naresh 4/11/2018 - start
NECInventoryOnhandTmp.InventQtyPhysicalOnhand = inventSum.AvailPhysical; // inventSum.physicalInvent;
select firstonly reqItemTableCurrent
where reqItemTableCurrent.ItemId == NECInventoryOnhandTmp.ItemId
join inventDimInventLocation
where inventDimInventLocation.InventdimId == reqItemTableCurrent.CovInventDimId
&& inventDimInventLocation.InventLocationId == warehouse;
if(reqItemTableCurrent)
{
NECInventoryOnhandTmp.ReqGroupId = reqItemTableCurrent.ReqGroupId;
NECInventoryOnhandTmp.InventQtyMinOnhand = reqItemTableCurrent.MinInventOnhand;
NECInventoryOnhandTmp.InventQtyMaxOnhand = reqItemTableCurrent.MaxInventOnhand;
}
this.insertProductCategories(inventTable.ItemId);
NECInventoryOnhandTmp.SIP = this.getSIP(inventTable.ItemId);
NECInventoryOnhandTmp.insert();
}
private void insertProductCategories(ItemId _itemId)
{
EcoResProductCategory EcoResProductCategory;
EcoResCategory EcoResCategory,EcoResCategoryNext;
EcoResCategoryId parentCategory;
int i = 0;
List li = new List(Types::String);
ListEnumerator enumer;
NECInventoryOnhandTmp.EcoResCategoryName1 = "";
NECInventoryOnhandTmp.EcoResCategoryName2 = "";
NECInventoryOnhandTmp.EcoResCategoryName3 = "";
NECInventoryOnhandTmp.EcoResCategoryName4 = "";
NECInventoryOnhandTmp.EcoResCategoryName5 = "";
select * from EcoResCategory
join RecId from EcoResProductCategory
where EcoResCategory.RecId == EcoResProductCategory.Category
&& EcoResProductCategory.Product == InventTable::find(_itemId).Product;
parentCategory = EcoResCategory.ParentCategory;
li.addStart(EcoResCategory.Name);
while (parentCategory)
{
select * from EcoResCategory
where EcoResCategory.RecId == parentCategory;
parentCategory = EcoResCategory.ParentCategory;
li.addStart(EcoResCategory.Name);
}
enumer = li.getEnumerator();
while (enumer.moveNext())
{
i++;
if(i==1)
{
NECInventoryOnhandTmp.EcoResCategoryName5 = enumer.current();
}
else if(i==2)
{
NECInventoryOnhandTmp.EcoResCategoryName4 = enumer.current();
}
else if(i==3)
{
NECInventoryOnhandTmp.EcoResCategoryName3 = enumer.current();
}
else if(i==4)
{
NECInventoryOnhandTmp.EcoResCategoryName2 = enumer.current();
}
else if(i==5)
{
NECInventoryOnhandTmp.EcoResCategoryName1 = enumer.current();
}
}
}
public str getSIP(ItemId _itemId)
{
Str sales, Invent, purch;
str SIP;
sales = InventItemSalesSetup::findDefault(_itemId).Stopped == true ? "Y" : "N";
invent = InventItemInventSetup::findDefault(_itemId).Stopped == true ? "Y" : "N";
purch = InventItemPurchSetup::findDefault(_itemId).Stopped == true ? "Y" : "N";
SIP = strfmt("%1%2%3", sales, invent, purch);
if(SIP == "NNN")
{
SIP = "ACT";
}
else if(SIP == "YYY")
{
SIP = "INA";
}
return SIP;
}
public static NECInventoryOnhandReportDP construct()
{
return new NECInventoryOnhandReportDP();
}
}
This is a very interesting web page and I have enjoyed reading many of the articles and posts contained on the website, keep up the good work and hope to read some more interesting content in the future.
ReplyDeleteAsset Management Software
Fixed Asset Management Software
Asset Tracking Software
Asset Management System
Asset Management Software UAE