Number of Pages in a Report

Hey All, According to One of my client request, I want to generate Report and this Report should contain Number of Pages which i SetRange on the Click of the button. To be more Precise. If i write a code like this on the click of the Button : SETRANGE(“Document No”,‘D01’,‘D10’); Then it should generate 10 Documents(Pages) containing the information of the Documents(Sales Order in my case)that actually i want to Print. I know that i can write this code in a report also rather then writting on the trigger of the Button. But some how not getting.

I’m not quite sure if I fully understand your requirements, but maybe this will help: You can set the filter on the record variable in the button’s trigger and then pass this record to REPORT.RUN/RUNMODAL (see the C/AL reference). The filters attached to the record will then be used for the data item in the report which refers to the same table as the variable.

If you print one page pr. record, use Rec.COUNT (=no of records within the range)…

Allright Let me tell you in C/AL Language [8D]…If i write this Code Cust.SETRANGE(Cust.“No.”,‘10000’,‘60000’); IF Cust.FIND(’-’) THEN REPEAT REPORT.RUNMODAL(50001,FALSE,FALSE,Cust) UNTIL Cust.NEXT = 0; It actually prints 6 Pages. That means it calls Report 6 Times and Print All the records. [B)] As far as calling is concerned it is fine. But what i want is …when it prints first time it should display only First Customers Record. Same way six pages with six different customers Records.

quote:


Cust.SETRANGE(Cust.“No.”,‘10000’,‘60000’); IF Cust.FIND(’-’) THEN REPEAT REPORT.RUNMODAL(50001,FALSE,FALSE,Cust) UNTIL Cust.NEXT = 0;


What about (form the Online Help [;)]): SETRECFILTER (Record) Use this function to set the values in the primary key fields of the current record as a record filter. Record.SETRECFILTER Example You can use this function to set a delimitation on a table before running a report. Put C/AL code similar to the one shown below in the OnPush trigger of a command button or menu item on a form. When the code is triggered, the primary key fields of the current record of the form will be used as a delimitation when the report is run. Customer.SETRECFILTER; REPORT.RUN(REPORT::“An Example Report”,FALSE,FALSE,Customer); Would look like: Cust2 := Cust; Cust2.SETRECFILTER; REPORT.RUNMODAL(50001,FALSE,FALSE,Cust2);

quote:


Originally posted by Michael_patrick_11
Cust.SETRANGE(Cust.“No.”,‘10000’,‘60000’); IF Cust.FIND(’-’) THEN REPEAT REPORT.RUNMODAL(50001,FALSE,FALSE,Cust) UNTIL Cust.NEXT = 0; It actually prints 6 Pages. That means it calls Report 6 Times and Print All the records. [B)]


What do you mean by “All the records”? All records in the customer table or all the 6 records you have filtered? I would expect the latter… You are calling the report 6 times, each time with a record variable which is filtered down to 6 entries, so this will amount to 6x6 customers being printed. Try Cust.SETRANGE(Cust."No.",'10000','60000'); REPORT.RUNMODAL(50001,FALSE,FALSE,Cust); i.e. without the loop.

Hey Joerg, Can you show me with an example. Sorry but i didnt get you. I am aware about the SETRECFILTER… I dont bother about the the Current record. I just want when i put filter on the table.Like this… Cust.SETRANGE(“No.”,‘10000’,‘60000’); It should print records of the Customer 10000 First then Customer 20000 " " " Customer 60000 In six different pages. NOTE : I have written this on the “Trigger” of the Button Thanks in advance

quote:


Originally posted by Michael_patrick_11
Allright Let me tell you in C/AL Language [8D]…If i write this Code Cust.SETRANGE(Cust.“No.”,‘10000’,‘60000’); IF Cust.FIND(’-’) THEN REPEAT REPORT.RUNMODAL(50001,FALSE,FALSE,Cust) UNTIL Cust.NEXT = 0; It actually prints 6 Pages. That means it calls Report 6 Times and Print All the records. [B)] As far as calling is concerned it is fine. But what i want is …when it prints first time it should display only First Customers Record. Same way six pages with six different customers Records.


Hi Michael If understood you properly, you want only(n all) the records that fall in the range to be printed and that too each record on a single page… i havent tried but you can test it out Cust.SETRANGE(Cust.“No.”,‘10000’,‘60000’); IF Cust.FIND(’-’) THEN REPEAT if Cust1.get(cust.“no.”) then; REPORT.RUNMODAL(50001,FALSE,FALSE,Cust1) UNTIL Cust.NEXT = 0; i have just added another variable of customer say cust1 to your actual code and also am passing the Cust1 to the report. hope this helps cheers

Michael what I thought was: Cust.SETRANGE(Cust."No.",'10000','60000'); IF Cust.FIND('-') THEN REPEAT Cust2 := Cust; **Cust2**.SETRECFILTER; REPORT.RUNMODAL(50001,FALSE,FALSE,**Cust2**); UNTIL Cust.NEXT = 0;

Michael, I think you just need my solution above (a SETRANGE followed by a RUNMODAL), and in addition set NewPagePerRecord to TRUE in the report’s data item.

Hey Joerg…it works.[^] Mk i think you are missing SETRECFILTER in your code. Any way Thanks Every one.