CREAR DOCUMENTO CON DATABROWSER (SAPB1)

Code with Edd

MÉTODO PARA CREAR UN DOCUMENTO DE MARKETING EN SAPB1 UTILIZANDO LA DI API EL OBJETO DATA BROWSER.

public AddResponse AddoOrdersFromXMLObject(XMLObjectModel objectXML)
{
    string file_name = "DocumentoObject.xml";
    
    this.ConnectToSAPB1();
    SAPbobsCOM.Documents oDocto = null;
    oDocto = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);

    try
    {
        oCompany.XmlExportType = BoXmlExportTypes.xet_ExportImportMode;
        if (oCompany.GetXMLobjectType(this.path_upload + file_name, 0) == SAPbobsCOM.BoObjectTypes.oOrders)
        {
            oDocto.Browser.ReadXml(this.path_upload + file_name, 0);

            int lRetCode = oDocto.Add();
            if (lRetCode != 0)
            {
                int lErrCode;
                string sErrMsg;
                oCompany.GetLastError(out lErrCode, out sErrMsg);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oDocto);
                this.DisConnectToSAPB1();

                return new AddResponse { Success = false, DocNum = "", Messages = lErrCode + " " + sErrMsg };
            }
            else
            {
                var numberDocument = oCompany.GetNewObjectKey();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oDocto);
                GC.Collect();
                this.DisConnectToSAPB1();

                return new AddResponse { Success = true, DocNum = numberDocument, Messages = "Documento creado correctamente." };
            }
        }
        else
        {
            return new AddResponse { Success = false, DocNum = "", Messages = "XML Contains not supported Items" };
        }
    }
    catch (Exception ex)
    {
        System.Runtime.InteropServices.Marshal.ReleaseComObject(oDocto);
        return new AddResponse { Success = false, DocNum = "", Messages = ex.Message };
    }
}

Referencia:

SAP Business One SDK – Help Center
https://help.sap.com/viewer/product/SAP_BUSINESS_ONE/9.3/es-ES

CREAR DOCUMENTO CON DATABROWSER (SAPB1)
Web | + posts

Full Stack Web Developer && SDK SAPB1 Developer.

Melómano, Gamer (Xbox), Comprador compulsivo de Amazon y Posiblemente con TDAH.

Scroll hacia arriba