Campos empaquetados en archivo de texto
Campos empaquetados en archivo de texto
Hola a todos... tanto tiempo...tratando de volver al ruedo.
Espero que estén muy bien.
Necesito ayuda para leer campos empaquetados (Comp-3 (Packed Decimals)) en un archivo de texto proveniente de un mainframe.
He probado con todas las funciones en Harbour y FiveWin y sin ningún resultado.
Alguien podría orientarme como lograrlo o si alguien tiene alguna función facilitármela o vendérmela ?
Desde ya muchísimas gracias.
Abrazo
Miguel
Espero que estén muy bien.
Necesito ayuda para leer campos empaquetados (Comp-3 (Packed Decimals)) en un archivo de texto proveniente de un mainframe.
He probado con todas las funciones en Harbour y FiveWin y sin ningún resultado.
Alguien podría orientarme como lograrlo o si alguien tiene alguna función facilitármela o vendérmela ?
Desde ya muchísimas gracias.
Abrazo
Miguel
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
- karinha
- Posts: 7932
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Campos empaquetados en archivo de texto
Ni con el cobol rebuild.exe que converte para txt?
Regards, saludos.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Campos empaquetados en archivo de texto
Gracias Karina por responder. Pero estoy medio en las nubes .... "cobol rebuild.exe" perdón pero que es eso?
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
- Antonio Linares
- Site Admin
- Posts: 42513
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: Campos empaquetados en archivo de texto
Puedes proporcionar un fichero de ejemplo empaquetado con Comp-3 (Packed Decimals) ?
Re: Campos empaquetados en archivo de texto
Antonio maestro querido tanto tiempo.... te lo preparo. Debo hacer una extracción porque el archivo pesa más de 10Gb
Gracias
Abrazo
Gracias
Abrazo
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
Re: Campos empaquetados en archivo de texto
Antonio te envié por privado la muestra ya que no encontré la forma de enviarlo por este medio.
Gracias. Abrazo
Miguel
Gracias. Abrazo
Miguel
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
- Antonio Linares
- Site Admin
- Posts: 42513
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: Campos empaquetados en archivo de texto
Miguel,
gracias por avisarme, ya lo encontré, fué a la carpeta de spam![Smile :-)](./images/smilies/icon_smile.gif)
gracias por avisarme, ya lo encontré, fué a la carpeta de spam
![Smile :-)](./images/smilies/icon_smile.gif)
- Antonio Linares
- Site Admin
- Posts: 42513
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: Campos empaquetados en archivo de texto
Miguel Angel,
Aqui tienes unas funciones en C# y VB que facilmente (son pequeñas) puedes pasar a Harbour:
https://newbedev.com/c-convert-comp-3-packed-decimal-to-human-readable-value
https://stackoverflow.com/questions/142972/c-convert-comp-3-packed-decimal-to-human-readable-value
Aqui tienes unas funciones en C# y VB que facilmente (son pequeñas) puedes pasar a Harbour:
https://newbedev.com/c-convert-comp-3-packed-decimal-to-human-readable-value
https://stackoverflow.com/questions/142972/c-convert-comp-3-packed-decimal-to-human-readable-value
Re: Campos empaquetados en archivo de texto
Gracias maestro. Ahora me fijo
Gracias Gracias.
Abrazo enorme
Gracias Gracias.
Abrazo enorme
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
Re: Campos empaquetados en archivo de texto
Voy a tratar pasar la función de C# a Harbour aunque mis conocimientos en C son muy escasos. De VB ni idea.
Pero de alguna manera tengo que lograrlo ya que dependo de esta bendita función para lograr insertarme laboralmente.
Gracias a todos
Abrazo
Miguel
Pero de alguna manera tengo que lograrlo ya que dependo de esta bendita función para lograr insertarme laboralmente.
Gracias a todos
Abrazo
Miguel
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
Re: Campos empaquetados en archivo de texto
Bueno estuve intentándolo todo el día y no hay caso...mis conocimientos en C son mucho más escasos de lo que suponía y no pude pasar la función para probarla.
Igualmente gracias por todo a todos.
Abrazo
Miguel
Igualmente gracias por todo a todos.
Abrazo
Miguel
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
- Antonio Linares
- Site Admin
- Posts: 42513
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: Campos empaquetados en archivo de texto
Antonio acá te lo dejo... es muy poco lo que hice .... mis conocimientos en C son totalmente nulos
De hecho no sé por donde empezar.
#include <Windows.h>
#include <hbapi.h>
HB_FUNC( Pack2Text )
{
private Decimal Unpack(byte[] inp, int scale)
{
long lo = 0;
long mid = 0;
long hi = 0;
bool isNegative;
// this nybble stores only the sign, not a digit.
// "C" hex is positive, "D" hex is negative, and "F" hex is unsigned.
switch (nibble(inp, 0))
{
case 0x0D:
isNegative = true;
break;
case 0x0F:
case 0x0C:
isNegative = false;
break;
default:
throw new Exception("Bad sign nibble");
}
long intermediate;
long carry;
long digit;
for (int j = inp.Length * 2 - 1; j > 0; j--)
{
// multiply by 10
intermediate = lo * 10;
lo = intermediate & 0xffffffff;
carry = intermediate >> 32;
intermediate = mid * 10 + carry;
mid = intermediate & 0xffffffff;
carry = intermediate >> 32;
intermediate = hi * 10 + carry;
hi = intermediate & 0xffffffff;
carry = intermediate >> 32;
// By limiting input length to 14, we ensure overflow will never occur
digit = nibble(inp, j);
if (digit > 9)
{
throw new Exception("Bad digit");
}
intermediate = lo + digit;
lo = intermediate & 0xffffffff;
carry = intermediate >> 32;
if (carry > 0)
{
intermediate = mid + carry;
mid = intermediate & 0xffffffff;
carry = intermediate >> 32;
if (carry > 0)
{
intermediate = hi + carry;
hi = intermediate & 0xffffffff;
carry = intermediate >> 32;
// carry should never be non-zero. Back up with validation
}
}
}
return new Decimal((int)lo, (int)mid, (int)hi, isNegative, (byte)scale);
}
private int nibble(byte[] inp, int nibbleNo)
{
int b = inp[inp.Length - 1 - nibbleNo / 2];
return (nibbleNo % 2 == 0) ? (b & 0x0000000F) : (b >> 4);
}
}
De hecho no sé por donde empezar.
#include <Windows.h>
#include <hbapi.h>
HB_FUNC( Pack2Text )
{
private Decimal Unpack(byte[] inp, int scale)
{
long lo = 0;
long mid = 0;
long hi = 0;
bool isNegative;
// this nybble stores only the sign, not a digit.
// "C" hex is positive, "D" hex is negative, and "F" hex is unsigned.
switch (nibble(inp, 0))
{
case 0x0D:
isNegative = true;
break;
case 0x0F:
case 0x0C:
isNegative = false;
break;
default:
throw new Exception("Bad sign nibble");
}
long intermediate;
long carry;
long digit;
for (int j = inp.Length * 2 - 1; j > 0; j--)
{
// multiply by 10
intermediate = lo * 10;
lo = intermediate & 0xffffffff;
carry = intermediate >> 32;
intermediate = mid * 10 + carry;
mid = intermediate & 0xffffffff;
carry = intermediate >> 32;
intermediate = hi * 10 + carry;
hi = intermediate & 0xffffffff;
carry = intermediate >> 32;
// By limiting input length to 14, we ensure overflow will never occur
digit = nibble(inp, j);
if (digit > 9)
{
throw new Exception("Bad digit");
}
intermediate = lo + digit;
lo = intermediate & 0xffffffff;
carry = intermediate >> 32;
if (carry > 0)
{
intermediate = mid + carry;
mid = intermediate & 0xffffffff;
carry = intermediate >> 32;
if (carry > 0)
{
intermediate = hi + carry;
hi = intermediate & 0xffffffff;
carry = intermediate >> 32;
// carry should never be non-zero. Back up with validation
}
}
}
return new Decimal((int)lo, (int)mid, (int)hi, isNegative, (byte)scale);
}
private int nibble(byte[] inp, int nibbleNo)
{
int b = inp[inp.Length - 1 - nibbleNo / 2];
return (nibbleNo % 2 == 0) ? (b & 0x0000000F) : (b >> 4);
}
}
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
Re: Campos empaquetados en archivo de texto
Buenos días a todos.
Alguien por favor podría pasar esta función en C para utilizarla en FiveWin/Harbour?
Gustoso le abonaría por el trabajo realizado.
En verdad necesito poder convertir estos benditos campos ....necesito desesperadamente poder tomar este trabajo, que me ayudaría a pasar esta situación que estamos viviendo en mi amado país.
Desde ya muchísimas gracias.
Abrazo enorme
Miguel
Alguien por favor podría pasar esta función en C para utilizarla en FiveWin/Harbour?
Gustoso le abonaría por el trabajo realizado.
En verdad necesito poder convertir estos benditos campos ....necesito desesperadamente poder tomar este trabajo, que me ayudaría a pasar esta situación que estamos viviendo en mi amado país.
Desde ya muchísimas gracias.
Abrazo enorme
Miguel
FWH 32/64 14.04
Harbour 3.2.0 (r1306211258)
PellesC
Harbour 3.2.0 (r1306211258)
PellesC
- carlos vargas
- Posts: 1721
- Joined: Tue Oct 11, 2005 5:01 pm
- Location: Nicaragua
Re: Campos empaquetados en archivo de texto
encontre, esto, no tengo muy claro la parte de la lectura del archivo...
http://www.verycomputer.com/165_a88f85a8a4ea61b7_1.htm
m_str = fread( ifp, m_cnt )
http://www.verycomputer.com/165_a88f85a8a4ea61b7_1.htm
Code: Select all | Expand
FUNCTION comp_3( m_cnt )
PRIVATE m_str, m_data, m_cnt, m_luku, m_ub, m_lb, m_uc, m_lc
m_ub := 0
m_lb := 0
m_uc := ""
m_lc := ""
m_str = fread( ifp, m_cnt )
m_data = ""
FOR i = 1 TO m_cnt
m_ub := int( asc( subs( m_str, i, 1 ) ) / 16 )
m_lb := asc( subs( m_str, i, 1 ) ) - ( m_ub * 16 )
m_uc := chr( 48 + m_ub )
m_lc := chr( 48 + m_lb )
if i < m_cnt
m_data := m_data + m_uc + m_lc
else
m_data := iif( m_lc = "=", "-" + m_data + m_uc,"+" + m_data + m_uc )
endif
NEXT
RETURN m_data
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
Carlos Vargas
Desde Managua, Nicaragua (CA)