Click or drag to resize

clsImportERPDocument Class

Data holder to import a Document to SAP Business One via DI-API

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.

Inheritance Hierarchy
SystemObject
  MARIInterfaceclsImportBase
    MARIInterfaceclsImportERPDocument

Namespace:  MARIInterface
Assembly:  MARIInterface (in MARIInterface.dll) Version: 8.0.0.100
Syntax
public class clsImportERPDocument : clsImportBase

The clsImportERPDocument type exposes the following members.

Constructors
  NameDescription
Public methodclsImportERPDocument
Initializes a new instance of the clsImportERPDocument class
Top
Properties
  NameDescription
Public propertyCompanyID
Company ID [Mandatory]. Logical linkt to the SBO Database(Schema)
Public propertyoDownPayments
List of DocEntries of the DownPayments
Public propertyoPositions
List of the Document Lines
Top
Methods
Fields
  NameDescription
Public fieldCurrency
Document Currency
Public fieldDiscount
Discount in percentage for the document
Public fieldDocDueDate
OINV.DocDueDate
Public fieldDocEntry
ReadOnly Internal ID SBO OINV.DocEntry
Public fieldDocNum
OINV.DocNum (optional) Can be used, when DocNumSeries is manual
Public fieldDocNumSeries
OINV.Series (optional) Can be used, when manual=-1
Public fieldDocType
Document Type
Public fieldDocumentDate
OINV.TaxDate
Public fieldDownPaymentPercent
Percent of the Invoice value (1 = 100%)
Public fieldFinanceBlock
Public fieldFinanceBPCode
Bill to or Pay to business partner code
Public fieldFinanceBuilding
Public fieldFinanceCity
Public fieldFinanceCountry
Public fieldFinanceCounty
Public fieldFinanceMatchcode
Public fieldFinanceName1
Public fieldFinanceName2
Public fieldFinanceName3
Public fieldFinanceState
Public fieldFinanceStreet
Public fieldFinanceStreetNo
Public fieldFinanceZip
Public fieldFooter
Public fieldHeader
Public fieldImportFileNum
Order Number
Public fieldJournalMemo
Journal Memo VarChar(50)
Public fieldnDownPaymentType
Down Payment Type
Public fieldPaymentTerm
PaymentTerm ID
Public fieldPostingDate
OINV.DocDate
Public fieldProfitCenter
Profit center in the header. Not used in MARIProject. Use the profit center in the position.
Public fieldProjectCode
ProjectCode center in the header. Not used in MARIProject. Use the project code in the position.
Public fieldREFNumber
Reference Number VarChar(11)
Public fieldREFSign
Reference Sign VarChar(11)
Public fieldRemarks
Remarks
Public fieldSalesPersonCode
string
Public fieldShipmentBlock
Public fieldShipmentBPCode
Public fieldShipmentBuilding
Public fieldShipmentCity
Public fieldShipmentCountry
Public fieldShipmentCounty
Public fieldShipmentMatchcode
Public fieldShipmentName1
Public fieldShipmentName2
Public fieldShipmentName3
Public fieldShipmentState
Public fieldShipmentStreet
Public fieldShipmentStreetNo
Public fieldShipmentZip
Top
Examples
Create a goods receipt to fill the warehouse in SBO via DI-API
private clsImportERPDocument CreateERPDocumentGoodsReceipt(string sCardCode, string sItemCode, DateTime dtDocDate) {

    clsImportERPDocument NewDoc = new clsImportERPDocument();
    NewDoc.CompanyID = 1; // first company linked to MARIProject
    NewDoc.DocType = clsImportERPDocument.eERPDocTypes.Goods_Receipt_PO;
    NewDoc.DocumentDate = dtDocDate;
    NewDoc.DocDueDate = dtDocDate;
    NewDoc.FinanceBPCode = sCardCode;
    NewDoc.ShipmentBPCode = sCardCode;
    NewDoc.Header = "New goods receipt PO via MARIInterface";

    clsImportERPDocument.clsERPDocumentPosition NewPos;
    NewPos = new clsImportERPDocument.clsERPDocumentPosition();
    NewPos.PositionType = clsImportERPDocument.clsERPDocumentPosition.eLineTypes.Item;
    NewPos.ItemCode = sItemCode;
    NewPos.UnitPrice = 12.34m;
    NewPos.Quantity = 5;
    NewPos.WareHouse = "01";

    NewDoc.oPositions.Add(NewPos);

    if (oMPInterface.bImportERPDocument(NewDoc, clsImportBase.eImportMode.ValidateAndImport)) {
        return NewDoc;
    } else {
        LogFail(oMPInterface.oErrors.PrintErrors());
        return null;
    }
}
Create a simple sales order in SBO via DI-API
private clsImportERPDocument CreateERPDocumentSalesOrder(string sCardCode, string sItemCode, DateTime dtDocDate) {

    clsImportERPDocument NewDoc = new clsImportERPDocument();
    NewDoc.CompanyID = 1; // first company linked to MARIProject
    NewDoc.DocType = clsImportERPDocument.eERPDocTypes.Sales_Order;
    NewDoc.DocumentDate = dtDocDate;
    NewDoc.DocDueDate = dtDocDate.AddDays(30);
    NewDoc.FinanceBPCode = sCardCode;
    NewDoc.ShipmentBPCode = sCardCode;
    NewDoc.Header = "New sales order created via MARIInterface";

    clsImportERPDocument.clsERPDocumentPosition NewPos;
    NewPos = new clsImportERPDocument.clsERPDocumentPosition();
    NewPos.PositionType = clsImportERPDocument.clsERPDocumentPosition.eLineTypes.Item;
    NewPos.ItemCode = sItemCode;
    NewPos.UnitPrice = 123.45m;
    NewPos.Quantity = 5;

    NewDoc.oPositions.Add(NewPos);

    if (oMPInterface.bImportERPDocument(NewDoc, clsImportBase.eImportMode.ValidateAndImport)) {
        return NewDoc;
    } else {
        LogFail(oMPInterface.oErrors.PrintErrors());
        return null;
    }
}
Create an A/P Invoice basde on a sales oder document in SBO via DI-API
private int CreateERPDocumentAPInvoice(clsImportERPDocument BaseSalesorder, DateTime dtDocDate) {

    clsImportERPDocument NewDoc = new clsImportERPDocument();
    NewDoc.CompanyID = BaseSalesorder.CompanyID;
    NewDoc.DocType = clsImportERPDocument.eERPDocTypes.AR_Invoice;

    NewDoc.DocumentDate = dtDocDate;
    NewDoc.FinanceBPCode = BaseSalesorder.FinanceBPCode;
    NewDoc.ShipmentBPCode = BaseSalesorder.ShipmentBPCode;
    NewDoc.Header = "New A/P Invoice created via MARIInterface";

    clsImportERPDocument.clsERPDocumentPosition NewPos;
    foreach (clsImportERPDocument.clsERPDocumentPosition BasePos in BaseSalesorder.oPositions) {

        NewPos = new clsImportERPDocument.clsERPDocumentPosition();
        NewPos.PositionType = BasePos.PositionType;
        NewPos.ItemCode = BasePos.ItemCode;
        NewPos.UnitPrice = BasePos.UnitPrice;
        NewPos.Quantity = BasePos.Quantity;
        NewPos.BaseEntry = BaseSalesorder.DocEntry;
        NewPos.BaseLine = BasePos.llLinenum;
        NewPos.BaseType = BaseSalesorder.DocType;
        NewDoc.oPositions.Add(NewPos);
    }

    if (oMPInterface.bImportERPDocument(NewDoc, clsImportBase.eImportMode.ValidateAndImport)) {
        return NewDoc.DocEntry;
    } else {
        throw new Exception(oMPInterface.oErrors.PrintErrors());
    }
}
See Also