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 asprcPrintAR_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 asShippmentItemsappears 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 withMaterial_. A document's own custom fields come in a table of their own, such asPaymentCF,PackingListCForShippingCF. 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 noCurrencyId, and neither does a transfer printed from the transfers print window. Vouchers also getFirstItemCurrencyId. 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 type | Procedure | The procedure reads | Tables returned |
|---|---|---|---|
| Invoice | prcPrintAR_Bill_Default | One 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 |
| Order | prcPrintAR_Order_Default | One saved order. | Order, OrderItems, Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, BillType, Discounts, LinkedPayments, PayTerms, AccountsReceivable, OrderPost, OrderDividing, OrderBills, OrderPostMove, OrderPreparation, ApprovalProcedures, UsersDecisions, Approvals |
| Voucher | prcPrintAR_Voucher_Default | One 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 Disassembly | prcPrintAR_Assembly_Default | One 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 Note | prcPrintAR_AssetPossessions_Default | One custody memo. | Form, FormItems |
| Note | prcPrintAR_CDNote_Default | One credit or debit note. | Notes, NoteTotals, NoteItems, Customers |
| Commercial Paper | prcPrintAR_Cheque_Default | One commercial paper. | ChequeHeader, Currency, Branch, Bank, ChequeAccount, PayReciveAccount, ChequeCost, PayReciveCost, EndorseAccount, Customer, ChequeHistory, ChequeOrigin, LastEventInfo |
| Generate Multiple Credit Notes | prcPrintAR_CreditNoteGenerator_Default | One run of the multiple credit notes generator. | Generator, GeneratorItems, TotalsOfGenerator |
| Direct Labor Wages | prcPrintAR_DirectLaborAllocation_Default | The direct labor wages of one job order. The ID it receives is the job order's. | Data, DirectLabors |
| Job Order | prcPrintAR_JobOrder_Default | One 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 |
| Manufacturing | prcPrintAR_Manufacturing_Default | One manufacturing operation. | Form, Ready Materials, Raw Materials, Individual Costs, Total Costs, Workers, Machinen, Manufacturing, ApprovalProcedures, UsersDecisions, Approvals |
| Packing List | prcPrintAR_PackingList_Default | One packing list. | PackingListHeader, Currency, Branch, Container, PackingListBills, PackingListMaterials, PackingListTotals, PackingListCF |
| Point of Sale | prcPrintAR_POS_Default | One point of sale order. | Order, Order Items, Addresses, Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, Discounts, LinkedPayments, RelatedBills, Checks |
| Request | prcPrintAR_POSSDOrder_Default | One order of the smart device point of sale. | Order, Items, Customer, Totals, OrderDetails, OrderEvents, AppliedSpecialOffer, SuppervisorsApprovals |
| Transaction | prcPrintAR_POSSDTransaction_Default | One transaction of the smart device point of sale. | Transaction, Items, Customer, Totals, PaymentMethods, SuppervisorsApprovals |
| Profit Center | prcPrintAR_ProfitCenter_Default | One shipment to a profit center. | ShipmentHeader, Currency, CurrentAccount, SaleGoodsAccount, ProfitCenter, ShipmentStore, CenterStore, GORStore, ShipmentItems, ShipmentTotals |
| Restaurant | prcPrintAR_Restaurants_Default | One restaurant order. | Order, Order Items, Addresses, Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, Discounts, LinkedPayments, RelatedBills, Checks, Restaurants |
| Shipping | prcPrintAR_Shipping_Default | One shipping between warehouses. | Users, Shippments, Receivments, ShippmentItems, ReceivmentItems, Transporters, ShippmentMaterial, ReceivmentMaterial, ShippingCF |
| Transfer | prcPrintAR_Transposition_Default | One 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 Request | prcPrintAR_MaintenanceOrder_Default | One 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 data | How to read it |
|---|---|
Tables of cards, such as Currency, Store, Branch, User, Distributor, SalesMan, CostCenter, BillType and Customer | One 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. |
Bill | The 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. |
BillItems | One 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. |
VoucherHeader | The 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 Details | One row for each line of the document. |
Tables ending in Totals | One row with the totals of the document. |
Tables with the names ApprovalProcedures, UsersDecisions and Approvals | The 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_DefaultandprcPrintAR_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.
Related
This page applies to alameen ERP 10, version 10.1.79.764.