Click or drag to resize

clsImportProductTree Class

Store Bill of Material structures in the Product Tree table of SBO (OITT) into the given CompanyID used for the import table MARIProjektImportOITT and MARIProjektImportOITTLines.

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.

Inheritance Hierarchy
SystemObject
  MARIInterfaceclsImportBase
    MARIInterfaceclsImportBaseERP
      MARIInterfaceclsImportProductTree

Namespace:  MARIInterface
Assembly:  MARIInterface (in MARIInterface.dll) Version: 8.0.0.100
Syntax
public class clsImportProductTree : clsImportBaseERP

The clsImportProductTree type exposes the following members.

Constructors
  NameDescription
Public methodclsImportProductTree
Initializes a new instance of the clsImportProductTree class
Top
Properties
  NameDescription
Public propertyCode
Code = ItemCode of the header
Public propertyHideComp
Hide Components in Print Out
Public propertyOcrCode
Cost Center 1
Public propertyOcrCode2
Cost Center 2
Public propertyOcrCode3
Cost Center 3
Public propertyOcrCode4
Cost Center 4
Public propertyOcrCode5
Cost Center 5
Public propertyPriceList
PriceList
Public propertyProductionTreeLines
Store the lines for the BOM Master. ITT1
Public propertyProductionTreeStages
Store the Route Stages for the BOM Master. ITT2
Public propertyProject
Project
Public propertyQuantity
Quantity [Qauntity] spelling mistake in DB -> Base Quantity
Public propertyToWH
Linked warehouse (default warehouse)
Public propertyTreeType
TreeType
Top
Methods
Examples
Create a new product tree in SBO via DI-API
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;
}
See Also