{*******************************************************} { } { Administración de puntos de venta } { } { Copyright (C) 2006 Rodax Software S.L. } { } {*******************************************************} unit EDI_INVRPT; interface uses Classes, EDI_Reader; const LONG_LINEA_CAB = 101; LONG_LINEA_LIN = 319; LONG_LINEA_CANT = 100; type TEDIFILE_CABINV = record REGISTRO_OK : boolean; NUMDOC : array[1..25] of char; TIPODOC : array[1..3] of char; TIPOLIQ : array[1..3] of char; FECHA : array[1..8] of char; FECHALIQ: array[1..8] of char; EMISOR : array[1..17] of char; RECEPTOR: array[1..17] of char; DPTO : array[1..3] of char; CENTRO : array[1..17] of char; end; TEDIFILE_LININV = record REGISTRO_OK : boolean; NUMDOC : array[1..25] of char; NUMLIN : array[1..6] of char; CODART : array[1..17] of char; FAMILIA : array[1..17] of char; BARRA : array[1..17] of char; TALLA : array[1..17] of char; MARCA : array[1..25] of char; TAMANO : array[1..25] of char; SERIE : array[1..25] of char; COLOR : array[1..25] of char; MODELO : array[1..25] of char; DIBUJO : array[1..25] of char; DESCRIP : array[1..70] of char; end; TEDITFILE_CANTINV = record REGISTRO_OK : boolean; NUMDOC : array[1..25] of char; NUMLIN : array[1..6] of char; NUMCANT : array[1..6] of char; TIPOCANT: array[1..3] of char; CANTIDAD: array[1..15] of char; CENTRO : array[1..17] of char; TMOV : array[1..3] of char; FACT : array[1..12] of char; DEPTO : array[1..3] of char; IDVEN : array[1..10] of char; end; PCABINV = ^TEDIFILE_CABINV; PLININV = ^TEDIFILE_LININV; PCANTINV= ^TEDITFILE_CANTINV; TCABINV_Reader = class(TEDIFile_Reader) protected function ProcessLine (const ALine : String) : Boolean; override; end; TLININV_Reader = class(TEDIFile_Reader) protected function ProcessLine (const ALine : String) : Boolean; override; end; TCANTINV_Reader = class(TEDIFile_Reader) protected function ProcessLine (const ALine : String) : Boolean; override; end; implementation uses SysUtils, Dialogs, uDataModuleEDI_Inventary; { TLININV_Reader } function TLININV_Reader.ProcessLine(const ALine: String): Boolean; var Registro : TEDIFILE_LININV; pRegistro : PLININV; LongLinea : Integer; AuxLine : String; begin Result := False; LongLinea := Length(ALine); { Por si la línea fuera más larga o más corta de lo normal, la hago de de la longitud que debería tener } AuxLine := Format('%-' + IntTostr(LONG_LINEA_LIN) + '.' + IntTostr(LONG_LINEA_LIN) + 's', [ALine]); // Inicializo los campos del registro. FillChar(Registro, SizeOf(TEDIFILE_LININV), 0); { Para rellenar el campo REGISTRO_OK del registro mediante el 'move', añado al principio de AuxLine el byte #0 (valor para 'False'). } AuxLine := Concat(#0, AuxLine); Move(AuxLine[1], Registro, LONG_LINEA_LIN+1); // +1 por el byte del concat // El registro es correcto si tiene la longitud adecuada. Registro.REGISTRO_OK := (LongLinea = LONG_LINEA_LIN); // Añado el registro a la lista de registros. New(pRegistro); Move(Registro, pRegistro^, SizeOf(TEDIFILE_LININV)); FileData.Add(pRegistro); Result := True; end; { TCABINV_Reader } function TCABINV_Reader.ProcessLine(const ALine: String): Boolean; var Registro : TEDIFILE_CABINV; pRegistro : PCABINV; LongLinea : Integer; AuxLine : String; begin Result := False; LongLinea := Length(ALine); { Por si la línea fuera más larga o más corta de lo normal, la hago de de la longitud que debería tener } AuxLine := Format('%-' + IntTostr(LONG_LINEA_CAB) + '.' + IntTostr(LONG_LINEA_CAB) + 's', [ALine]); // Inicializo los campos del registro. FillChar(Registro, SizeOf(TEDIFILE_CABINV), 0); { Para rellenar el campo REGISTRO_OK del registro mediante el 'move', añado al principio de AuxLine el byte #0 (valor para 'False'). } AuxLine := Concat(#0, AuxLine); Move(AuxLine[1], Registro, LONG_LINEA_CAB+1); // +1 por el byte del concat // El registro es correcto si tiene la longitud adecuada. Registro.REGISTRO_OK := (LongLinea = LONG_LINEA_CAB); // Añado el registro a la lista de registros. New(pRegistro); Move(Registro, pRegistro^, SizeOf(TEDIFILE_CABINV)); FileData.Add(pRegistro); Result := True; end; { TCANTINV_Reader } function TCANTINV_Reader.ProcessLine(const ALine: String): Boolean; var Registro : TEDITFILE_CANTINV; pRegistro : PCANTINV; LongLinea : Integer; AuxLine : String; begin Result := False; LongLinea := Length(ALine); { Por si la línea fuera más larga o más corta de lo normal, la hago de de la longitud que debería tener } AuxLine := Format('%-' + IntTostr(LONG_LINEA_CANT) + '.' + IntTostr(LONG_LINEA_CANT) + 's', [ALine]); // Inicializo los campos del registro. FillChar(Registro, SizeOf(TEDITFILE_CANTINV), 0); { Para rellenar el campo REGISTRO_OK del registro mediante el 'move', añado al principio de AuxLine el byte #0 (valor para 'False'). } AuxLine := Concat(#0, AuxLine); Move(AuxLine[1], Registro, LONG_LINEA_CANT+1); // +1 por el byte del concat // El registro es correcto si tiene la longitud adecuada. Registro.REGISTRO_OK := (LongLinea = LONG_LINEA_CANT); // Añado el registro a la lista de registros. New(pRegistro); Move(Registro, pRegistro^, SizeOf(TEDITFILE_CANTINV)); FileData.Add(pRegistro); Result := True; end; end.