Hi Andre, Please find the code attached below. There is no customiation for PO Components just we need to export the Components through Excel. The Components Form consists of Fields from PurchLineIngredient Table and i can see some of the data was imported but Purch Id and Purch Line was not populated. One of my collegue suggested to add initFromPurchLine also still not happening.
//.......... Modified by Prem _ 28/07/2020
void clicked()
{
Dialog _dialog;
DialogField _file;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
//Declaring Table Name
PurchLineIngredient importTable;
PurchTable purTable;
InventDim dimTab;
PurchLine pline;
int row = 1;
ItemId _itemid;
UnitIDInventory _unitid;
ConfigIdStandard configId;
InventColorTxt inventColorId;
InventSizeTxt inventSizeId;
InventBatchId inventBatchId;
Qty _cwQty;
str _cwUnitId;
Qty _qty;
Qty pureQty;
SettingCode _settingTypeCode;
real _rate;
StoneRate _stoneSettingRate;
anytype _cType;
real _lineamount;
PurchId purchId;
LineNumber lineNumber;
_dialog = new Dialog("Please select the file to load");
_dialog.addText("Select file:");
_file = _dialog.addField(ExtendedTypeStr("FilenameOpen"));
_dialog.run();
if (_dialog.closedOK())
{
info(_file.value() );
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specifies the file path that you want to read
filename =_file.value(); //ExcelSheet File Name
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error('File cannot be opened');
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number
cells = worksheet.cells();
do
{
row++;
_itemid = cells.item(row, 1).value().bStr();
_unitid = cells.item(row, 2).value().bStr();
configId = cells.item(row, 3).value().bStr();
inventColorId = any2str(cells.item(row, 4).value().toString());
inventSizeId = any2str(cells.item(row, 5).value().toString());
inventBatchId = any2str(cells.item(row, 6).value().toString());
_cwQty = cells.item(row, 7).value().double();
_cwUnitId = any2str(cells.item(row, 8).value().toString());
_qty = cells.item(row, 9).value().double();
pureQty = cells.item(row, 10).value().double();
_settingTypeCode = cells.item(row, 11).value().bStr();
_rate = cells.item(row, 12).value().double();
_stoneSettingRate = cells.item(row, 13).value().double();
_cType = cells.item(row, 14).value().bStr();
_lineamount = cells.item(row, 15).value().double();
type = cells.item(row+1, 1).value().variantType();
PurchLineIngredient.initFromPurchLine(PurchLine);
importTable.initValue();
importTable.initFromPurchLine(pline);
importTable.ItemId = _itemid;
importTable.UnitId = _unitid;
dimTab.configId = configId;
dimTab.InventColorId = inventColorId;
dimTab.InventSizeId = inventSizeId;
dimTab.inventBatchId = inventBatchId;
importTable.CWQTY = _cwQty;
// importTable.pdsCWUnitId = _cwUnitId;
importTable.Qty = _qty;
importTable.PureQty = pureQty;
importTable.SettingTypeCode = _settingTypeCode;
importTable.CRate = _rate;
importTable.StoneSettingRate = _stoneSettingRate;
importTable.CalcType = _cType;
importTable.LineAmount = _lineamount;
importTable.insert();
dimTab.insert();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
info("Data is Imported");
}
}
//.......... Modified by Prem _ 28/07/2020
void clicked()
{
Dialog _dialog;
DialogField _file;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
//Declaring Table Name
PurchLineIngredient importTable;
PurchTable purTable;
InventDim dimTab;
PurchLine pline;
int row = 1;
ItemId _itemid;
UnitIDInventory _unitid;
ConfigIdStandard configId;
InventColorTxt inventColorId;
InventSizeTxt inventSizeId;
InventBatchId inventBatchId;
Qty _cwQty;
str _cwUnitId;
Qty _qty;
Qty pureQty;
SettingCode _settingTypeCode;
real _rate;
StoneRate _stoneSettingRate;
anytype _cType;
real _lineamount;
PurchId purchId;
LineNumber lineNumber;
_dialog = new Dialog("Please select the file to load");
_dialog.addText("Select file:");
_file = _dialog.addField(ExtendedTypeStr("FilenameOpen"));
_dialog.run();
if (_dialog.closedOK())
{
info(_file.value() );
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specifies the file path that you want to read
filename =_file.value(); //ExcelSheet File Name
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error('File cannot be opened');
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number
cells = worksheet.cells();
do
{
row++;
_itemid = cells.item(row, 1).value().bStr();
_unitid = cells.item(row, 2).value().bStr();
configId = cells.item(row, 3).value().bStr();
inventColorId = any2str(cells.item(row, 4).value().toString());
inventSizeId = any2str(cells.item(row, 5).value().toString());
inventBatchId = any2str(cells.item(row, 6).value().toString());
_cwQty = cells.item(row, 7).value().double();
_cwUnitId = any2str(cells.item(row, 8).value().toString());
_qty = cells.item(row, 9).value().double();
pureQty = cells.item(row, 10).value().double();
_settingTypeCode = cells.item(row, 11).value().bStr();
_rate = cells.item(row, 12).value().double();
_stoneSettingRate = cells.item(row, 13).value().double();
_cType = cells.item(row, 14).value().bStr();
_lineamount = cells.item(row, 15).value().double();
type = cells.item(row+1, 1).value().variantType();
PurchLineIngredient.initFromPurchLine(PurchLine);
importTable.initValue();
importTable.initFromPurchLine(pline);
importTable.ItemId = _itemid;
importTable.UnitId = _unitid;
dimTab.configId = configId;
dimTab.InventColorId = inventColorId;
dimTab.InventSizeId = inventSizeId;
dimTab.inventBatchId = inventBatchId;
importTable.CWQTY = _cwQty;
// importTable.pdsCWUnitId = _cwUnitId;
importTable.Qty = _qty;
importTable.PureQty = pureQty;
importTable.SettingTypeCode = _settingTypeCode;
importTable.CRate = _rate;
importTable.StoneSettingRate = _stoneSettingRate;
importTable.CalcType = _cType;
importTable.LineAmount = _lineamount;
importTable.insert();
dimTab.insert();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
info("Data is Imported");
}
}
//.......... Modified by Prem _ 28/07/2020
void clicked()
{
Dialog _dialog;
DialogField _file;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
//Declaring Table Name
PurchLineIngredient importTable;
PurchTable purTable;
InventDim dimTab;
PurchLine pline;
int row = 1;
ItemId _itemid;
UnitIDInventory _unitid;
ConfigIdStandard configId;
InventColorTxt inventColorId;
InventSizeTxt inventSizeId;
InventBatchId inventBatchId;
Qty _cwQty;
str _cwUnitId;
Qty _qty;
Qty pureQty;
SettingCode _settingTypeCode;
real _rate;
StoneRate _stoneSettingRate;
anytype _cType;
real _lineamount;
PurchId purchId;
LineNumber lineNumber;
_dialog = new Dialog("Please select the file to load");
_dialog.addText("Select file:");
_file = _dialog.addField(ExtendedTypeStr("FilenameOpen"));
_dialog.run();
if (_dialog.closedOK())
{
info(_file.value() );
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specifies the file path that you want to read
filename =_file.value(); //ExcelSheet File Name
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error('File cannot be opened');
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number
cells = worksheet.cells();
do
{
row++;
_itemid = cells.item(row, 1).value().bStr();
_unitid = cells.item(row, 2).value().bStr();
configId = cells.item(row, 3).value().bStr();
inventColorId = any2str(cells.item(row, 4).value().toString());
inventSizeId = any2str(cells.item(row, 5).value().toString());
inventBatchId = any2str(cells.item(row, 6).value().toString());
_cwQty = cells.item(row, 7).value().double();
_cwUnitId = any2str(cells.item(row, 8).value().toString());
_qty = cells.item(row, 9).value().double();
pureQty = cells.item(row, 10).value().double();
_settingTypeCode = cells.item(row, 11).value().bStr();
_rate = cells.item(row, 12).value().double();
_stoneSettingRate = cells.item(row, 13).value().double();
_cType = cells.item(row, 14).value().bStr();
_lineamount = cells.item(row, 15).value().double();
type = cells.item(row+1, 1).value().variantType();
PurchLineIngredient.initFromPurchLine(PurchLine);
importTable.initValue();
importTable.initFromPurchLine(pline);
importTable.ItemId = _itemid;
importTable.UnitId = _unitid;
dimTab.configId = configId;
dimTab.InventColorId = inventColorId;
dimTab.InventSizeId = inventSizeId;
dimTab.inventBatchId = inventBatchId;
importTable.CWQTY = _cwQty;
// importTable.pdsCWUnitId = _cwUnitId;
importTable.Qty = _qty;
importTable.PureQty = pureQty;
importTable.SettingTypeCode = _settingTypeCode;
importTable.CRate = _rate;
importTable.StoneSettingRate = _stoneSettingRate;
importTable.CalcType = _cType;
importTable.LineAmount = _lineamount;
importTable.insert();
dimTab.insert();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
info("Data is Imported");
}
}