cancel
Showing results for 
Search instead for 
Did you mean: 

add invoices and payments

Former Member
0 Kudos

Hello SAP . because when I want to create payment received related to an invoice, the delay paying around 15-25 seconds to be created , I am using di api , there is a faster way to create payments received , I have 300k of records that need to migrate to sap

, THIS MY CODE thanks  !!

factura = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

SAPbobsCOM.Payments Pagos;

Pagos = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);

factura.CardCode = "C000" + CARDCODE;

factura.CardName = CARDNAME;

factura.DocDate = DocDate;

factura.TaxDate = DocDate;

factura.DocDueDate =DocDate;

factura.NumAtCard =NumAtCard;

factura.GroupNumber = GroupNum;

factura.SalesPersonCode = SlpCode;

factura.Comments = "Creado por SDK";

factura.FolioPrefixString = FolioPref;

factura.FolioNumber =FolioNum;

factura.Indicator =Indicator;

factura.TrackingNumber = Convert.ToString(TrackNo);

factura.ControlAccount = CUENTA_ASOCIADA;

factura.UserFields.Fields.Item("U_EXX_TIPOOPER").Value = U_EXX_TIPOOPER;

factura.UserFields.Fields.Item("U_EXC_EMBARQUE").Value = U_EXC_EMBARQUE;

factura.UserFields.Fields.Item("U_EXC_DESEMBARQUE").Value =U_EXC_DESEMBARQUE;

factura.UserFields.Fields.Item("U_EXC_NROASIENTO").Value = U_EXC_ASIENTO;

factura.UserFields.Fields.Item("U_EXC_FECHAVIAJE").Value = U_EXC_FECHAVIAJE;

factura.UserFields.Fields.Item("U_EXC_TIPOVENTA").Value = Convert.ToString(U_EXC_TIPOVENTA);

factura.UserFields.Fields.Item("U_EXC_TIPPAGO").Value = Convert.ToString(TIPOPAGO);

factura.UserFields.Fields.Item("U_EXC_SDK").Value = "Y";

factura.DocCurrency = DocCur;

//Detalle

factura.Lines.ItemCode = ITEMCODE;

factura.Lines.WarehouseCode = "ALM_VENT";

factura.Lines.Quantity =1;

factura.Lines.PriceAfterVAT = Math.Abs(PriceBefDi);

factura.Lines.DiscountPercent = Math.Abs(DiscPrcnt);

//  factura.Lines.UnitsOfMeasurment = 1;

factura.Lines.TaxCode =TaxCode;

factura.Lines.CostingCode = agencia;

//   factura.Lines.AccountCode = "_SYS00000001916";

factura.DocumentSubType = SAPbobsCOM.BoDocumentSubType.bod_Bill;

factura.Add();

//MessageBox.Show("Factura creado exitosamente...");

string DocEntry = BL.Modules.Purchasing.BCOPayments.GetById_pasaje(NumAtCard);

string sys_origen = Convert.ToString(Convert.ToString(row.Cells["SYSORIGEN"].Value));

Pagos.CardCode = "C" + CARDCODE;

Pagos.CardName = CARDNAME;

////   Pagos.Address = "JR. TRENEMAN  - 15679069";

Pagos.DocDate = DocDate;

Pagos.TaxDate = DocDate;

Pagos.DueDate = DocDate;

//// Pagos.JournalRemarks = Payments.Journalremarks;

Pagos.DocCurrency = "SOL";

Pagos.Invoices.DocEntry = Convert.ToInt32(DocEntry);

Pagos.Invoices.AppliedFC = PriceBefDi;

Pagos.CashSum = PriceBefDi;

Pagos.Remarks = Convert.ToString(TrackNo);

Pagos.CashAccount = sys_origen;

//string Metodo_pago = PayMethod.Trim();

//if (Metodo_pago == "POR PAGAR EN DESTINO") { sys_origen = BL.Modules.Purchasing.BCOPayments.GetCentroAgencia(CodDest); }

//Pagos.UserFields.Fields.Item("U_EXC_TIPOVENTA").Value = Convert.ToString(U_EXC_TIPO_TRANS);

//Pagos.UserFields.Fields.Item("U_EXX_MPFONDEF").Value = "001";

//Pagos.UserFields.Fields.Item("U_EXC_SDK").Value = "Y";

if (Pagos.Add() != 0)

{

   oCompany.GetLastError(out lErrCode, out sErrMsg);

    mensaje2 = "Factura No creada...";

}

else

{

    mensaje2 = "Factura creado exitosamente...";

}

Accepted Solutions (0)

Answers (1)

Answers (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Luis,

For that volume of information I'd think about breaking it up into "manageable" chunks (say 100 records per chunk).

You should also have a look (if feasible) at the DTW. Maybe this will fit your scenario.

As a last resort you can change your code to use the XML interface (basically an xml that "represents" a document) then use that for adding the document. It should be better performance wise.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn