Skip to main content

Advanced printing data sources

An advanced template does not hold data. When you print or preview, the program asks the company file for the data of one saved document and the template lays it out. The data comes from a ready SQL Server procedure, one for each document type. This page lists the types, says what each procedure returns, and explains when the Change Data Source button appears. To add a procedure of your own, see Create a custom data source.

How a template gets its data​

  • A template belongs to one document type. The type is fixed when the template is created.
  • A new template reads from the procedure named prcPrintAR_, then the type name, then _Default, such as prcPrintAR_Bill_Default. A saved template keeps the name of the procedure it reads from, so a template that was switched to another procedure stays on it.
  • The program calls the procedure with one value: the ID of the saved document being printed. The template therefore shows the document as it is saved. What you typed in the window and did not save is not in it.
  • The procedure returns several tables in one call. Its first table has one row. The first column is named Schema, and each following column carries the name of one of the other tables, in order. The designer uses these names to label the tables in the field list. A name such as ShippmentItems appears as words with capital letters.
  • The name of the source inside the report is CurrentDb.
  • Custom fields appear as extra columns. In a card table their names start with CF_. In a line table the custom fields of the material start with Material_. A document's own custom fields come in a table of their own, such as PaymentCF, PackingListCF or ShippingCF. In each name, spaces, /, ' and % become _.
  • Besides the tables, the program gives most templates a hidden parameter CurrencyId. What it holds depends on the window that prints. Windows that have a currency box pass the currency chosen in the window: bills (including orders and transfers), Journal Entry, receipt and payment vouchers, Commercial Papers, credit and debit notes, profit centers, assembly, and equipment maintenance orders. Point of Sale and restaurant orders pass the default currency of the program (for the restaurant, the first currency if no default is set), and so does the designer opened from their print settings, as do Point of Sale Pro, shipping, generate multiple credit notes, asset custody, direct labor, job orders and manufacturing. Packing lists get no CurrencyId, and neither does a transfer printed from the transfers print window. Vouchers also get FirstItemCurrencyId. See Data source and parameters.

The document types​

Each row shows the type as the program names it, the ready procedure, what the procedure reads, and the tables it returns. The table names are written as the procedure returns them. The field list shows them split into words, such as Bill Items for BillItems.

Document typeProcedureThe procedure readsTables returned
InvoiceprcPrintAR_Bill_DefaultOne saved invoice, of any invoice type.Customer, Addresses, Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, BillType, Bill, BillItems, Discounts, BillItemsExtended, LinkedPayments, RelatedBills, Checks, ApprovalProcedures, UsersDecisions, Approvals
OrderprcPrintAR_Order_DefaultOne saved order.Order, OrderItems, Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, BillType, Discounts, LinkedPayments, PayTerms, AccountsReceivable, OrderPost, OrderDividing, OrderBills, OrderPostMove, OrderPreparation, ApprovalProcedures, UsersDecisions, Approvals
VoucherprcPrintAR_Voucher_DefaultOne entry, or one receipt or payment voucher. It accepts the ID of either.VoucherHeader, VoucherType, Currency, Branch, MainAccount, CostCenter, VoucherItems, RelatedCheques, EndorseCheques, PaymentCF, RelatedPays
Assembly and DisassemblyprcPrintAR_Assembly_DefaultOne assembly or disassembly operation, with its input and output invoices.AssembleHeader, BillHeader, Currency, Branch, Customer, then In... tables for the input invoice and Out... tables for the output invoice (header, store, cost center, accounts, items, totals, serial numbers, discounts, checks, approvals)
Asset Custody Receipt and Handover NoteprcPrintAR_AssetPossessions_DefaultOne custody memo.Form, FormItems
NoteprcPrintAR_CDNote_DefaultOne credit or debit note.Notes, NoteTotals, NoteItems, Customers
Commercial PaperprcPrintAR_Cheque_DefaultOne commercial paper.ChequeHeader, Currency, Branch, Bank, ChequeAccount, PayReciveAccount, ChequeCost, PayReciveCost, EndorseAccount, Customer, ChequeHistory, ChequeOrigin, LastEventInfo
Generate Multiple Credit NotesprcPrintAR_CreditNoteGenerator_DefaultOne run of the multiple credit notes generator.Generator, GeneratorItems, TotalsOfGenerator
Direct Labor WagesprcPrintAR_DirectLaborAllocation_DefaultThe direct labor wages of one job order. The ID it receives is the job order's.Data, DirectLabors
Job OrderprcPrintAR_JobOrder_DefaultOne job order.Job Order, Manufacturing Overhead, Manufacturing Overhead Details, Manufacturing Overhead Total, Job Order Summary, Job Order Summary Total, Direct Materials Bills, Direct Materials Details, Direct Labour Allocations, Direct Labour Allocations Details, Finished Goods Bills
ManufacturingprcPrintAR_Manufacturing_DefaultOne manufacturing operation.Form, Ready Materials, Raw Materials, Individual Costs, Total Costs, Workers, Machinen, Manufacturing, ApprovalProcedures, UsersDecisions, Approvals
Packing ListprcPrintAR_PackingList_DefaultOne packing list.PackingListHeader, Currency, Branch, Container, PackingListBills, PackingListMaterials, PackingListTotals, PackingListCF
Point of SaleprcPrintAR_POS_DefaultOne point of sale order.Order, Order Items, Addresses, Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, Discounts, LinkedPayments, RelatedBills, Checks
RequestprcPrintAR_POSSDOrder_DefaultOne order of the smart device point of sale.Order, Items, Customer, Totals, OrderDetails, OrderEvents, AppliedSpecialOffer, SuppervisorsApprovals
TransactionprcPrintAR_POSSDTransaction_DefaultOne transaction of the smart device point of sale.Transaction, Items, Customer, Totals, PaymentMethods, SuppervisorsApprovals
Profit CenterprcPrintAR_ProfitCenter_DefaultOne shipment to a profit center.ShipmentHeader, Currency, CurrentAccount, SaleGoodsAccount, ProfitCenter, ShipmentStore, CenterStore, GORStore, ShipmentItems, ShipmentTotals
RestaurantprcPrintAR_Restaurants_DefaultOne restaurant order.Order, Order Items, Addresses, Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, Discounts, LinkedPayments, RelatedBills, Checks, Restaurants
ShippingprcPrintAR_Shipping_DefaultOne shipping between warehouses.Users, Shippments, Receivments, ShippmentItems, ReceivmentItems, Transporters, ShippmentMaterial, ReceivmentMaterial, ShippingCF
TransferprcPrintAR_Transposition_DefaultOne transfer bill, with its output and input stores.Transpostion, TranspostionItem, Currency, InStore, OutStore, Branch, User, Distributor, SalesMan, InCostCenter, OutCostCenter, BillType, Discounts, InAccount, OutAccount, InMaterialAccount, OutMaterialAccount
Equipment Maintenance RequestprcPrintAR_MaintenanceOrder_DefaultOne maintenance request.Order, OrderTotals, SpareParts, Wages, VisibleMalfunctions, MaintenanceMalfunctions, CancelOrderReasons, Accessories

The table names are written as the procedures return them, including the spellings Machinen, Transpostion, Shippments and SuppervisorsApprovals. To bind a control, drag the field from the field list or pick it in the expression editor instead of typing the table name.

What the fields mean​

The fields are named in English, and the names follow a few habits:

Part of the dataHow to read it
Tables of cards, such as Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, BillType and CustomerOne row with the columns of the card of the document. Use them for the name, code and other details of the card used in the document. For invoices, take the branch from BranchCode and BranchName of the Bill table. The Branch table of the invoice procedure is normally empty.
BillThe invoice header. It holds, among others, Number, Date, CustomerName, Notes, Total, TotalDiscounts, TotalExtra, ItemsDiscounts, VAT, IsPosted, BranchCode and BranchName. GrandTotal is Total plus TotalExtra minus TotalDiscounts.
BillItemsOne row for each invoice line: Number, Price, Quantity, Discount, Extra, VAT, BonusQuantity, and the material card of the line in columns that start with Material_, such as Material_Name, Material_Code and Material_Barcode. A column whose name ends with GUID is the internal ID of a card or line, not text to print.
VoucherHeaderThe fields start with Voucher, for example VoucherNumber, VoucherDate, VoucherNote, VoucherDebitSUM, VoucherCreditSUM, and VoucherMainAccPrevBalance, the balance of the main account before the voucher date. The fields of the receipt or payment voucher start with Pay.
Tables ending in Items, or DetailsOne row for each line of the document.
Tables ending in TotalsOne row with the totals of the document.
Tables with the names ApprovalProcedures, UsersDecisions and ApprovalsThe approval path of the document and the decision of each user.
Columns that start with CF_ or Material_Custom fields, as described above.

The same naming is used in the other procedures: the main table of a document holds its header, a table with Items holds its lines, and a table with Totals holds its totals. Check a column in the field list before you use it, because each procedure has its own columns.

Change Data Source​

The designer has a Change Data Source button in the Data group of the ribbon. It lists the procedures the template can read from, and choosing one replaces the data source of the open template. The list shows the procedure names.

  • When it appears. The program looks in the company file for the procedures whose name starts with prcPrintAR_ followed by the type name of the template. The button appears only if it finds more than one. With a single procedure, which is the usual case, the button does not appear.
  • What it lists. Every procedure found, sorted by name. The match is on the start of the name, without the underscore after the type name. For the Point of Sale type, the list therefore also holds prcPrintAR_POSSDOrder_Default and prcPrintAR_POSSDTransaction_Default, so the button always appears for this type.
  • What choosing does. The program builds a new data source for the chosen procedure, removes the old one and sets the report to read from the new one. Controls bound to fields that the new procedure does not return need to be bound again.
  • Your own procedures. A procedure you create with a correct name appears in the list on the next opening of the designer. See Create a custom data source.

This page applies to alameen ERP 10, version 10.1.79.764.