on 09-23-2016 11:06 PM
Olá experts
Estou desenvolvendo uma rotina de código que faz a função de copiar de um documento nota fiscal varias entregas mais sempre que faço isso um erro me retorna.
Erro: Internal error (-5002) occurred
segue o código fonte que eu estou utilizando para fazer essa inserção.
oCompany = DiCompany.Conectar();
try
{
oInvoices = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oInvoices);
oDeliveryNotes = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oDeliveryNotes);
oInvoices.SequenceCode = -2;
oInvoices.SequenceSerial = Convert.ToInt32(oinv.codTMS);
oInvoices.SequenceModel = Convert.ToString(39);
oInvoices.CardCode = Validacao_Retorno_SAP.RetornaCarCodeCPF_CNPJ(oinv.cliente_cpf_cnpj);
oInvoices.NumAtCard = oinv.Referencia;
oInvoices.DocDate = oinv.DataLancamento;
oInvoices.DocDueDate = oinv.DataVencimento;
oInvoices.UserFields.Fields.Item("U_TDS_Usuario").Value = oinv.Usuario;
oInvoices.BPL_IDAssignedToInvoice = Validacao_Retorno_SAP.RetornaBPLID(oinv.CodFilial);
oInvoices.PaymentGroupCode = Validacao_Retorno_SAP.RetornaCondicaoPagamento(oinv.CondicaoPagamento);
oInvoices.PaymentMethod = Validacao_Retorno_SAP.RetornaFormaPagamento(oinv.FormaPagamento);
for (int i = 0; i < CTes.Count; i++)
{
oDeliveryNotes.GetByKey(Validacao_Retorno_SAP.RetornaDocentryCTE(CTes[i].ChaveAcesso));
for (int j = 0; j < oDeliveryNotes.Lines.Count; j++)
{
oDeliveryNotes.Lines.SetCurrentLine(j);
oInvoices.Lines.BaseType = (int)SAPbobsCOM.BoObjectTypes.oDeliveryNotes;
oInvoices.Lines.BaseEntry = oDeliveryNotes.DocEntry;
oInvoices.Lines.BaseLine = j;
oInvoices.Lines.ItemCode = oDeliveryNotes.Lines.ItemCode;
oInvoices.Lines.ItemDescription = oDeliveryNotes.Lines.ItemDescription;
oInvoices.Lines.Quantity = oDeliveryNotes.Lines.Quantity;
oInvoices.Lines.Price = oDeliveryNotes.Lines.Price;
oInvoices.Lines.TaxCode = oDeliveryNotes.Lines.TaxCode;
oInvoices.Lines.CFOPCode = oDeliveryNotes.Lines.CFOPCode;
oInvoices.Lines.AccountCode = oDeliveryNotes.Lines.AccountCode;
oInvoices.Lines.LineTotal = oDeliveryNotes.Lines.LineTotal;
oInvoices.Lines.Usage = oDeliveryNotes.Lines.Usage;
oInvoices.Lines.CostingCode = oDeliveryNotes.Lines.CostingCode;
oInvoices.Lines.CostingCode2 = oDeliveryNotes.Lines.CostingCode2;
oInvoices.Lines.CostingCode3 = oDeliveryNotes.Lines.CostingCode3;
oInvoices.Lines.CostingCode4 = oDeliveryNotes.Lines.CostingCode4;
oInvoices.Lines.CostingCode5 = oDeliveryNotes.Lines.CostingCode5;
oInvoices.Lines.ProjectCode = oDeliveryNotes.Lines.ProjectCode;
oInvoices.Lines.WarehouseCode = oDeliveryNotes.Lines.WarehouseCode;
oInvoices.Lines.UnitPrice = oDeliveryNotes.Lines.UnitPrice;
oInvoices.Lines.Add();
}
}
int iErrorSAP = 0;
iErrorSAP = oInvoices.Add();
if (iErrorSAP != 0)
{
throw new Exception(oCompany.GetLastErrorCode() + " - " + oCompany.GetLastErrorDescription());
}
return "0";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
7 | |
7 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.