I am facing error while saving report in Pdf in a drive

Hello Experts,
I am facing error while saving report in Pdf in a drive
“there is insufficient memory to execute this function this may be due to Recursive function call contact your system administrator”
I am using code for the Pdf create that is

BEGIN
IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);
ReportID := REPORT::“Customer - Statement of A/C”;
FileDirectory := ‘D:\Sachin’;
Window.OPEN(‘processing Cusomer ######################1##’);
Object.GET(Object.Type::Report,’’,ReportID);
IF Customer.FINDSET THEN
//REPEAT

Window.UPDATE(1,Customer.“No.”);
FileName := Customer.“No.” + ‘.pdf’;
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);
Customer2 := Customer;
Customer2.SETRECFILTER;
REPORT.RUNMODAL(ReportID,FALSE,FALSE,Customer2);

TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut< 10) DO BEGIN
SLEEP(1000);
TimeOut := TimeOut + 1;

MESSAGE(Text);
END;
//UNTIL Customer1.NEXT = 0;
Window.CLOSE;
END;

so I am unable to understand what is the exact fault in the code so Experts please share your feedback please.
Thanks in Advance .

First, I see an error in REPEAT…UNTIL loop, despite is commented:

IF Customer.FINDSET THEN

//REPEAT

//UNTIL Customer1.NEXT = 0; → Here you need to use Customer and not Customer1

Moreover, I’d rather use this kind of statements for running the report:

Customer2.RESET;

Customer2.SETRANGE(“No.”,Customer.“No.”);

REPORT.RUNMODAL(ReportID,FALSE,FALSE,Customer2);

Third, did you write this code in an external report/codeunit? Don’t you have any further call of itself inside “Customer - Statement of A/C” report?

Many Thanks for reply

yes i write this code in codeunit and i did some modification in code which is

Customer.SETRANGE(“No.”,CustNo);
IF Customer.FINDFIRST THEN BEGIN

IF ISCLEAR(File1) THEN
CREATE(File1);

IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);

IF NOT File1.FolderExists(UserSetup.“Path to Save Report”) THEN
File1.CreateFolder(UserSetup.“Path to Save Report”);

Filename1:= UserSetup.“Path to Save Report” +‘Statement’+ ‘.pdf’;

IF EXISTS(Filename1) THEN
ERASE(Filename1);

BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue(‘Output’,Filename1);
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);

SalesStat.SETTABLEVIEW(Customer);
SalesStat.USEREQUESTFORM(FALSE);
SalesStat.RUNMODAL;

//>>Code for Deay - Start
TimeOut := 0;
WHILE (TimeOut < 20) DO BEGIN
SLEEP(1000);
TimeOut += 1;
END;
//<<Code for Deay - End

CLEAR(File1);
CLEAR(BullZipPDF);

END;
MESSAGE(‘Saved Successfully!!!’);

check setup@>>>>>>>>>>>>>>

UserSetup.GET(USERID);
UserSetup.TESTFIELD(“Path to Save Report”);

when i am calling this code in report then it going into infinite loop mean there is not enough memory to execute this function this may be cause of recusive function i tried so hard to overcome this error but could not resolve this please help me …

Running the report directly from object designer gives the same problem? I guess there is some inside it that makes him go in an infinite loop.

hi Daniele

Thanks for the reply now pdf is generated now there is a issue when i am running this report for two or more customer it is saving only first customer pdf except all and error showing

**"**Auto-save mode: The destination file J:\plm\max users.pdf is in use. The process was stopped to prevent data loss."

what is this error don’t know…

now what to do for this issue any idea or any solution for this please share …

When composing the file name, did you add a unique identifier (e.g. customer no.) to generate a unique file for every customer processed?

Thanks again Daniele

yeah i mentioned the unique identifier this is the statement for …

FileDir:=‘E:\Customer’;
FileName:=‘CustomerStatement’+Customer.“No.”+’.pdf’;

actually as i run this report for multiple customer show error and did not save multiple pdf actually i have done this using pdfcreater…[*-)]

I think in your case the creation of the second file starts when the first file is not finished yet and BullZip doesn´t allow two contemporary instances: try inserting a long sleep like 60 seconds as attempt to see if the problem is solved.

thanks again deniele

its not working still it is saving only one customer pdf what to do i am doing same thing from both pdfcreater and bullzip but facing same error in both …

Can you try setting this further parameter to the BullZip automation?

BullZipPDF.SetValue(‘ShowSaveAS’, ‘never’);

nope not working i did some changes in code but result is same what to do? [8-)]

check this code

CheckSetup;>>>>>>>function

UserSetup.GET(USERID);
UserSetup.TESTFIELD(“Path to Save Report”);

///// code();

CheckSetup;
Customer.SETRANGE(“No.”,CustNo);
MESSAGE(CustNo);
IF Customer.FINDFIRST THEN BEGIN

IF ISCLEAR(File1) THEN
CREATE(File1);

IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);

IF NOT File1.FolderExists(UserSetup.“Path to Save Report”) THEN
File1.CreateFolder(UserSetup.“Path to Save Report”);

Filename1:= UserSetup.“Path to Save Report” +‘Statement’+CustNo+’.pdf’;

IF EXISTS(Filename1) THEN
ERASE(Filename1);

BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue(‘Output’,Filename1);
BullZipPDF.SetValue(‘Showsettings’, ‘never’);
BullZipPDF.SetValue(‘ShowSaveAS’, ‘never’);
BullZipPDF.SetValue(‘ShowPDF’, ‘no’);
BullZipPDF.SetValue(‘ShowProgress’, ‘no’);
BullZipPDF.SetValue(‘ShowProgressFinished’, ‘no’);
BullZipPDF.SetValue(‘SuppressErrors’, ‘yes’);
BullZipPDF.SetValue(‘ConfirmOverwrite’, ‘no’);
BullZipPDF.WriteSettings(TRUE);

SalesStat.SETTABLEVIEW(Customer);
SalesStat.USEREQUESTFORM(FALSE);
SalesStat.RUNMODAL;
//>>Code for Deay - Start
TimeOut := 0;
WHILE (TimeOut < 20) DO BEGIN
SLEEP(10000);
TimeOut += 1;
END;
//<<Code for Deay - End

CLEAR(File1);
CLEAR(BullZipPDF);

END;
MESSAGE(‘Saved Successfully!!!’);

Hi ,

Make sure you set Bullzip as default printer, or set it up in Printer Selection for the user or report.
Download Bullzip PDF Printer and install it. Import the form.txt file into NAV and compile it and run it. The example will loop through customers and create one pdf document per customer.

first test this and u will come to know the difference on u r own.

http://mibuso.com/blogs/ara3n/2008/08/01/save-nav-reports-to-pdf/

OBJECT Form 50101 Example Report to PDF files

{

OBJECT-PROPERTIES

{

Date=07/31/08;

Time=10:44:15 PM;

Modified=Yes;

Version List=PDFCreator;

}

PROPERTIES

{

Width=9460;

Height=3960;

}

CONTROLS

{

{ 1000000000;CommandButton;990;660;5060;1210;CaptionML=ENU=Print and save as PDF;

OnPush=BEGIN

PrintToBullZip;

END;

}

}

CODE

{

VAR

FileDirectory@1000000000 : Text[100];

FileName@1000000010 : Text[100];

ReportID@1000000001 : Integer;

Object@1000000002 : Record 2000000001;

BullZipPDF@1000000004 : Automation “{61CB5BFA-AFE6-4B0F-A4BB-7F3D4999EE52} 3.2:{BEBDC1DF-D793-4F6C-B8FF-E831A1C2595C}:‘Bullzip’.PDFPrinterSettings”;

Window@1000000007 : Dialog;

RunOnceFile@1000000005 : Text[1000];

TimeOut@1000000006 : Integer;

Customer@1000000003 : Record 18;

Customer2@1000000011 : Record 18;

PROCEDURE PrintToBullZip@1000000000();

BEGIN

IF ISCLEAR(BullZipPDF) THEN

CREATE(BullZipPDF);

ReportID := REPORT::“Customer - List”;

FileDirectory := ‘C:’;

Window.OPEN(‘processing Cusomer ######################1##’);

Object.GET(Object.Type::Report,’’,ReportID);

IF Customer.FINDSET THEN REPEAT

Window.UPDATE(1,Customer.“No.”);

FileName := Customer.“No.” + ‘.pdf’;

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);

Customer2 := Customer;

Customer2.SETRECFILTER;

REPORT.RUNMODAL(ReportID,FALSE,FALSE,Customer2);

TimeOut := 0;

WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN

SLEEP(1000);

TimeOut := TimeOut + 1;

END;

UNTIL Customer.NEXT = 0;

Window.CLOSE;

END;

BEGIN

{

Author: Ahmed Amini

Email: ara3n(NOSPAM)@hotmail.com

}

END.

}

}