Store report as .htm file

nrinishnrinish Member Posts: 8
Hi All,

Please help me with an issue...My cust wants the sales invoice report to be saved in the computer once the report is generated for an invoice...i tried to do it but i have a problem now...i can generate and store the report as .htm file using the method SAVEASHTML()...but its taking long time and i am also getting an error while storing ....I am posting the code and the error message .... please tell me ware i went wrong..

Code:

Filename := 'C:\FileAttachment\' + "Sales Invoice Header"."No." + '.htm';
SalesInvoiceHeader.RESET;
SalesInvoiceHeader.SETFILTER(SalesInvoiceHeader."No.", "Sales Invoice Header"."No.");
IF SalesInvoiceHeader.FIND('-') THEN BEGIN
SalesInvoiceLine.RESET;
SalesInvoiceLine.SETFILTER(SalesInvoiceLine."Document No.",SalesInvoiceHeader."No.") ;
IF SalesInvoiceLine.FIND('-') THEN BEGIN
CLEAR(Rep);

Rep.SETTABLEVIEW(SalesInvoiceHeader);
Rep.SETTABLEVIEW(SalesInvoiceLine);
OK := Rep.SAVEASHTML(Filename);
END;
END;


ERROR:

There is insufficient memory to execute this function.This can be caused by recursive function calls that are used in the program. Contact your system administrator

Comments

  • kinekine Member Posts: 12,562
    You do not need to filter the lines, try to use it without this. Only filter the header and set the report view to the filtered header...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nrinishnrinish Member Posts: 8
    Hi kine,
    I tried removing the line filter and kept only the Header Filter... but still its the same :( ... I tried writing the code in the "onpostreport " but the thing is after adding the code the "onpostreport " is running for the entire header table record...hence it takes long time and i amgetting the error...

    The modified code is:

    IF Counter = 0 THEN BEGIN

    Filename := 'C:\FileAttachment\' + "Sales Invoice Header"."No." + '.htm';
    //SalesInvoiceHeader.RESET;
    SalesInvoiceHeader.SETFILTER(SalesInvoiceHeader."No.", "Sales Invoice Header"."No.");
    IF SalesInvoiceHeader.FIND('-') THEN BEGIN
    Counter += 1;
    CLEAR(Rep);
    Rep.SETTABLEVIEW(SalesInvoiceHeader);
    OK := Rep.SAVEASHTML(Filename);
    END;
    SalesInvoiceHeader.RESET;
    END;
  • kinekine Member Posts: 12,562
    Ah, you are calling this code from within the report? You are in endless loop than... 8)

    You cannot call the same report from within the report, without any condition which will end this endless loop... (endless recursion)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nrinishnrinish Member Posts: 8
    Hi kine,

    I tried copying the code into a codeunit and called the codeunit from the "onpostreport " of the sales invooice report...but its still its the same ](*,) ....please help me how i can fix it [-o< ....where should i call this codeunit...
    :?:
  • ara3nara3n Member Posts: 9,256
    The Codeunit by the user or scheduled task. It should be called from the report.
    It still is a infinite loop.

    You can add a function to your report called don't run the CU. The function will set a global CalledFromCU boolean to true.

    you can wrap your CU with If not CalledFromCU then begin
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.