clsImportProductTree Class |
Please make sure, that SAP Business One DI-API in 32 or 64 bit is installed according to the usage of this interface. The logon user in MARIProject has to have a corresponding user linked to the selected company database.
Use AddLine(clsImportProductTreeLine) to add lines
Use MPInterface.bImportERPProductTree(clsImportProductTree, clsImportBaseeImportMode) to import.
Namespace: MARIInterface
The clsImportProductTree type exposes the following members.
| Name | Description | |
|---|---|---|
| clsImportProductTree | Initializes a new instance of the clsImportProductTree class |
| Name | Description | |
|---|---|---|
| Code | Code = ItemCode of the header | |
| HideComp | Hide Components in Print Out | |
| OcrCode | Cost Center 1 | |
| OcrCode2 | Cost Center 2 | |
| OcrCode3 | Cost Center 3 | |
| OcrCode4 | Cost Center 4 | |
| OcrCode5 | Cost Center 5 | |
| PriceList | PriceList | |
| ProductionTreeLines |
Store the lines for the BOM Master. ITT1
| |
| ProductionTreeStages |
Store the Route Stages for the BOM Master. ITT2
| |
| Project | Project | |
| Quantity | Quantity [Qauntity] spelling mistake in DB -> Base Quantity | |
| ToWH | Linked warehouse (default warehouse) | |
| TreeType | TreeType |
| Name | Description | |
|---|---|---|
| AddLine |
Function to add lines (only one hierarchy) to the Product Tree. At least one line is mandatory. See clsImportProductTreeLine for the line properties.
Use ProductionTreeLines.Add as alternative | |
| bReadFromDB |
Read from the linked SBO Database (CompanyID must be set)
(Overrides clsImportBasebReadFromDB(MPInterface, String).) | |
| bSaveRSToMDB |
Save object to MDB line
(Overrides clsImportBasebSaveRSToMDB(MPInterface, DataRow, DataTable).) | |
| bValidateAndRemove | (Overrides clsImportBasebValidateAndRemove(MPInterface).) |
public bool CreateProductTree(bool bWithResource) { string sResCode = sValidResCode(); string ItemCode = "370001"; string Whs = "01"; //Create Item Master (see example code in clsImportItem) CreateItemCode(ItemCode, "Tree Example", 105); // ItemCode, ItemName, ItemGroup clsImportProductTree NewTree = new clsImportProductTree(); NewTree.CompanyID = 1; // First company linked to MARIProject NewTree.Code = ItemCode; NewTree.TreeType = clsImportProductTree.BoItemTreeTypes.iProductionTree; NewTree.Quantity = 1;//Base Qty clsImportProductTreeLine oLine; oLine = new clsImportProductTreeLine(); oLine.Code = "220004"; //existing inventory item oLine.Type = clsImportProductTreeLine.ProductionItemType.pit_Item; //this is default oLine.IssueMthd = clsImportProductTreeLine.BoIssueMethod.im_Manual; oLine.Warehouse = Whs; oLine.Quantity = 2; NewTree.ProductionTreeLines.Add(oLine); if (bWithResource) { // only works with SBO 9.2 or later if (!string.IsNullOrEmpty(sResCode)) { oLine = new clsImportProductTreeLine(); oLine.Code = sResCode; // existing resource oLine.Type = clsImportProductTreeLine.ProductionItemType.pit_Resource; oLine.IssueMthd = clsImportProductTreeLine.BoIssueMethod.im_Manual; oLine.Warehouse = Whs; oLine.Quantity = 2; //hours NewTree.ProductionTreeLines.Add(oLine); } } if (oMPInterface.bImportERPProductTree(NewTree, clsImportBase.eImportMode.ValidateAndImport)) { return true; } else { LogFail(oMPInterface.oErrors.PrintErrors()); return false; } } private string sValidResCode() { string sResCode = ""; string sSQL; clsRecordset rs; clsConnection oConn = oEngine.oConnection(clsConnection.mpengDevices.mpengDeviceBusinessOne, nMandant: 1); sSQL = $"SELECT TOP 1 [ResCode] FROM [ORSC] ORDER BY [ResCode]"; Log(sSQL); rs = oConn.OpenRecordset(sSQL, clsConnection.clsConnectionOpenrecordset.dbOpenSnapshot); if (rs.RecordCount() > 0) { sResCode = Convert.ToString(rs["ResCode"]); } return sResCode; }