Report processing OR No output

maheshmahesh Member Posts: 115
Hi guys,

I found problem when i was trying to send report via email automatically.
Before sending email, i need to check whether report has Output or still it is under process. Currentrly i have set wait time of 10 sec. But if there is not any file generated in assigned folder after 10 sec then there are two chances 1) Report dont have any ouput. 2) Report is still under process.

There is not any inbuilt function stating this problem. I want to generate exact error message by coding. plz help.

Regards
mahESH
Best Regards,
Mahesh Jain
mahesh@reliconservices.com

Comments

  • kinekine Member Posts: 12,562
    There is a way... I saw some code in tool for creating files for on-line help in NAV, which was detecting, if the report is "Report" or "Batch" (processing only) - it is a part of the report "Generate HTML Help" which is on the MBS Tools CD. There is the code:
    IsABatchJob(Obj : Record Object) : Boolean
    IF Obj.Type <> Obj.Type::Report THEN EXIT(FALSE);
    Obj.CALCFIELDS("BLOB Reference");
    Obj."BLOB Reference".CREATEINSTREAM(ObjStream);
    WHILE NOT ObjStream.EOS DO BEGIN
      Counter := ObjStream.READ(BinData);
      FOR Counter := 1 TO 1998 DO BEGIN
        intChar[1] := BinData[Counter];
        intChar[2] := BinData[Counter+1];
        intChar[3] := BinData[Counter+2];
        IF (intChar[1] = 37) AND (intChar[2] = 72) AND (intChar[3] = 4) THEN
          IF BinData[Counter+4] = 1 THEN
            EXIT(TRUE);
      END;
      EXIT(FALSE);
    END;
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • maheshmahesh Member Posts: 115
    thanx for appreciated reply...

    but if a report is not processing only & which takes too much time to execute then i just want to know by coding dat still report is executing or it has no output?
    Best Regards,
    Mahesh Jain
    mahesh@reliconservices.com
  • kinekine Member Posts: 12,562
    If you are running the process on one client/NAS, your checking code will not run until the report is processing data. Do not forget that NAV is "single-threaded" application.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • maheshmahesh Member Posts: 115
    Hi,
    the problem I am facing is that I am mailing the report in pdf format to customers, but sometimes, before the pdf is fully generated, it gets transferred to e-mail, so the file size is less and it is corrupted, but when you check the file it is fully generated.

    So we need some solution which will halt mail till the file is fully generated. So is sleep only solution? If it is then it is not totally accurate and also time consuming.
    Best Regards,
    Mahesh Jain
    mahesh@reliconservices.com
  • kinekine Member Posts: 12,562
    1) One way is to try to open the file for writing. if you succeeded, the file was closed and is fully generated. During process of generation is the file locked for writing for another process. If you fail, try it in e.g. 500ms...

    2) Another way is depending on used PDF printer. Some has API you can use to check, if the file was generated...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.