Print report X times

sarkie83sarkie83 Member Posts: 22
edited 2007-08-02 in Navision Financials
I am trying to write a report which basilically takes the posted shipment note, and uses the info to print off some box labels. This part is fine, but there is a field which says X no. of packages, and I need to use this to make the report print itself X times.
Up till now i've only created relitively simply reports - so is this possible, and where is a good starting point?
Thanks,

Answers

  • David_CoxDavid_Cox Member Posts: 509
    Look at the structure of the existing Sales or Purchase documents, you have a data item called CopyLoop, this sets the number of copies

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • sarkie83sarkie83 Member Posts: 22
    Thanks for that! I managed to get the reporting running as I wanted by using the copy loop in one of the other reports.

    This report is going to be called from the posted sales shipments form - which is fine - I can get it to run my new object ok.

    However, I want it to pass through the SS.No. as the filter value for the report. At present you have to manually enter the number.

    There are other reports that pull this info through, but looking at them I can't see how they are grabbing the ss.No.

    What am I missing?
  • SavatageSavatage Member Posts: 7,142
    Not sure but when I run Code Coverage on the print button (which fills in the ss#)

    Look at the sales shipment header - a local funct called Printrecords
    PrintRecords(ShowRequestForm)
      WITH SalesShptHeader DO BEGIN
        COPY(Rec);
        ReportSelection.SETRANGE(Usage,ReportSelection.Usage::"S.Shipment");
        ReportSelection.SETFILTER("Report ID",'<>0');
        ReportSelection.FIND('-');
        REPEAT
          REPORT.RUNMODAL(ReportSelection."Report ID",ShowRequestForm,FALSE,SalesShptHeader);
        UNTIL ReportSelection.NEXT = 0;
      END;
    

    The code on the print button is
    OnPush()
    CurrForm.SETSELECTIONFILTER(SalesShptHeader);
    SalesShptHeader.PrintRecords(TRUE);
    

    perhaps a place to start
  • jlandeenjlandeen Member Posts: 524
    I would say that you've almost got it sorted out. You can just apply the filter to the Record set that is being passed through to the report.run function as if you were going to apply filters on the options screen if you run it manually.
    PrintRecords(ShowRequestForm) 
      WITH SalesShptHeader DO BEGIN 
        COPY(Rec); 
        ReportSelection.SETRANGE(Usage,ReportSelection.Usage::"S.Shipment"); 
        ReportSelection.SETFILTER("Report ID",'<>0'); 
        ReportSelection.FIND('-'); 
        REPEAT 
          SalesShptHeader.Setrange(<FIELDA>,<VALUE1>);
          REPORT.RUNMODAL(ReportSelection."Report ID",ShowRequestForm,FALSE,SalesShptHeader); 
        UNTIL ReportSelection.NEXT = 0; 
      END;
    
    (of course you want to set Field A to a real field name and Value 1 to some value or use the setfilter command).

    Another option if there are more complex options or values required is to build a function that handles any of that filtering logic in the report itself and just call the report using a local variable.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • sarkie83sarkie83 Member Posts: 22
    Cheer guys, it's working exactly how I wanted now! Part of the problem is just knowing where to start.. I added this to the OnPush():
    SalesShptHeader.SETRANGE(SalesShptHeader."No.","No.");
    REPORT.RUNMODAL(REPORT::"Shipment Label",TRUE,FALSE,SalesShptHeader);
    

    Although I didn't realise at first you could get at the OnPush() of a menu item, as it was running from a button at first.

    Cheers.
Sign In or Register to comment.