cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with message of error

Former Member
0 Kudos

Hi experts,

we have one problem with many message of error of this type:

We have this code:

if((inicio + saltos) < this.eContenido.Length() && this.eContenido.Length() != 0 && this.eContenido.Length() > 0 && inicio < saltos ) { //VDLL
lineaArch = this.eContenido.Substring( inicio , saltos);
//}

} //VDLL

But we don't understand why is the reason of this error because we have three validations by  common reason of error.

Do you have any idea of this error or you have any suggestion by erase of log de errors standard?

Very thanks for your help.

Accepted Solutions (1)

Accepted Solutions (1)

former_member200567
Active Contributor
0 Kudos

Hi Victor,

Have you checked this above the substring fuction call?

if(!this.eContenido.IsInitial()){


// your codes


}

Best Regards

Fred

Former Member
0 Kudos

Hi Fred, not, no fix the problem ..this is all code and I do not understand why is reason of error:

import ABSL;

import AP.FinancialAccounting.Global;

import AP.FO.MOM.Global;

import AP.Common.GDT;

import AP.FO.Party.Global;

//validando que exista el archivo

var existe = this.afAarchivos.AttachmentExistsIndicator;

var nArchivos = this.afAarchivos.DocumentList.Count();

var primerLinea = true;

var primerArchivo = true;

this.id = "PROCESAR_ARCHIVO";

///////// llena perfiles

var qperfil88 = AccountingEntry.QueryByElements;

var paraC = qperfil88.CreateSelectionParams();

paraC.Add(qperfil88.AccountingDocumentTypeCode, "I", "EQ", "00088");

paraC.Add(qperfil88.BusinessTransactionTypeCode, "I", "EQ", "634");

paraC.Add(qperfil88.Status.PostingStatusCode, "I", "EQ", "3");

var perfil88 = qperfil88.Execute(paraC);

var p88 : collectionof AccountingEntry;

var p88Sorted : collectionof AccountingEntry;

var p88first : collectionof AccountingEntry;

p88 = perfil88;

p88Sorted = p88.OrderByDescending(n=>n.ID.content);

p88Sorted.GetFirst();

p88first = p88Sorted;

foreach(var per88 in p88Sorted){

if(this.zCompany == "" && this.closingStep == "" && this.hText == ""){

this.zCompany = per88.CompanyID;

this.closingStep = per88.AccountingClosingStepCode;

this.hText = per88.Note.content;

this.dDate = per88.EntryDate;

this.tCurrency = per88.TransactionCurrencyCode;

}

}

/////////fin llena perfiles.

if (existe)

{

  foreach (var arch in this.afAarchivos.DocumentList)

  {

  //Obteniendo contenido del archivo

  //-----------------------------------------------------------------------------------------------

  if (!this.tcContenido.IsSet())

  {

  this.tcContenido.Create().Text.Create().TextContent.Create();

  }

  //this.tcContenido.Create().Text.Create().TextContent.Create();

  var BinaryObject = arch.FileContent.BinaryObject;

  this.tcContenido.Text.GetFirst().TextContent.Text.content = BinaryObject.content.ToString();

  this.eContenido = BinaryObject.content.ToString();

  var largo1 = BinaryObject.content.ToString().Length();

  var largo2 = this.eContenido.Length();

  //-----------------------------------------------------------------------------------------------

  this.eContenido = this.eContenido.ReplaceRegex("\\t", "^");

  this.eContenido = this.eContenido.ReplaceRegex("\\n", ";") + ";";

  //Declaración de variables

  //-----------------------------------------------------------------------------------------------

  var inicio = 0;

  var saltos = this.eContenido.Find(";");

  var ultCaracterEspecial = this.eContenido.Find(";");

  var lineaArch;

  var sCompania;

  var cMoneda;

  var postDate;

  var iAccountNumber;

  var sCostCenter;

  var sItemText;

  var bContinuarLinea = true;

  var bContinuar = true;

  var dato;

  var contador = 0;

  var monto = 0;

  var montomenor = 0;

  var monto2 = 0;

  var montomenor2 = 0;

  var totalcaracteres = 0;

  var tlinea = this.eContenido.Length();

  //-----------------------------------------------------------------------------------------------

  //Contenido del Archivo

  //-----------------------------------------------------------------------------------------------

  //Se omite la primera linea del archivo ya que son los encabezados

  /*inicio = ultCaracterEspecial + 1;

  ultCaracterEspecial = this.eContenido.Find(";", inicio);

  saltos = this.eContenido.Find(";", inicio) - inicio;*/

  totalcaracteres = inicio + saltos;

  //if (totalcaracteres < tlinea){

  //  Numeric.ParseFromString(inicio);

  //if((inicio + saltos) < this.eContenido.Length() && this.eContenido.Length() != 0 && this.eContenido.Length() > 0 && inicio < saltos ) { //VDLL

  if(!this.eContenido.IsInitial()){

  lineaArch = this.eContenido.Substring( inicio , saltos);

  }

  //}

  //} //VDLL

  var inicioLinea = 0;

  var especialLinea = lineaArch.Find(",");

  var saltosLinea = lineaArch.Find(",");

  var largoLinea;

  var largoLinea2;

  var largoSO;

  var largo = this.eContenido.Length() - 1;

  //Objeto a crear

  //var newObject:elementsof BO_Archivo;

  var cab : elementsof BO_ArchivoJE.lineasAsiento;

  var linea : elementsof BO_ArchivoJE.lineasArchivo;

  var linea2 : elementsof BO_ArchivoJE.lineasArchivo2;

  var newObject;

  var archivo = this.lineasAsiento.Create();

  if (!primerArchivo)

  {

  newObject = BO_ArchivoJE.Create();

  }

  while (bContinuar)

  {

  if (ultCaracterEspecial == -1 || inicio >= largo)

  {

  bContinuar = false;

  }

  else

  {

  //if((inicio + saltos) < this.eContenido.Length() && this.eContenido.Length() != 0 && this.eContenido.Length() > 0 && inicio < saltos ){ //VDLL

  if(!this.eContenido.IsInitial()){

  lineaArch = this.eContenido.Substring(inicio, saltos);

     }

  //}//VDLL

     //lineaArch = lineaArch + ",";

  largoLinea = lineaArch.Length();

  inicioLinea = 0;

  especialLinea = lineaArch.Find(",");//(";");

  if ( inicio < lineaArch.Length()){ //VDLL

  saltosLinea = lineaArch.Find(",", inicio) - inicio; //(";");;this.eContenido.Find(";", inicio) - inicio;

  } //VDLL

  contador = 1;

       if ( especialLinea == 0 && inicioLinea == 0)

  {

  bContinuar = false;

  }

  else

  {

  //Mapeo de datos (linea de archivo)

  //-----------------------------------------------------------------------------------------------

  while (bContinuarLinea)

  {

  //Instacias del nodo de lineas

  if ( especialLinea == -1 || inicioLinea > largoLinea)

  {

  bContinuarLinea = false;

  }

  else

  {

  /*if((inicioLinea + saltosLinea) < lineaArch.Length() && lineaArch.Length() != 0 && lineaArch.Length() > 0 && inicioLinea < saltosLinea){ //VDLL*/

  if(!lineaArch.IsInitial()){

  dato = lineaArch.Substring(inicioLinea, saltosLinea);

  }

  /*}//VDLL*/

  switch (contador)

  {

  case 1//Post Date

  {//DATO GENERAL

  if (primerArchivo)

  {

  this.PostDate =  dato;

  archivo.PostDate = dato;

  archivo.zCompany = this.zCompany;

  archivo.setOfBooks = this.setOfBooks;

  archivo.journalEntry = this.journalEntry;

  archivo.screenVariant = this.screenVariant;

  archivo.tCurrency = this.tCurrency;

  archivo.closingStep = this.closingStep;

  archivo.pDate = this.pDate;

  archivo.dDate = this.dDate;

  archivo.eRate = this.eRate;

  archivo.hText = this.hText;

  archivo.glAccount = this.glAccount;

  archivo.TypeJE = "00088";

  }

  else

  {

  newObject.PostDate = dato;

  }

  }

  case 4//2

  {//G/L Account

  /*if (primerArchivo)

  {*/

  linea.AccountNumber = dato;

  }

  case 7//8

  {//Debit in transaction Currency

  linea.Monto.content = dato;//Numeric.ParseFromString(dato);

  /*if (linea.Monto.content >= 0)

  {

    monto = monto + Numeric.ParseFromString(dato);

  }

  else

  {

    montomenor = montomenor + Numeric.ParseFromString(dato);

  }*/

  }

  case 8//9

  {//Cost Center or Sales Order

  //linea.AccountNumber = dato;

  linea.TypeText = dato;

  //linea.CC = dato;

  largoLinea2 = linea.TypeText.Length();

  }

  case 9//10

  {//Employee name

     linea.ItemDescription = dato;

  }

  }

  if (largoLinea2 > 3 || largoLinea2 == 0 )

  {

     linea2.AccountNumber2 = linea.AccountNumber;

  linea2.Monto2.content = linea.Monto.content;

  //linea2.Monto2.content = linea.Monto.content;

  linea2.TypeText2 = linea.TypeText;

  linea2.ItemDescription2 = linea.ItemDescription;

  if (contador == 8){

  if (linea2.Monto2.content >= 0)

  {

    monto2 = monto2 + linea.Monto.content;

    monto = monto - linea2.Monto2.content;

  }

  else

  {

    montomenor2 =  montomenor2 + linea2.Monto2.content;

  }

  }

  //cab.TypeJE = "00047";

             /*linea.AccountNumber = "";

  linea.Monto.content = "";

  linea.TypeText = "";

  linea.ItemDescription = "";

  monto = 0;

  montomenor = 0;*/

  }

  

  inicioLinea = especialLinea + 1;//saltosLinea + 1;

  if ( inicioLinea < lineaArch.Length()){ //VDLL

  especialLinea = lineaArch.Find(",", inicioLinea);

  saltosLinea = lineaArch.Find(",", inicioLinea) - inicioLinea;//this.eContenido.Find(";", inicio) - inicio;

  }//VDLL

  contador = contador + 1;

  }

  }//Cierra while interno

     if (largoLinea2 > 3)

  {

      cab.AmountPrice.content = monto2;

  cab.zCompany = this.zCompany2;

  cab.setOfBooks = this.setOfBooks2;

  cab.journalEntry = this.journalEntry2;

  cab.screenVariant = this.screenVariant2;

  cab.tCurrency = this.tCurrency2;

  cab.closingStep = this.closingStep2;

  cab.pDate = this.pDate2;

  cab.dDate = this.dDate2;

  cab.eRate = this.eRate2;

  cab.hText = this.hText2;

  cab.glAccount = this.glAccount2;

      cab.TypeJE = "00047";

  }

  //-----------------------------------------------------------------------------------------------

  //Generando el objeto del BO

  if (primerArchivo)

  {

     if (largoLinea2 == 3)

  {

     primerLinea = false;

     this.lineasArchivo.Create(linea);

  bContinuarLinea = true;

  /*largoLinea2.Clear();*/

  }

  else

  {

    primerLinea = false;

    this.lineasArchivo2.Create(linea2);

    bContinuarLinea = true;

  }

  largoLinea2.Clear();

  }

  else

  {

  bContinuarLinea = true;

  newObject.lineasArchivo.Create(linea);

  }

  //-----------------------------------------------------------------------------------------------

  inicio = ultCaracterEspecial + 1;

  if ( inicio < this.eContenido.Length()){ //VDLL

  ultCaracterEspecial = this.eContenido.Find(";", inicio);

  saltos = this.eContenido.Find(";", inicio) - inicio;

  }//VDLL

  }//Cierre del else

   }//Cierre del else linea en blanco

  }//Cierra while externo

  //-----------------------------------------------------------------------------------------------

  //Creacion del objeto

  if (primerArchivo)

  {

   

     //if (largoLinea2 == 3){

  this.id = "1";

  this.AmountPrice.content = monto;

  archivo.AmountPrice.content = monto;

  primerArchivo = false;

  /*}

  else{*/

  this.id = "1";

  this.AmountPrice2.content = monto2;

  archivo.AmountPrice2.content = monto2;

  primerArchivo = false;

  /*//cab.AmountPrice = monto2;

  }*/

    this.lineasAsiento.Create(cab);

  }

  else

  {

  newObject.AmountPrice.content = monto;

  newObject.id = "1";

  }

  }//Cierre del ForEach

}

else

{

  mError.Create("E", "No existe un archivo por procesar.");

}

this.afAarchivos.Delete();

Do you have any idea?

Thanks very much for your help!

former_member200567
Active Contributor
0 Kudos

Hi Victor,

As mentioned in the doc, the followings are the reasons. Can you please check?

● Either the start position or the sum of start position and length of the substring is not within the

length of the string (error message)

● The length of the substring succeeds the length of the string (error message)

● The source string is empty (information message)

● The start position or the length of the substring is a negative number (error message)

Best Regards

Fred

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Fred.

Finally the problem was in a negative number.

Thanks a lot.

former_member200567
Active Contributor
0 Kudos

Hi Victor,

Glad to hear that

Best Regards

Fred