Facing issue to slow import BOM lines through DMF- Bill of materials lines V3 (Data Management). Need to customize code to import BOM lines, after importing below through DMF
A. BOM Header
B. BOM Version
Using System.IO;
Using OfficeOpenXml;
Using OfficeOpenXml.ExcelPackage;
Using OfficeOpenXml.ExcelRange;
internal final class GMUploadBOMStaging
{
/// <summary>
/// Class entry point. The system will call this method when a designated menu
/// is selected or when execution starts and this class is set as the startup class.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
System.IO.Stream stream;
ExcelSpreadsheetName sheet;
FileUploadBuild fileUpload,fileUploadBuild;
DialogGroup dialogUploadGroup;
FormBuildControl formBuildControl;
Dialog dialog=new Dialog("BOM Lines Import");
GMBOM GMBOM;
InventDim InventDim;
dialogUploadGroup = dialog.addGroup("@SYS54759");
formBuildControl = dialog.formBuildDesign().control(dialogUploadGroup.name());
fileUploadBuild = formBuildControl.addControlEx(classStr(fileUpload),"UploadExcel");
fileUploadBuild.style(FileUploadStyle::MinimalWithFilename);
fileUploadBuild.fileTypesAccepted(".xlsx");
if(dialog.run())
{
FileUploadTemporaryStorageResult fileUploadResult = file::GetFileFromUser(classStr(FileUploadTemporaryStorageStrategy));
if(fileUploadResult!= null && fileUploadResult.getUploadStatus())
{
stream=fileUploadResult.openResult();
using(ExcelPackage package= new ExcelPackage(stream))
{
int rowCount, iterator;
package.Load(stream);
ExcelWorksheet worksheet= package.get_workbook().get_worksheets().get_Item(1);
OfficeOpenXml.ExcelRange range=worksheet.Cells;
rowCount = worksheet.Dimension.End.Row - worksheet.Dimension.Start.Row + 1;
for(iterator=2;iterator<=rowCount;iterator++)
{
GMBOM.clear();
GMBOM.BOMConsump = BOMConsumpType::Variable;
GMBOM.BomWHSReleasePolicy = BomWHSReleasePolicy::AllowPartialReservation;
GMBOM.BOMId = range.get_Item(iterator, 2).Value;
GMBOM.BOMQty = range.get_Item(iterator, 3).Value;
GMBOM.BOMQtySerie = range.get_Item(iterator, 4).Value;
if(range.get_Item(iterator,5).Value == "Item")
GMBOM.BOMType = BOMType::Item;
if(range.get_Item(iterator,5).Value == "Vendor")
GMBOM.BOMType = BOMType::Vendor;
if(range.get_Item(iterator,6).Value == "Yes")
GMBOM.Calculation = NoYes::Yes;
if(range.get_Item(iterator,6).Value == "No")
GMBOM.Calculation = NoYes::No;
GMBOM.Constant = range.get_Item(iterator,7).Value;
GMBOM.Density = range.get_Item(iterator,8).Value;
GMBOM.Depth = range.get_Item(iterator,9).Value;
GMBOM.EndSchedConsump = NoYes::No;
GMBOM.Formula = BOMFormula::Formula0;
GMBOM.FromDate = dateNull();
GMBOM.Height = range.get_Item(iterator,13).Value;
GMBOM.ItemBOMId = range.get_Item(iterator,14).Value;
GMBOM.ItemId = range.get_Item(iterator,15).Value;
GMBOM.ItemRouteId = range.get_Item(iterator,16).Value;
GMBOM.LineNum = range.get_Item(iterator,17).Value;
GMBOM.LineCreationSequenceNumber = GMBOM.LineNum;
GMBOM.OprNum = 0;
GMBOM.PDSInheritCoProductBatchAttrib = NoYes::No;
GMBOM.PDSInheritCoProductShelfLife = NoYes::No;
GMBOM.PdsCWQty = range.get_Item(iterator,19).Value;
GMBOM.Position = range.get_Item(iterator,22).Value;
GMBOM.ProdFlushingPrincip = ProdFlushingPrincipBOM::Blank;
GMBOM.RoundUp = BOMRoundUp::No;
GMBOM.RoundUpQty = range.get_Item(iterator,25).Value;
GMBOM.ScrapConst = range.get_Item(iterator,26).Value;
GMBOM.ScrapVar = range.get_Item(iterator,27).Value;
GMBOM.ToDate = dateNull();
GMBOM.UnitId = range.get_Item(iterator,29).Value;
GMBOM.VendId = range.get_Item(iterator,30).Value;
GMBOM.Width = range.get_Item(iterator,31).Value;
GMBOM.WrkCtrConsumption = 0;
GMBOM.InventSiteId = range.get_Item(iterator,38).Value;
GMBOM.InventLocationId = range.get_Item(iterator,39).Value;
InventDim.clear();
InventDim.inventSiteId = GMBOM.InventSiteId;
InventDim.InventLocationId = GMBOM.InventLocationId;
InventDim = InventDim::findOrCreate(InventDim);
GMBOM.InventDimId = InventDim.inventDimId;
GMBOM.insert();
}
}
}
}
else
{
Error("error occured.");
}
}
}