PRECIOS ESPECIALES (BP) DI API SAPB1

Code with Edd

PRECIOS ESPECIALES (BP) DI API SAPB1. ACTUALIZAR PRECIOS ESPECIALES DE UN PRODUCTO PARA UN SOCIO DE NEGOCIO EN SAPB1 USANDO LA DI API (9.3 PL14)

Public SapResponseModel UpdateSpecialPrices(SpecialPrice header)
{
    try
    {
        SapResponseModel response;

        if (oCompany != null)
        {
            SAPbobsCOM.SpecialPrices oDocto;
            oDocto = (SAPbobsCOM.SpecialPrices)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSpecialPrices);
            oDocto.GetByKey(header.itemCode, header.cardCode);

            oDocto.SpecialPricesDataAreas.AutoUpdate = SAPbobsCOM.BoYesNoEnum.tNO;
            oDocto.SpecialPricesDataAreas.PriceListNo = header.listNum;
            oDocto.SpecialPricesDataAreas.Discount = header.discount;
            oDocto.SpecialPricesDataAreas.SpecialPrice = header.price;
            oDocto.SpecialPricesDataAreas.DateFrom = Convert.ToDateTime(header.dateFrom);
            oDocto.SpecialPricesDataAreas.Dateto = Convert.ToDateTime(header.dateTo);

            oDocto.AutoUpdate = SAPbobsCOM.BoYesNoEnum.tNO;
            oDocto.PriceListNum = header.listNum;
            oDocto.DiscountPercent = header.discount;
            oDocto.Price = header.price;

            int lRetCode = oDocto.Update();
            if (lRetCode != 0)
            {
                int lErrCode;
                string sErrMsg;
                oCompany.GetLastError(out lErrCode, out sErrMsg);
                Logger.Error(new Exception(), String.Format("LIB | {0}", lRetCode + " | " + sErrMsg));
                response = new SapResponseModel { Success = false, CodeErr = 1, CardCode = "-", DocEntry = 0, DocNum = 0, Message = lErrCode + " - " + sErrMsg };
            }
            else
            {
                response = new SapResponseModel { Success = true, CodeErr = 0, CardCode = oCompany.GetNewObjectKey(), DocEntry = 0, DocNum = 0, Message = "OK" };
            }
            GC.Collect();
        }
        else
        {
            response = new SapResponseModel { Success = false, CodeErr = 1, CardCode = "-", DocEntry = 0, DocNum = 0, Message = "No se conecto la libreria oCompany de SAPB1" };
        }

        return response;
    }
    catch (Exception ex)
    {
        this.SAPDisConnectCompany();
        Logger.Error(ex, String.Format("LIB | {0}", ex.Message + " | " + ex.StackTrace));
        return new SapResponseModel { Success = false, CodeErr = 1, CardCode = "-", DocEntry = 0, DocNum = 0, Message = ex.Message };
    }
}

Referencia: SAP Business One SDK – Help Center

PRECIOS ESPECIALES (BP) DI API 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