Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with generating pdf script (dutchie) 1

Status
Not open for further replies.

kikkerkermit

Programmer
Nov 13, 2005
7
NL
Dear cognos experts,

I have script problem and i need desperately help. Sometimes i pass a variabele to a powerplay report that gives an empty report.
I get than the message, and the script process hangs.

message:
THIS REPORT CONTAINS NO DATA VALUES. NO PDF FILE WAS CREATED

But what i want is that the report resumes.
I have tried on error resume next but this does not work. does someone has an idea, please !!!

Thanks in advance

SCRIPT (in the script stands the message on the line with *** ***)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Naam : Genereer '
' Eigenaar : Maarten van Eck Getronics/PinkRoccade Food '
' Datum : 16-11-2005 '
' Versie : 1.0 '
' Ltste wijziging : 16-11-2005 '
' '
' Doel : Aan de hand van een extern bestand wordt een filter '
' opgehaald. Deze wordt vervolgens naar een PowerPlay rapport '
' rapport gestuurd en tot slot wordt een excelbestand of PDF-bestand '
' van dit PowerPlay rapport gemaakt. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


' CONSTANTEN

CONST Inputfile = "G:\Cognos\Tombola\input\inputmail.txt"

' VARIABELEN

DIM Rapport as String
DIM Excelrapport as String
DIM Export as String
DIM Lijst as String
DIM Aantal as Integer
DIM Regel as String
DIM Home as String
DIM Teller as Integer
DIM Duur as Long
dim strPadImpReport as String
dim strPadMacro as String
dim strPadXLSReport as String
dim strPadPDFReport as String
dim strPadXLSServer as String
dim strPadPDFServer as String
dim Serverdir as String
dim ivpdir as String
Dim SourceName As String
Dim DestPDFName As String
Dim objPDF as Object
Dim objPPRep as Object
Dim objPPAPP as Object
DIM ExcelSheet as Object

Sub Main()

'Paden instellen
strPadImpReport = "G:\Cognos\Tombola\reports\"
strPadMacro = "G:\Cognos\Tombola\macro\"
strPadCatalog = "G:\Cognos\Tombola\catalog\"
strPadXLSReport = "G:\Cognos\Tombola\xls\"
strPadPDFReport = "G:\Cognos\Tombola\pdf\"
strPadXLSServer = "G:\Cognos\Tombola\xls\"
strPadPDFServer = "k:\tombola\pdf\"

'Powerplay openen waarbij de postwijk centraal staat.

SourceName = "G:\Cognos\Tombola\Cube\mozaiek.ppr"

'Openen van PowerPlay
Set objPPAPP = CreateObject("CognosPowerPlay.Application")
objPPAPP.Application.Visible =True


'Te exporteren rapporten opzoeken
Open InputFile For Input As #1

'Logfile openen
kill strPadPDFReport & "logfile.txt"
Open strPadPDFReport & "logfile.txt" For Output As #2

'Beginnen bij derde regel
Line Input #1, Regel
Line Input #1, Regel

'Starttijd wegschrijven in logfile
Print #2, "================================================================================="
Print #2, " LOGFILE GENEREREN PDF BESTANDEN "
Print #2, "================================================================================="
Print #2, "Startdatum: " & Date$
Print #2, "Starttijd : " & Time$
Print #2, "================================================================================="


do while not EOF(1)
Line Input #1, Regel
regio = Trim(Left (Regel, 10))
bezorger = Trim(Mid (Regel,13,16))


' Openen van PowerPlay-rapport

Set objPPRep = CreateObject("CognosPowerPlay.Report")
objPPRep.Open SourceName
objPPRep.Visible = True

' Elke keer terug naar het bovenste niveau
objPPRep.dimensionline.item("regio").changetotop
' Geef de parameter door
objPPRep.dimensionline.item("regio").change(regio)


'-----------------------------------------------------'
' Creeren PDF bestand
'-----------------------------------------------------'

Set objPDF = objPPRep.PDFFile( "g:\cognos\tombola\pdf\" & regio & "_postwijk.pdf" , True )
With objPDF
.SaveEntireReport = True
.SaveAllCharts = True
.AxisOnAllPages = True
.ChartTitleOnAllPages = True
.IncludeLegend = True
.SetListOfLayersToSave objPPRep.Layers
.SetListOfRowsToSave objPPRep.Rows
End With
objPDF.Save
on error resume next
Set objPDF = Nothing
objPPRep.Close
Set objPPRep = Nothing
loop


********** Sometimes I Got THE POPUP: THIS REPORT CONTAINS NO DATA VALUES. NO PDF FILE WAS CREATED *************


'Eindtijd wegschrijven in logfile
' Duur = Time - Duur
Print #2, ""
Print #2, "================================================================================="
Print #2, "Einddatum: " & Date$
Print #2, "Eindtijd : " & Time$
' Print #2, "Duur : " & Minute(Duur)
Print #2, "================================================================================="

Close #1
Close #2

'PowerPlay sluiten
'objPPRep.Quit
'Set objPPRep = Nothing
objPPAPP.Quit
Set objPPAPP = Nothing




 
hallo Maarten,

The pop up makes sense. You implemeted a "error handler" but that is no use for this behaviour. You must simply check BEFORE you save the report as pdf if the report is empty. If empty do NOT save the report. It's that simple.

If you need more information, just let me know.

succes ermee!

christenhusz
 
Dear christenhusz,

Thanks for your answer
Can you please tell me how you should realize this in code

Greeting maarten
 
Maarten,

This worked for me. Count the rows and columns <> 0 then save the report otherwise close the report.

'If there are no rows OR columns in the report the save as PDF option
'will generate a message window. Check therefore the number of row and columns.

countrow=objPPRep.Rows.Count
countcol=objPPRep.columns.Count

If (countrow = 0 or countcol = 0) Then
'Empty report
objPPApp.Quit
SendKeys "N",1
Else
'Filled report
objPDFRep.Save
objPPApp.Quit
End if

Succes,

Christenhusz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top