1
votes

I have some experience with Rave Reports 10 i've made lot of reports in the past, but now im having a issue with generation of it.

Checklist: On main form -RvProject -RvSystem -RvDataSet -RvRenderPDF

All of them set up

On Rave designer i can generate the report sucessfully but when i use the code it generate a blank page.

Can you check my code and tell me if im missing something please? Im stucked at this steep since two days ago, and cant solve this issue.

I know there is a lot of variables without use, but im trying some things.

procedure TFormPrincipal.ImprimirReporteDeNomina(FechaCorte:String);
var
  DireccionMisDocumentos,A:String;
  Año, Mes, Dia:Word;
  I:Integer;
  MyFields: array of TField;
  Temf: TStringField;
  DataView: TRaveBaseDataView;
  myPage:TRavePage;
  MyDataText:TRaveDataText;
  MyText:TRaveText;
  //MyPage2:TRavePage;
  nMarginBottom, nMarginLeft, nMarginRight, nMarginTop: Double;
begin
  with RvProject1 do
    begin
      SetLength(FechaCorte,10);

      //A:=GetCurrentDir()+'\Data\NOMREP1.rav';
      //ProjectFile:=GetCurrentDir()+'\Data\NOMREP1.rav';
      //Open;
      //LoadFromFile(GetCurrentDir()+'\Data\NOMREP1.rav');
      //StoreRAV:=True;
      //ZQuery2.Fields.Clear;
      ZQuery2.Close;
      ZQuery2.SQL.Clear;
      ZQuery2.SQL.Add('Select');
      ZQuery2.SQL.Add('NumeroEmpleado,');
      ZQuery2.SQL.Add('Cargo,');
      ZQuery2.SQL.Add('Nombre,');
      ZQuery2.SQL.Add('Apellido,');
      ZQuery2.SQL.Add('Format(Cedula,0),');
      ZQuery2.SQL.Add('Ingreso,');
      ZQuery2.SQL.Add('Format(SalarioMensual,2),');
      ZQuery2.SQL.Add('Format(SalarioDiario,2),');
      ZQuery2.SQL.Add('Format(CTDiario,2),');
      ZQuery2.SQL.Add('DiasTrabajados,');
      ZQuery2.SQL.Add('DiasLibres,');
      ZQuery2.SQL.Add('CT,');
      ZQuery2.SQL.Add('Ausencias,');
      ZQuery2.SQL.Add('Format(SSO,2),');
      ZQuery2.SQL.Add('Format(RPE,2),');
      ZQuery2.SQL.Add('Format(FAOV,2),');
      ZQuery2.SQL.Add('Format(TotalSueldo,2),');
      ZQuery2.SQL.Add('Format(TotalSanciones,2),');
      ZQuery2.SQL.Add('Format(TotalCT,2),');
      ZQuery2.SQL.Add('Format(TotalDiasLibres,2),');
      ZQuery2.SQL.Add('Format(TotalAusencias,2),');
      ZQuery2.SQL.Add('Format(TotalAsignaciones,2),');
      ZQuery2.SQL.Add('Format(TotalDeducciones,2),');
      ZQuery2.SQL.Add('Format(TotalCobrar,2)');
      ZQuery2.SQL.Add('From Constructor.ZRepNom');
      //ZQuery2.Open;
      //ZQuery2.Close;

      {
      SetLength(MyFields, ZQuery2.FieldDefs.Count);
      //Add one by one the fields to make them accesible.
      for i:=0 to ZQuery2.FieldDefs.Count - 1 do
        MyFields[i] := ZQuery2.FieldDefs[i].CreateField(ZQuery2);
      //Create all Calculated Fields as you need
      Temf := TStringField.Create(nil);
      Temf.FieldKind := fkCalculated;
      //Temf.FieldName := 'NewCalcField';
      }
      Open;

      With ProjMan do
        begin
          Dataview := FindRaveComponent('DataView1',nil) as TRaveBaseDataView;
          CreateFields(DataView, nil, nil, true); // refresh the dataview
        end;

      With ProjMan do
        begin
          MyPage := FindRaveComponent('Report1.Page1',nil) as TRavePage;
          MyText := FindRaveComponent('FECHACORTE',MyPage) as TRaveText;
          MyText.Text:=FechaCorte;
        end; { with }

      Save;
      {
      with IACProyectUnidades.ProjMan do
        begin
          nMarginBottom := 0.5;
          nMarginLeft := 0.5;
          nMarginRight := 0.5;
          nMarginTop := 0.5;
        end;
        }
      //seleccionamos el printer por defecto,
      //asi salen los reportes tal cual queremos
      //desde cualquier maquina con cualquier impresora
      RpDev.SelectPrinter('microsoft xps document writer', False );
      DireccionMisDocumentos:=GetMyDocuments;
      if Not (DirectoryExists(DireccionMisDocumentos+'\Informes Luminatti\Nomina')) then
        CreateDir(DireccionMisDocumentos+'\Informes Luminatti\Nomina');
      //Label4.Caption:= 'Generando Reporte...';
      RvSystem1.DefaultDest := rdFile;
      RvSystem1.DoNativeOutput := false;
      RvSystem1.RenderObject := RvRenderPDF1;
      RvSystem1.OutputFileName := DireccionMisDocumentos+'\Informes Luminatti\Nomina\['+NOMREPMes.Text+' '+FechaCorte+']Reporte de Nómina.pdf';
      RvSystem1.SystemSetups := RvSystem1.SystemSetups - [ssAllowSetup];
      //ZConnection1.Connected:=False;
      RvSystem1.Execute;
      //Label4.Caption:= 'Reporte Generado!';
      ShellExecute(FormPrincipal.Handle,nil,PChar(DireccionMisDocumentos+'\Informes Luminatti\Nomina\['+NOMREPMes.Text+' '+FechaCorte+']Reporte de Nómina.pdf'),'','',SW_SHOWMAXIMIZED);
    end;
end;
1

1 Answers

2
votes

I finally found the error, was a writing mistake

The error was: RvSystem1.Execute;

The correct way is: RvProject1.Execute;

Its solved