cancel
Showing results for 
Search instead for 
Did you mean: 

Create document through DI API

Former Member
0 Kudos

Good day experts, I have the following code that creates a sale offer (quotation) within SAP through the DI API in a web page:

        private void CrearDocumento()
        {
            if (oCompany == null || !oCompany.Connected)
                this.ConectarCompany();

            Documents Cotizacion = oCompany.GetBusinessObject(BoObjectTypes.oQuotations);

            Cotizacion.CardCode = txtCodigoCliente.Text.ToString();
            Cotizacion.DocDate = DateTime.Now;
            Cotizacion.DocDueDate = DateTime.Now.AddMonths(1);
            Cotizacion.Series = 13;
            Cotizacion.DocCurrency = ddlMoneda.SelectedItem.Text.ToString();

            //Líneas
            Cotizacion.Lines.SetCurrentLine(0);
            Cotizacion.Lines.ItemCode = txtArticulo.Text.ToString();
            Cotizacion.Lines.Quantity = double.Parse(txtCantidadArticulo.Text.ToString());
            Cotizacion.Lines.Price = double.Parse(txtPrecioArticulo.Text.ToString());
            Cotizacion.Lines.DiscountPercent = double.Parse(txtDescuentoArticulo.Text.ToString());
            Cotizacion.Lines.UoMEntry = Convert.ToInt32(ddlUoM.SelectedValue.ToString());  

            if (Convert.ToInt32(ddlUoM.SelectedValue.ToString()) != -1)
                Cotizacion.Lines.UseBaseUnits = BoYesNoEnum.tNO;
            else
                Cotizacion.Lines.UseBaseUnits = BoYesNoEnum.tYES;

            Cotizacion.Lines.TaxCode = "A4";
            Cotizacion.Lines.WarehouseCode = "MTY";
            Cotizacion.Lines.ProjectCode = "01MTY";     

            Cotizacion.Comments = "Comentarios..";

            //Crear cotización
            int iret = Cotizacion.Add();        
        }

I have two doubts about this, the first is if there is a way that through the DI API, I can bring the total cost ($) of the line of the article, that is, when I select an article code I have to execute a query which brings me the units of measure, the price, etc., but I must do it "manually", I wanted to ask if the DI API has any option to do this.

And the second and most important, I was looking for topics related to the memory consumption of the DI API and I found this post:

DI API - Memory Leak

Could you support me by checking my code and checking if it is written in the correct way ?, or if it is required to do some type of "cleaning" elements (eg Garbage Collector, Dispose, return everything to NULL, etc.) .

I thank you in advance for any support, example, comment or guidance that you can give me. Best regards.

Accepted Solutions (0)

Answers (0)