Hi all,
Thanks in advance ..
I have a form where I have a command button, by clicking on it a report will automatically run and will be saved as a pdf in the given path. The report has a request option form, there are two variables, where I need to pass parameters while running it from the form. I have done this by writing a few codes.. but the problem is I dont want to show the ReqWindow or anything, the whole process should be done automatically while clicking on the button. But if I use reportvariable.runmodal it will open the window, and if I use report.runmodal(reportID,false,false,recordvariable), then it is not working... please help..here are my codes.
IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);
ReportID:=50028;
FileDirectory := 'C:\New Folder\';
FileName := 'test'+'.pdf';
Object.GET(Object.Type::Report,'',ReportID);
recSalesInvHeader.RESET;
recSalesInvHeader.SETRANGE(recSalesInvHeader."Publication Type",'01');
recSalesInvHeader.SETRANGE(recSalesInvHeader."Posting Date",140511D);
IF recSalesInvInvHeader.FINDSET THEN BEGIN
BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue('Output',FileDirectory+FileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);
RepAddBill.PassParam('01',140511D); // this is the func of the report pasing 2 parameters
REPORT.RUNMODAL(ReportID,FALSE,FALSE,recSalesInvHeader);
//RepAddBill.RUNMODAL;
TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
SLEEP(1500);
TimeOut := TimeOut + 1;
END;
END;
0
Comments
Try the example code from Rashed in the thread How to save Navision Reports as PDF or his blog http://mibuso.com/blogs/ara3n/2008/08/0 ... ts-to-pdf/ .
well the problem is, when I am using simple reports say for exp - (customer-list) where there is no request form, only request filter field, it is working fine using runmodal by setting the reqwindow false... as I told you I want the whole thing will be done automatically.. but in my report there are two dataitems, and a few filters which have been done in the onpre dataitem using setrange and setfilter and I have applied a few filter in the properties as well... in that case it's not working, the system hangs for few seconds, perhaps it's because of the sleep time...but no pdf is generated at all.... I hope I am able to make you understand.
Thanks a lot... and i have gone through this link earlier, even I have used it few times before.. I know that I have done something wrong or missed something but can't resolve it...
Your problem is that you created a report variable to pass the parameters and then you call it by the ReportID. This will not work.
This should work. Be sure to clear your RepAddBill variable, because you're running it modally.
Hope this helps,
Regards,
Willy
Hi KYDutchie,
It works, thanks a lot..I overlooked the USEREQUESTFORM property, that's why I kept trying to run it using reportID. Anyways thanks a ton..
please mark the topic as solved.
thanks,
Willy