Report Printed twice or even not printed.

AndwianAndwian Member Posts: 627
Dear Experts,

I have implementing a customized report that export it to Excel and then print it from there in the background.

I use that report in the very massively transactions, about 12 times print action per minute.

Sometime, the printed report is not printed, and sometime it even printed twice per Document No.

Do you ever experienced in this before?
Please share.

I do not know whether the problem is in the Excel print command, or the physical line (cable/connection) from the Client to the printer. The Client is using Remote Desktop Connection to the server.

Thank you.
Regards,
Andwian

Comments

  • ara3nara3n Member Posts: 9,256
    Could you specify a little more info on what you are doing and some code on what you are accomplishing.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • AndwianAndwian Member Posts: 627
    What actually I am doing is Create & Print Whse. Pick (Standard Report 7318), but the Report to print Whse. Pick is modified so that it will be exported to Excel and then print them from there.

    Below is the code in the modified Picking List Report (Report ID 5752). I just show the part of Export to Excel, and then Print from Excel.
    OBJECT Report 5752 Picking List
    {
      OBJECT-PROPERTIES
      {
        Date=10/07/10;
        Time=10:31:36 AM;
        Modified=Yes;
        Version List=
      }
      PROPERTIES
      {
        Permissions=TableData 50000=r;
        CaptionML=ENU=Picking List;
        UseReqForm=No;
        ProcessingOnly=Yes; // --> Processing Only since I want to print from Excel
        OnPreReport=BEGIN
                      PickFilter := "Warehouse Activity Header".GETFILTERS;
    
                      //Win.OPEN('#1###################################');
                      //Win.UPDATE(1,'Generating excel ...............');
    
                      IF NOT ISCLEAR(ExcelApp) THEN
                        IF ExcelApp.Workbooks.Count <= 0 THEN
                          ExcelApp.Quit;
    
                      IF recExcelLocation.GET THEN BEGIN
                        recExcelLocation.TESTFIELD(recExcelLocation."Picking List Template");
                        FormPath := recExcelLocation."Picking List. Template";
                      END;
                      CLEAR(ExcelApp);
                      CLEAR(xlWorkbook);
                      CLEAR(xlWorksheet);
                      CLEAR(xlSheets);
    
                      CREATE(ExcelApp);
                      xlWorkbooks := ExcelApp.Workbooks;
                      xlWorkbook := xlWorkbooks.Open(FormPath);
    
                      PageNo := 1;
                      RowNo := 18;
                      xlSheets := ExcelApp.ActiveWorkbook.Sheets;
                      xlWorksheet := xlSheets.Item(PageNo);
                    END;
    
        OnPostReport=BEGIN
                       //XlsFooter;
    
                       xlWorkbook := ExcelApp.ActiveWorkbook;
    
                       //Win.CLOSE;
    
                       {
                       SavePath := ComDialogMgt.OpenFile('','',2,'',1);
                       IF SavePath <> '' THEN
                         xlWorkbook.SaveAs(SavePath);
    
                       xlWorkbook.Close(FALSE);
                       }
    
                       //xlWorkbook.PrintOut(1,ExcelApp.ActiveWorkbook.Sheets.Count,1,FALSE,txtPrinterName,FALSE,FALSE);
                       xlWorkbook.PrintOut(1,10,1,FALSE,txtPrinterName,FALSE,FALSE);
                       xlWorkbook.Close(FALSE);
    
                       WhseCountPrinted.RUN("Warehouse Activity Header"); //Picking List Add
                     END;
    
        PROCEDURE XlsHeader@1000000001();
        BEGIN
    
          xlWorksheet.Range('AH3').Value  := FORMAT("Warehouse Activity Header"."No.");
          xlWorksheet.Range('AH5').Value  := FORMAT("Warehouse Activity Header"."Assignment Date");
    
          xlWorksheet.Range('AI11').Value := FORMAT(WORKDATE);
          xlWorksheet.Range('AI13').Value := FORMAT(TIME); 
    
          recWhseActLine.RESET;
          recWhseActLine.SETRANGE("Activity Type","Warehouse Activity Header".Type);
          recWhseActLine.SETRANGE("No.","Warehouse Activity Header"."No.");
          recWhseActLine.SETFILTER("Source No.",'<> %1','');
          recWhseActLine.SETFILTER("Whse. Document No.",'<> %1','');
          IF recWhseActLine.FINDFIRST THEN BEGIN
            xlWorksheet.Range('G11').Value  := recWhseActLine."Source No.";
            xlWorksheet.Range('G13').Value  := recWhseActLine."Whse. Document No.";
            xlWorksheet.Range('AB9').Value  := 'USER ID';
            xlWorksheet.Range('AI9').Value  := USERID;
            recSalesHeader.RESET;
            IF recSalesHeader.GET(recSalesHeader."Document Type"::Order,recWhseActLine."Source No.") THEN BEGIN
              xlWorksheet.Range('G9').Value   := recSalesHeader."Sell-to Customer Name";
            END;
          END;
        END;
    
        PROCEDURE XlsLine@1000000002(VAR RowNo@1000000000 : Integer);
        BEGIN
          IF RowNo >= 50 THEN BEGIN
            XlsCreateNewSheet;
            RowNo := 18;
          END;
    
    
          xlWorksheet.Range('A' + FORMAT(RowNo)).Value  := txtItemNo+' '+txtvarian;
          xlWorksheet.Range('I' + FORMAT(RowNo)).Value  := txtItemDesc;
          xlWorksheet.Range('V' + FORMAT(RowNo)).Value  := txtBinCode;
    
    
    
          xlWorksheet.Range('AD' + FORMAT(RowNo)).Value := txtUM;
    
    
          xlWorksheet.Range('AK' + FORMAT(RowNo)).Value := txtQtyHandled;
    
    
    
          RowNo := RowNo + 2;
        END;
    
        PROCEDURE XlsFooter@1000000003();
        BEGIN
          TotalPageNo := PageNo;
    
          FOR PageNo := PageNo DOWNTO 1 DO BEGIN
           xlWorksheet := xlSheets.Item(PageNo);
           xlWorksheet.Name('Page ' + FORMAT(PageNo) + ' of ' + FORMAT(TotalPageNo));
           xlWorksheet.Range('A54').Value := FORMAT(PageNo) + ' of ' + FORMAT(TotalPageNo);
          END;
        END;
    
        PROCEDURE XlsCreateNewSheet@1000000004();
        BEGIN
          PageNo := PageNo + 1;
    
          xlWorksheet.Copy(xlSheets.Item(PageNo-1));
          xlWorksheet := xlSheets.Item(PageNo-1);
          xlWorksheet := xlSheets.Item(PageNo);
          xlWorksheet.Range('A18', 'AK48').Value := '';
        END;
    
    Regards,
    Andwian
  • ara3nara3n Member Posts: 9,256
    The create(Automation has a couple of parameters, try to create new instance every time.

    Also another suggestion is to store what you are writting in temporary table and then at the end call/ create the automations once and print what you need.


    I still don't understand why you need to export it to excel and then print it, if you can just print it using NAV report.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • AndwianAndwian Member Posts: 627
    ara3n wrote:
    The create(Automation has a couple of parameters, try to create new instance every time.

    Also another suggestion is to store what you are writting in temporary table and then at the end call/ create the automations once and print what you need.
    My apologies, I still do not understand what you mean. Would you mind if explain it in more detail?
    ara3n wrote:
    I still don't understand why you need to export it to excel and then print it, if you can just print it using NAV report.
    Actually, the reason is because the report is printed on pre-printed paper, that is, the paper is not blank, but it is having a company logo and the table box for the Pick Line. :) This way, the document could be more neat than using the NAV report, as you know that the Header and Footer, additionally, the Table box could not be printed fixedly when using standard NAV report. I hope you could understand the background. Maybe, if you have any other ideas to print this kind of document, that would be very nice, I think :D

    Thank you for the suggestion.
    Regards,
    Andwian
  • vaprogvaprog Member Posts: 1,139
    Andwian wrote:
    Actually, the reason is because the report is printed on pre-printed paper, ... This way, the document could be more neat than using the NAV report, as you know that the Header and Footer, additionally, the Table box could not be printed fixedly when using standard NAV report. I hope you could understand the background. Maybe, if you have any other ideas to print this kind of document, that would be very nice, I think
    Printing to pre-printed paper should be no issue wit NAV, also printing header and footer works fine as long as you don't mix some properties (Only "Page m of n" type page numbers are difficult to do).
    Printing lines into the pre-printed table box is no issue either. What difficulues could you not solve?
Sign In or Register to comment.