web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Batch printing to file writes inomplete files (it stops at 1st page)

(0) ShareShare
ReportReport
Posted on by 1,087

Hi,

i'm using a class to print a (not standard) report for each customer on Ax 2009.

The class is executed on batch and with these lines of codes it writes the report on file (i commented the parameters to the report section, since it's not part of the issue):

        report = new ReportRun(new Args(ReportStr(MyCustReport)));
        report.printJobSettings().setTarget(PrintMedium::File);
        report.printJobSettings().format(PrintFormat::PDF);
        report.printJobSettings().fileName(fileName);

//parameters to the report
        report.run();

Everything works fine, but at a certain (i think random) point, it starts generating PDFs file with only one page, even when the report file should be two or three pages. So I've got files with missing data.

First files are ok, but after a bit it starts generating these incomplete reports....

What could be this caused by? Any suggestion?

Thank you in advance

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    Hi

    Are you following the standard way of sending SSRS report to pdf using Controller class? or this a custom class ?

    like this for e.g.: blogs.msdn.microsoft.com/.../how-to-sending-reports-to-file

    Please share where your file is kept? in a file share? or in a local drive?

  • Suggested answer
    Fredrik Sætre Profile Picture
    12,644 on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    I've noticed (in 2012 at least) that if you trigger a print job and it fails, then the execution of the code simply stops without any return errors. I suggest you go back and check your SSRS servers event log when the print occured and change your code to take in to account incomplete printouts.

    You could do a log for instance that retried the printout if it did not finished. Create a log entry on startup and update the status when done. Retrigger the report a set of times and leave the report open with an error message or send an email with incomplete reports.

  • vv1984 Profile Picture
    1,087 on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    Hi Manish, thanks for your answer. Yes, i'm using the standard approach. But i'm on Ax 2009, i'm not using SSRS reports in this case.

    The file is kept on a shared folder in a different machine, not terminal server nor AOS, I guess the printer driver which is generating the file is on the AOS machine.

  • vv1984 Profile Picture
    1,087 on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    Hi Fredrik, thank you for helping. Does this apply to Ax 2009 as well? I'm not using SSRS report at the moment, but the old version which was on Ax 2009. Do I have a way to check an event log for these reports too?

    How would you check if a report is incomplete? Sometimes this batch generates 1 page files which are ok, because the data fits in a single page..

  • Community Member Profile Picture
    on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    Sorry, My bad. Didn't notice it was AX2009

  • Community Member Profile Picture
    on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    Are you generating a new filename randomly each time ? or overwriting the existing file?

  • vv1984 Profile Picture
    1,087 on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    I'm writing a file for each customer, if the file already exists, i overwrite it. 

  • vv1984 Profile Picture
    1,087 on at
    RE: Batch printing to file writes inomplete files (it stops at 1st page)

    I've tried generating a log table of the pdf files the batch must generate.

    If the file is ok, i remove the record from this tablet.

    If not ok, i keep the file.

    The batch loops until the log table is empty.

    The whole batch printing should require no more than 2 hours to complete the 3800 files. But tonight it lasted a lot and this morning was still running, looping on the last 400 files over and over again. This can't be a definitive solution.

    Looks like there is some buffer somewhere which never gets flushed. And this causes next prints to end up incomplete.

    Is there a way to force print buffer flush?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans