Hardcode No. of copies for Report

Hi david:

Here is the Code;

Code:



OBJECT Report 50000 Cust. Reciept
{
OBJECT-PROPERTIES
{
Date=29/08/07;
Time=11:08:02;
Modified=Yes;
Version List=;
}
PROPERTIES
{
UseReqForm=Yes;
UseSystemPrinter=Yes;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table21;
DataItemTableView=SORTING(Entry No.);
NewPagePerRecord=Yes;
OnAfterGetRecord=BEGIN
IF “Cust. Ledger Entry”.“Amount (LCY)” < 0 THEN
"Cust. Ledger Entry".“Amount (LCY)”:=“Cust. Ledger Entry”.“Amount (LCY)” * -1;

IF Customer.GET(“Cust. Ledger Entry”.“Customer No.”) THEN
CustName := Customer.Name
ELSE
CustName := ‘’;
IF Cashier.GET(“Cust. Ledger Entry”.“User ID”) THEN
CashName := Cashier.Name
ELSE
CashName := ‘’;
END;

ReqFilterFields=Document No.;
}
SECTIONS
{
{ PROPERTIES
{
SectionType=Header;
PrintOnEveryPage=Yes;
SectionWidth=18150;
SectionHeight=2538;
OnPreSection=BEGIN
COMPINFO.GET;
COMPINFO.CALCFIELDS(Picture);
END;

}
CONTROLS
{
{ 1000000002;TextBox;15000;0 ;3150 ;423 ;HorzAlign=Right;
SourceExpr=FORMAT(TODAY,0,4) }
{ 1000000004;TextBox;17700;423 ;450 ;423 ;CaptionML=ENU=Page;
SourceExpr=CurrReport.PAGENO }
{ 1000000005;Label ;16950;423 ;750 ;423 ;ParentControl=1000000004 }
{ 1000000006;TextBox;15900;846 ;2250 ;423 ;HorzAlign=Right;
SourceExpr=USERID }
{ 1000000022;Label ;0 ;1692 ;3150 ;423 ;FontSize=9;
FontBold=Yes;
FontUnderline=Yes;
CaptionML=ENU=Official Receipt }
{ 1000000034;Label ;0 ;0 ;5400 ;1692 ;Border=No;
BorderStyle=Normal;
FontSize=12;
FontBold=Yes;
MultiLine=Yes;
CaptionML=ENU="SOCIAL SECURITY AND HOUSING FINANCE CORPORATION " }
}
}
{ PROPERTIES
{
SectionType=Body;
SectionWidth=18150;
SectionHeight=8037;
}
CONTROLS
{
{ 1000000008;TextBox;3150 ;0 ;4650 ;423 ;HorzAlign=Left;
SourceExpr=“Document No.” }
{ 1000000009;Label ;0 ;0 ;3000 ;423 ;ParentControl=1000000008;
CaptionML=ENU=Receipt No. }
{ 1000000011;TextBox;3150 ;423 ;2700 ;423 ;HorzAlign=Left;
SourceExpr=“Posting Date” }
{ 1000000012;Label ;0 ;423 ;3000 ;423 ;ParentControl=1000000011;
CaptionML=ENU=Date }
{ 1000000014;TextBox;3150 ;846 ;3450 ;423 ;HorzAlign=Left;
SourceExpr=“Customer No.” }
{ 1000000015;Label ;0 ;846 ;3000 ;423 ;ParentControl=1000000014 }
{ 1000000017;TextBox;3150 ;2115 ;3750 ;423 ;HorzAlign=Left;
SourceExpr=[“Amount (LCY)” ] }
{ 1000000018;Label ;0 ;2115 ;3000 ;423 ;ParentControl=1000000017;
CaptionML=ENU=Amount (GMD) }
{ 1000000023;TextBox;3150 ;2538 ;4950 ;423 ;HorzAlign=Left;
SourceExpr=Description }
{ 1000000024;Label ;0 ;2538 ;3000 ;423 ;ParentControl=1000000023;
CaptionML=ENU=Desc }
{ 1000000026;TextBox;3150 ;2961 ;4950 ;423 ;HorzAlign=Left;
SourceExpr=“Dimension Name” }
{ 1000000027;Label ;0 ;2961 ;3000 ;423 ;ParentControl=1000000026;
CaptionML=ENU=FUND }
{ 1000000000;TextBox;3150 ;1269 ;4650 ;423 ;HorzAlign=Left;
SourceExpr=CustName }
{ 1000000007;Label ;0 ;1269 ;3000 ;423 ;ParentControl=1000000000;
CaptionML=ENU=Customer Name }
{ 1000000010;TextBox;3150 ;3807 ;2700 ;423 ;HorzAlign=Left;
SourceExpr=“Start Period Name” }
{ 1000000013;Label ;0 ;3807 ;3000 ;423 ;ParentControl=1000000010;
CaptionML=ENU="Start Period " }
{ 1000000019;Label ;0 ;5499 ;4650 ;423 ;HorzAlign=Left;
CaptionML=ENU=___________________________________ }
{ 1000000025;Label ;0 ;5922 ;4650 ;423 ;HorzAlign=Left;
CaptionML=ENU=Cashier’s Stamp & Signature: }
{ 1000000016;TextBox;3150 ;4230 ;2700 ;423 ;HorzAlign=Left;
SourceExpr=“End Period Name” }
{ 1000000020;Label ;0 ;4230 ;3000 ;423 ;ParentControl=1000000016;
VertAlign=Center;
FontBold=Yes;
MultiLine=Yes;
CaptionML=ENU=End Period }
{ 1000000001;TextBox;3150 ;3384 ;4950 ;423 ;HorzAlign=Left;
SourceExpr=“Global Dimension 2 Code” }
{ 1000000003;Label ;0 ;3384 ;3000 ;423 ;ParentControl=1000000001;
VertAlign=Center;
FontBold=Yes;
MultiLine=Yes }
{ 1000000029;Label ;0 ;7191 ;7050 ;423 ;VertGlue=Top;
HorzAlign=Left;
VertAlign=Center;
CaptionML=ENU=______________________________________________________________________________ }
{ 1000000030;TextBox;1500 ;6768 ;3450 ;423 ;HorzGlue=Left;
VertGlue=Top;
HorzAlign=Left;
SourceExpr=CashName }
{ 1000000031;Label ;0 ;6768 ;1500 ;423 ;HorzGlue=Left;
VertGlue=Top;
ParentControl=1000000030;
HorzAlign=Left;
VertAlign=Center;
FontSize=9;
FontBold=Yes;
MultiLine=Yes;
CaptionML=ENU=Cashier : }
{ 1000000032;TextBox;3150 ;1692 ;4650 ;423 ;HorzAlign=Left;
SourceExpr=“External Document No.” }
{ 1000000033;Label ;0 ;1692 ;3000 ;423 ;ParentControl=1000000032;
HorzAlign=Left;
VertAlign=Center;
FontBold=Yes;
MultiLine=Yes;
CaptionML=ENU=Cheque No. }
}
}
}
}
{ PROPERTIES
{
DataItemIndent=1;
DataItemTable=Table2000000026;
DataItemTableView=SORTING(Number);
NewPagePerGroup=No;
NewPagePerRecord=Yes;
DataItemVarName=CopyLoop;
OnPreDataItem=BEGIN
NoOfLoops := ABS(NoOfCopies) + Cust.“Invoice Copies” + 1;
&nbs

Hi experts,

I created a report to print receipt of customer. This report is created using the Cust. Ledger Entry table. right now i have to use request form to specify the no. of copies.

The cashier enter customers payment details and the click on POSTING------> POST and PRINT and the receipt will be printed and and one copy comes out.

Now i created a request form where the no. of copies can be specify to print that no. This seems a bit tidious.

I want to either hardcode or any method to two copies, so that whenever the cashier post and print payments, the printer will print two copies straight.

i hope its understood.

Thanks

Hi Momodou,

the problem is this code:

OnPreDataItem=BEGIN
NoOfLoops := ABS(NoOfCopies) + Cust.“Invoice Copies” + 1;
IF NoOfLoops <= 0 THEN
NoOfLoops := 1;
CopyText := ‘’;
SETRANGE(Number,1,NoOfLoops);
END;

You are looking at the Field in the request form and the Customer card. I would add a new field “Print No Of Payments” to the customer table, and change thecode to:

OnPreDataItem=BEGIN
NoOfLoops := “Print No Of Payments”;
IF NoOfLoops <= 0 THEN
NoOfLoops := 1;
CopyText := ‘’;
SETRANGE(Number,1,NoOfLoops);
END;

That should do it.

Then just set the field “Print No Of Payments” to 2 on the customer cards.

There are many other ways, but this is one idea

The report is now printing two copies correctly. Now there are three cashiers, two needs the two copies but the other needs only one not two.

How can the code be modify to let the two have their two copies and the third one have one copy?

Any idea please.

Thanks

OK, I was following the code you already did.

Then add the field to the User Setup table. Then add

OnPreDataItem=BEGIN

IF not UserSetup.get(USERID) then

UserSetup.“Print No Of Payments” := 2;
IF UserSetup.“Print No Of Payments” <= 0 THEN
UserSetup.“Print No Of Payments” := 1;
CopyText := ‘’;
SETRANGE(Number,1,UserSetup.“Print No Of Payments”);
END;

BTW the above code is not perfect, butI am more trying to give you the idea of what to do with out trying to add confusion.

I was simply thinking goto “Add Printer” create a second copy of the printer (call it whatever “Receipt Printer 2 Copies”).

Then set it’s default settings to copies=2.

Then just assign that printer to the report. Done!

But then you threw in the user thing [:’(]

I did not make use of the Print no of payments field which i added to the customer table and also to the customer card. I ended up just setting NoOfLoops := 2 and the report print two copies.

I have added Print No Of Payments field to the setup table and assigned the respective no of copies to them. I have added the code in the OnPreDataItem of the copyloop, but when i try to compile it tells me to define ‘Print No Of Payments’ which i already did before.

Any idea please?

Thanks.

  1. Was the field added to the user setup table, while You were in design-mode on Your report?
    If it was, then You should save the changes, without compiling, then go to design-mode again, and this time you should be able to compile the report.

  2. Maybe You misspelled the field-name.
    Have You inserted the code through the C/AL symbol Menu, or have You written the code Yourself?

  3. Are You addressing the field as USERSETUP.“Print No Of Payments”, or just as “Print No Of Payments”?
    If the last thing is correct, then it looks for the field in the Integer-table, and not in the User Setup-table.

I have use the above code and when i test it with user Ids

mm is having Print No Of Payments=2

hh is having Print No Of Payments=1

in the User set table

when i test using mm as user Id and run the report it gives me 2 copies

but when i use hh as user id it still gives me 2 copies when i am expecting 1.

Any ideas please.

Thanks

Try running with Debugger on to see why it is not getting the correct value.

I have run the debugger to check but i have not seen anything.

Thanks

You probably have to insert a “toggle breakpoint”-mark in the object first.

If You haven’t done that, nor checked the “Breakpoint on triggers”, then I will expect the report to just print normally.
The debugger will only pop up if a runtime-error occours, if You only check “Debugger active”.

I think that David was refering to a “manual” run-through of the code and variables as the report prints.

Exactly [;)]