Designer of external printing forms 1c. Publications. Instructions for a managed application

So! There is a configuration (for example "Trade Management", edition 10.3), and for it you need to develop an external printable. For example, take model document "Invoice for payment to the buyer" (although external printable forms can be created not only for documents, but also for reference books).

Example for 1C 8.3 (Managed forms)

An example of developing an external printable for a managed application can be viewed.

A task

Develop an external printed form, which will be available from the document "Invoice for payment to the buyer", and which will contain the name of the organization, counterparty and a list of goods with price, amount and quantity.

Go!

The first thing to do is create an external processing file. Processing should contain three main points:
  1. Attribute "LinkObject" with the type "DocumentLink.InvoicePayment to the Buyer"
  2. Layout to be printed
  3. Export Function "Print ()" which returns a spreadsheet document
These actions can be seen in figure # 1

"Drawing the layout"

Our layout will contain two areas:
  1. The title (head) of the document (the names of the organization and the counterparty will be placed in this area), and the head of the table (with the names of the columns)
  2. Table with goods (columns, with name, quantity and amount)
Figure # 2 shows the layout of the external printing plate. Note that the table cells and header cells contain parameters, not just text.

Function "Print ()"

Now the form is almost ready. It remains to write the programmatic filling of the fields of the spreadsheet document. These actions are performed in the module of the processing object, in a function called "Print", which MUST be exported.
Stage 1. Obtaining data for the header, filling in the header parameters, and its output to a spreadsheet document TabularDocument \u003d New TabularDocument; Layout \u003d Get Layout ("Our Layout"); Data Request \u003d New Request ("SELECT | SUBMISSION (InvoicePointing to Buyer.Contractor) AS A Counterparty, | PRESENTATION (InvoicePaying to Buyer.Organization) AS Organization | FROM | Document.InvoiceToPayment to Buyer AS InvoicePointing & Payment | Data Query.SetParameter ("Link", LinkOnObject); Head \u003d Data Query.Run (). Select (); Hat.Next (); Area \u003d Layout.GetArea ("Header"); Region.Parameters.Fill (Heading); TabularDocument.Display (Region); Stage 2. Receiving tabular data and line-by-line output of goods
Data Query.Text \u003d "SELECT | _Goods.LineNumber, | PRESENTATION (_Goods.Nomenclature) AS Nomenclature, | _Goods.Quantity, | _Goods.Price, | _Goods.Total | FROM | Document.Invoice of Goods _Goods to the Buyer | Link \u003d & Link "; Fetch \u003d Data Query.Run (). Select (); Region \u003d Layout.GetScope ("Data"); While Selection.Next () Loop Area.Parameters.Fill (Selection); TabularDocument.Display (Region); End of Cycle; Stage 3. Return of spreadsheet document and print function Returning TabularDocument;

Add our external printing plate to 1C

We go to the menu "Service - External printing forms and processing - External printing forms"

In the element creation window that opens, perform the following actions:

  1. Load the external processing file
  2. We indicate for which document (or reference) of the configuration the printable is intended
  3. Recording changes

We print!

We open any document "Invoice for payment to the buyer" (with the filled tabular section "Products", because it is from there that we take the data to fill out), click the "Print" button, in the window that opens, select OUR printable form, and click "Print"


ATTENTION!This development algorithm is suitable ONLY for "Normal Application". Print forms for configurations in Application Guided mode are different!

The file of the printable form shown in the example can be

This article describes how to connect an external printing plate to the 1C base using the example of the "Trade Management 10.3" configuration

The "Trade Management 10.3" configuration is a configuration on the so-called "REGULAR" forms, and not on "MANAGED" forms like "Trade Management 11.2", we recommend reading for "MANAGED" forms.

Our instruction "shows" how to connect an external printing plate in 1C with a configuration on "REGULAR" forms, namely:

  • "Accounting 2.0"
  • "Trade Management 10.3"
  • "Salary and personnel management 2.5"
  • "Integrated Automation 1.1"
  • "Control manufacturing enterprise 1.3 "
  • "Retail 1.0"
  • and other similar configurations.

In order to connect an external printing plate in 1C, we need to go through 11 steps.

1 - Menu "Service". 2 - We select "External printing forms and processing". 3 - Next - "External printing forms" (see the figure below ↓)

In order to convince you that this instruction is suitable for other configurations on "STANDARD" forms - we will present the same initial 1-2-3 steps, but not in "Trade Management 10.3", but in "Accounting 2.0" everything is there as well, with the exception of slightly changed words in the subparagraphs, namely ...

1 - Menu "Service" (as in "UT 10.3", and in others).
2 - Here "Additional reports and processing", and not "External printing forms and processing" as in "UT 10.3",
but all the same, the meaning is the same and is in the same place in the "Service" menu.
3 - And then - "Additional external printing plates", i.e. an extra word "Additional" when compared with "UT 10.3" (see the figure below ↓)

Then we will continue with the example of "Trade Management 10.3" without unnecessary comparisons.
4 - Press the button "+" i.e. Add. 5 - The button where the folder is drawn (on hover, a hint will appear: "Replace external processing file").

In new versions of 1C (starting from August 2016), the program has a built-in warning mechanism about the dangers of using unknown external processors that may contain "viruses"; in earlier versions of the program, the warning will not occur! If it occurs, then to connect external processing it will be necessary - 6 - press the "Continue" button. (see picture below ↓)

7 - We select the directory in which the file of the external printing form we need is located. 8 - Select our file. 9 - Click "Open" (see the figure below ↓)

10 - An external printable can have auto-registration parameters, as in our case, here it makes sense to click "Yes" - thereby using these parameters during registration, i.e. automatically select those objects (documents or maybe, for example, directories) in which it will be possible to use a plug-in external printable (see the figure below ↓)

That's all, we have filled in the "Printed form ownership" table, thanks to the auto-registration parameters, we see the name of the external print form to be connected, perhaps you will fill in the "Comment" field, etc. You can add your objects to the "Printed form ownership" table, for example, for our processing "Universal printable form of the contract", which supports the printing of many documents and reference books, but the auto-registration parameters are set only for the main ones: 10* - Click on the green "Add" button and choose which objects to place for processing. Now all that remains is - 11 - press the "OK" button and (see the figure below ↓)

Now it's worth checking - have we done everything right?
To do this, select an object for verification, for example, the document "Sale of goods and services", which is indicated in the table "Printing plate ownership", which means that the connected printing form can be used in this document! Let's check ... (see the picture below ↓)

To check the possibility of printing, open any document of the form: "Sale of goods and services." 13 - Press the "Print" button.
We see - a selection window has appeared printed forms, among them there is - 14 - external printing plate connected by us (see the picture below ↓)

Consider writing the simplest printable in 1s 8.1 - 8.2 for example configuration Enterprise accounting 2.0... Let's say you want to write an external printable for a document: display the basic data of the document, as well as from the tabular section Products: nomenclature, price, quantity and amount.

You can download the resulting example by.

In the configurator 1C Enterprises 8 create external processing ( File-\u003e New-\u003e External Processing), set the name, create the requisite required for the external printable ReferenceObject with type DocumentLink.Realization of GoodsServices.

Creating a layout of a printing plate

Add new layout, leave the layout type Spreadsheet document... Create three areas on the layout: Hat, Data and Basement... This can be done by highlighting the required number of lines and clicking the menu Table-\u003e Names-\u003e Assign Name (Ctrl + Shift + N).

After that, we begin to place text and parameters in the areas. We display in the header name of the printed form, document number and organization, and also draw the borders of the table header and write the names of the columns. When creating a parameter in the cell properties, on the layout tab, set the property Filling in value Parameter.

In area Data create parameters for displaying the rows of the tabular section ( Nomenclature, price etc.), and in the area Basement for totals by quantity and amount.

Programming

Let's go to the module of the printable object Actions-\u003e Open Object Module.

Let's create a mandatory export function for printable forms. Print ().

Function Print () Export EndFunction

In the function, create a variable for spreadsheet document, in which the printed form will be displayed, we get layout and layout areas.

TabDoc \u003d new TabularDocument; Layout \u003d Get Layout ("Layout"); Header Area \u003d Layout.GetArea ("Header"); DataScope \u003d Layout.GetScope ("Data"); AreaFooter \u003d Layout.GetArea ("Footer");

Fill in the parameters hats and display it in spreadsheet document.

Captions.Parameters.TextHeader \u003d + ReferenceObject.Number; AreaHaps.Parameters.Organization \u003d ReferenceObject.Organization; TabDok.Display (Caps area);

To get the rows of the tabular section Products we use the request.

Request \u003d new request; Request.SetParameter ("Link", LinkOnObject); Request.Text \u003d "SELECT | Sale of goods, services, goods, nomenclature, | Sale of goods, services, goods, amount, | Sale of goods, services, goods, price, | Sales of goods, services, goods, quantity | FROM | Document.Realization ofGoodsServices.Goods AS Sale ofGoodsServicesGoods | WHERE | Implementation of GoodsServicesGoods.Link \u003d & Link ";

Pass the props to the request parameter ReferenceObjectto indicate in the condition WHEREthat we only need the data of the document from which we display the printable. To get a fetch of a query, we first execute it and then fetch the rows.

Selection \u003d Query.Run (). Select ();

Next, in the loop, fill in the area parameters Data for each line of the document selection and display them in spreadsheet document... Also, in the cycle, we calculate the total values quantity and sums... We will not fill in each parameter separately, but use the procedure FillPropertyValues \u200b\u200b((<Приемник>, <Источник>) of global context, it copies the property values <Источника> in properties <Приемника> ... Matching is done by property names. You can read more about this in syntax assistant 1C Enterprise 8.

TotalSum \u003d 0; TotalQuantity \u003d 0; While Fetch.Next () Loop FillPropertyValues \u200b\u200b(ScopeData.Parameters, Fetch); TotalSum \u003d TotalSum + Sample.Sum; TotalQuantity \u003d TotalQuantity + Sample.Quantity; TabDok.Display (ScopeData); End of Cycle;

Fill in and display the area Basement.

AreaBoard.Parameters.TotalQuantity \u003d TotalQuantity; AreaBoard.Parameters.TotalSum \u003d TotalSum; TabDok.Display (Area Basement);

Returning the filled spreadsheet document from the function Print ().

return of TabDoc;

If you are using one of the typical configurations, then after returning the spreadsheet document 1C will display the printed form itself. You can also use the spreadsheet document method for output Show ().

5. Connecting the printable to the document

IN typical configurations 1C 8 there is a directory for registering external printable forms External treatments... To connect, go to the menu in enterprise mode Service-\u003e Additional reports and processing-\u003e Additional external printable forms.

Add a new element of the directory, load the printable from disk and select the type of document.

Now in the doc Sale of goods and services a new printable will appear.

Auto registration of printable

In order to avoid having to manually select the type of document when connecting the printing form, you can configure auto registration... To do this, add a new layout and name it Auto-registration_Parameters(only this way) and in its first cell we write Documents.<Наименование документа> (or Reference books.<Наименование справочника> ).

Now, when connecting a printable, we will be prompted to use auto-registration parameters.

External printables for a regular application (for the Enterprise Accounting 2.0 configuration, Payroll and Human Resources 2.5, Trade Management 10.3, etc.) are quite simple to create compared to external printables for a managed application.

Why create external printing plates

The advantage of an external printing plate over a conventional one is that it avoids changing the configuration of the infobase. This means that the process of subsequent configuration updates will not be complicated. In addition, external printing forms, along with external processing, are the only option for expanding the functionality of the basic versions of 1C configurations, which cannot be changed at all.

And the last thing: external printing forms are easier to replicate, because they are a separate file that can be quickly connected to the infobase.

How to create an external printable

Let's consider the process of creating an external 1C printing form in steps:

  1. We create external processing. To do this, select the menu item in the configurator File - New ... And in the opening dialog box - External processing.
  2. Create an external processing props named ReferenceObject... Attribute type - a link to a reference book or document for which an external printable is created. The same form can be used for several types of objects, in this case the data type of the props ReferenceObject must be composite.
  3. In the object module, create an export function named Printing, which should return a ready-made tabular document of a printing form.

It often happens that you need to slightly adjust the layout of an existing printing plate and make it external. For example, add an organization seal and a manager's signature to the layout.

Creation of an external printing plate based on a standard one with minor changes

Let's consider this procedure using the example of creating an external printable for a universal transfer document for a document. Sale of goods and services 1C: Accounting. It will differ from the standard printing form by the presence of the organization's seal.

  1. We create external processing with props LinkToObject,data type - DocumentLink.Realization of GoodsServices.
  2. We find the layout of the standard printable form of the UPD (it is in the general layouts) and copy (drag) it into the external processing window. Layouts of other printed forms can be located in the documents themselves or reference books.
  3. We make the necessary changes to the copied layout of the printing plate.
  4. We find the function responsible for the formation of the printing plate. This function should return the generated spreadsheet document. Copying its content into the export function Print ()in the module of the external processing object.
    In our case, this is the function Printing Universal Transfer Document () Exportfrom the document object module Sale of goods and services.
    If the layout changes were significant (areas and / or parameters changed), then it is necessary to make the appropriate adjustments to the print function.
  5. Trying to keep external processing. This will most likely generate error messages related to the absence of some procedures and functions called by the print function. These functions and procedures must be found in the original document and also copied into the module of the external processing object. Or correct the link if the original function or procedure is exported.
  6. (not necessary).For testing an external printing plate, it is convenient to make its form, on which to place the props ReferenceObject... Button Executeshould call the procedure Print ()from the object module. For this, a procedure is assigned to the button click event:

This article will tell you in detail how to create a printable for a beginner who does not know much about 1C 8. For example, let's take one of the most common 1C 8 configurations - Accounting 2.0... Creation of a printing form 1C stages of writing:

  • Creation of a file of an external printing plate;
  • Creation of a printable layout;
  • Writing program code for displaying printable data on the screen;
  • Creation of parameters for auto-registration of a printable;
  • Connecting an external printing plate to the base 1C Enterprise.

Creation of a printing form 1C. Formulation of the problem

We are required in the configuration Accounting 2.0 create a printable for the document Receipt of goods and services... Print the following data in the header of the printable:

  • Organization;
  • Counterparty;
  • Counterparty agreement;
  • Date of admission.

Display tabular data in the form of a table Productsdocument. The table should include the following columns:

  • Nomenclature;
  • Number;
  • Price;
  • Amount;
  • And also the price of the item as of the current date (according to the type of prices from the document).

External processing file

Let's move on to solving the problem. First, let's open 1C 8 in the mode Configurator... It is in this mode that all developments on the 1C 8 platform are carried out. Now we need to create an external processing file. To do this, click on the menu File -\u003e New ... or by the new file icon.

In the window that opens, select the item External processing.

Further in the field Name it is necessary to enter the name of the external treatment. In our case, let's call it simply: "Printing Form", the synonym field will be filled in automatically. Note that in the field Name,external processing, you should write the name without spaces and punctuation marks.

Add a props for external processing LinkOnObject and select for him type DocumentLink.Arrival of GoodsServices... To do this, in the metadata tree of external 1C processing, select the item Requisites and press the button Add to (green plus button). On the right side of the screen, the property window will open, in the field Name write - ReferenceObject. IN field A type press the button with three dots.

In the type tree, open the branch DocumentLink, and find there the item Receipt of Goods / Services, put a tick in front of it and click OK.

Let's save the external processing file to the hard disk, for this we use the menu File -\u003e Save, pictogram Save (blue diskette), or a keyboard shortcut Ctrl + S... Let's name the file being saved "Printing Form".

Creating a layout of a printing plate

Let's start creating a layout of the 1C printing form. The layout serves as a template for the output of the printable, so if you want your printable to look good, you should pay attention to it.

In the metadata tree of external processing, add a new layout, in the layout designer window we will not change anything and click the button Done.

In the new layout that opens, create several areas necessary for the output of the printable. All the areas of the layout we need will be horizontal, so to create new area select the required number of layout lines and go to the menu Table -\u003e Names -\u003e Assign Name or use the keyboard shortcut Ctrl + Shift + N, then enter the name of the area in the box. When creating a layout area, do not be afraid to make a mistake with the number of lines, you can always add or remove them. To delete a line of the 1C layout, select the required line and select the item in the context menu Delete... To add a new line to the layout, select any line in the layout and select the item Push apart.

Adding a layout header

First of all, let's create an area Cap, the data for the header of the printable will be displayed there. For this area, we need seven lines of the layout. Let's select them and, as I wrote above, press the keyboard shortcut Ctrl + Shift + N, in field Name write "Hat" and press the button OK.

Let's fill the layout area with the data we need. Usually no printable is complete without a header, so let's create one in our header as well. Since in the title, in addition to the name of the printable, we will also display the number of the document from which it was printed, we will set the title text in the layout with a parameter. A layout parameter is a specially designated layout cell, into which various data can be displayed using the built-in 1C 8 language. The heading should be displayed on the entire width of the printing form, so let's determine how many layout cells we will need to print on the standard landscape orientation of the sheet.

Usually thirteen or fourteen layout cells are enough, select them in the first line of the area Cap and combine into one cell ( Context Menu -\u003e Merge). After that, double-click on the resulting large cell and write the name of the parameter, in our case "TitleText". In order for the entered text to become a full-fledged parameter, right-click on the cell and select the item in the context menu Properties... On a bookmark Layout find the field Filling and choose the value Parameter... Parameters in the 1C layout are indicated by brackets "<>».

The heading of the printable should stand out among other text, so once again select the cell and, using the icons on the layout formatting panel, set the text alignment Center and font size 14.

After the title text, we display in the area Capdata on the organization, counterparty, contract of the counterparty and the date of goods receipt. Since all this data is also taken from the document, we will also arrange them with parameters. In addition, before each parameter, an explanatory text should be written so that the user can easily understand where the organization is, and where is the counterparty, etc. All these actions are similar to creating a heading, so I will not dwell on them in detail, I will give only a picture with what should be the result.

The figure shows how the layout parameters differ from normal text.

Adding a layout table header

The last thing we need to create in this area of \u200b\u200bthe layout is the table header, into which the data of the tabular section will be displayed Products... The columns required for the table were described in the "Problem Statement" section. We will also create the table header using the concatenation of cells and writing text (column names). Select the borders of the table header using the tool Framewhich is located in the layout formatting pane.

Adding a table to the layout

Let's create another area in the layout - Data... It will display the data table of the tabular section Products.For this area, we only need one line of layout. To display all the rows of the tabular section in a printable form, we will fill in and display this area as many times as necessary. Columns in the area Data must match the columns of the table header, so filling it out is easy. The only difference is in the area Data we need parameters, not just text. Also note that by default, numeric parameters are right-aligned and text parameters are left-aligned. To select columns, you also need to use the tool Frame.

Adding a footer to the layout

The last layout area we need is Basement... It will display totals by quantity and amount. Creation is similar to area creation Data, but in addition, you should highlight the totals in bold.

As a result, you should get the following layout:

Creation of a printing form 1C. Programming

Let's start programming - this is the most important stage in creating a printing plate. First of all, let's go to the module of the object of the external printing form, this is where we will program. To do this, in the main window of external processing, click Actions -\u003e Open Object Module.

In the module of the object of the external printing form, you need to create an export function Print ().

Function Print () Export End Functions

Please note that this feature is required for external printing plates in configurations using a regular application. We will write all the subsequent program code necessary for displaying the printable inside this function.

Initializing Basic Variables

Let's create a variable TabDoc, which will contain the spreadsheet document - it is he who is the printable in which we will display the filled areas of the layout.

TabDoc \u003d new TabularDocument;

Into a variable Layout we get the layout of the printing plate we created. For this we use the built-in function Get Layout (<ИмяМакета>).

Layout \u003d Get Layout ("Layout");

We will get all the areas of the layout into variables. For this we use the layout method GetArea (<ИмяОбласти>) .

Header Area \u003d Layout.GetArea ("Header"); DataScope \u003d Layout.GetScope ("Data"); AreaFooter \u003d Layout.GetArea ("Footer");

Output of the printable header into a spreadsheet document

All required variables are initialized. Let's start filling and displaying the layout areas in a spreadsheet document. First of all, let's fill in the header of the printable, for this we need to pass in the parameter TextHeader, which we created in the layout, the text we need. To fill in the parameter values, the layout area has a special collection, which is called so - Options.From which through "." you can get any parameter. In the title text we will transfer the text: "Printable", as well as the document number.

AreaHeads.Parameters.TextHeader \u003d "Printable" + ReferenceObject.Number;

Fill in the rest of the header parameters in a similar way, we get all the necessary values \u200b\u200bfor them from the props ReferenceObject, which contains a link to the document being printed.

AreaHaps.Parameters.Organization \u003d ReferenceObject.Organization; AreaHaps.Parameters.Contractor \u003d ReferenceObject.Contractor; AreaHaps.Parameters.ArrivalDate \u003d ReferenceObject.Date; AreaHaps.Parameters.Contractor Agreement \u003d ReferenceObject.Contractor Agreement;

All header parameters are filled in, we will display it in the spreadsheet document we created, for this we use the method Output (<Область>) .

TabDok.Display (Caps area);

Writing a request for a printable handicap

Let's fill in and output the area Data... Creating a printable 1C also means writing a request, we need it to get the data of the tabular section Products and prices Nomenclatures for the current date we will use Request... The 1C 8 query language is similar to SQL, or rather practically copies the capabilities of its SELECT operator, but the entire query is written in Russian. Therefore, if you are even remotely familiar with SQL, then you will easily understand the 1C 8 query language.

In this printed form, the request will be quite simple and many will say that it would be possible to do without it, but knowledge of the query language and the ability to use it correctly is one of the main skills of a 1C programmer. Queries allow using less resources to obtain the most complex data samples, and also the query text is much easier to understand than the program code written without using a query (or with minimal use of it). In addition, 1C 8 has a very good query designer that allows you to interactively collect a query from the required tables.

Let's create a variable that will contain the request.

Request \u003d New Request;

We will compose the request text using the query constructor. First, let's write:

Request.Text \u003d "";

Put the mouse cursor between the quotes, press the right mouse button. In the context menu that opens, select the item Query constructor, it will help us a lot in creating a 1C printing form. After that, the query designer window will open, it contains many tabs, but for our query only four are needed: "Tables and Fields", "Relationships", "Conditions", "Joins / Aliases".

For our query, we need two tables: tabular section Products document Receipt of goods and services and a slice of the latest information register for the current date Item prices.

On the left side of the designer window, find the column Database... It contains a tree of all metadata objects, we will find the ones we need. To do this, open the branch Documents and find the document Arrival of goods and services, open it and find the tabular section Productsby dragging it to the query designer column Tables... You can drag in three ways: by dragging and dropping, by double-clicking on the table, or by selecting it and pressing the "\u003e" button. Let's open the branch Information Registers and find the table there PricesNomenclature.SliceLast, also drag it to the column Tables... These two tables are enough for our query.

Let's select the fields we need from the resulting tables. To do this, in the column Tables open the table and find the fields: Nomenclature, Amount, Price, Quantity and drag them to the third column of the constructor - Fields... Let's open the table , find the field Price and also drag it to Fields.

The structure of the tables and fields of our query is ready, now we will deal with the conditions. We need the data of the tabular section Products were taken not from all receipts, but only from the one that we print. To do this, we impose a condition on the table Arrival of goods... Let's go to the "Conditions" tab of the query designer. In a collumn Fieldsthe tables we selected earlier are located, for the condition we need a field Link from the table Receipt of goods, services, goods, drag it to the Conditions window.

You can use parameters in 1C requests, they are needed in order to transfer data to a request. For example, if we want to restrict the selection of documents to a specific document, then using a parameter, we can pass a link to this document to the request and use this parameter in the condition. This is exactly what we will do in our request.

After out the window Conditions we added a field Link, the query builder will itself create a parameter with the same name and place it after the "\u003d" sign. This parameter can be renamed if desired. Parameters in the request text are marked with "&", but in this case you don't need to do this, since it is assumed that the second part of the condition contains a parameter, you just need to remember it. How to transfer a value to a 1C request parameter will be described below.

Since in the request we do not use a complete table of item prices, but a virtual one (a cut of the latter in this case), we need to set the conditions for the formation of this virtual table, in our case this is the cut date and a condition for the price type (prices must be selected that have a strictly defined price type - the one that is specified in the receipt document that we print).

To fill in the parameters of the virtual table, go to the tab Tables and fields query constructor, in the column Tables select the table PricesNomenclatureSliceLast and press the button Virtual table parameterslocated at the top. In the window that opens, in the field Period you should set the parameter to which the date will be transmitted, for which the prices will be cut. In our case, this will be the current date (that is, today), therefore we will name the parameter "& CurrentDate". In the condition field, we will write conditions for the price type, we will also pass it in the parameter, which we will call "& TypePrice". The resulting condition will look like this (where Price Type - register measurement Item prices):

PriceType \u003d & PriceType

The virtual table parameters are filled, press the button OK.

Now that we have limited the selection to only the document we need, we will create links between the query tables. If you do not do this, then the prices from the ItemNomenclatureSlicePrices table will not be linked to the item from the receipt. Let's go to the tab Connectionsquery constructor. Create a link across the field Nomenclature between our two tables. To do this, press the button Add to, in field Table 1select a table Arrival of goods, and in the Table 2 field - PricesNomenclatureSliceLast. In the communication conditions, select the fields Nomenclature from both tables.

It should also be noted that in the query selection we need to get all the rows from the tab part Products and prices only if available for the current date by type of document prices. Thus, these tabs Products are required, but the price cut data is not. Therefore, in the links between these tables, it is necessary to use the so-called LEFT JOIN, and the left (or required) table will be Arrival of goodsand the right (or optional) PriceNomenclatureSliceLast. In order for the left join of the query tables to work as I described above, you must check the box All after the field Table 1.


The query is almost ready, there is only a little work left on the field aliases. Let's go to the bookmark Unions / Aliases and set an alias for the field PricesNomenclatureSliceLast.Price... The alias name will be - PriceToday, it is needed so that the names of the query selection fields and the names of the parameters in the layout of the printable are the same.

This completes the work in the query designer, press the OK button. After the constructor window closes, you will see that the line with the request text is filled and looks like this:

Zapros.Tekst \u003d "SELECT | PostuplenieTovarovUslugTovary.Nomenklatura, | PostuplenieTovarovUslugTovary.Summa, | PostuplenieTovarovUslugTovary.Tsena, | PostuplenieTovarovUslugTovary.Kolichestvo, | TsenyNomenklaturySrezPoslednih.Tsena AS TsenaNaSegodnya | FROM | Dokument.PostuplenieTovarovUslug.Tovary AS PostuplenieTovarovUslugTovary | left join RegistrSvedeniy.TsenyNomenklatury.SrezPoslednih (| & CurrentDate, PriceType \u003d &PriceType) AS PricesNomenclatureSliceLatest | ON Incoming GoodsServicesGoods.Nomenclature | \u003d PricesNomenclaturesSliceLatest.Nomenclature | WHERE | Incoming GoodsServicesGoods.Link \u003d & Link ";

Executing a request

Let's pass the necessary parameters to the request, for this we use the request method SetParameter (<ИмяПараметра>,<Значение>). To get the current date, let's use the built-in function The current date(), it returns the date and time of the computer.

Let's execute a request to get a selection with the data we need. To do this, we first use the request method Execute ()and then by the method Select().

Selection \u003d Query.Run (). Select ();

Filling out the printable table

As a result, in the variable Sample will contain a selection of query results, you can navigate through it using the method Following(), and to bypass the entire loop you need Until... The construction will be as follows:

While Fetch.Next () Loop End of Loop;

It is in this loop that we will fill and display the layout area Data... But first, let's initialize two variables of the numeric type. In them we will collect totals for the quantity and amount that we need to bring to the area Basement.

TotalSum \u003d 0; TotalQuantity \u003d 0;

Inside the loop, we will fill the area Data data from the current selection element, into variables Total Amountand Total Quantity add the values \u200b\u200bof the amount and quantity, and finally, display the area in the spreadsheet document using the method already familiar to us Output ()... Since the field names of our query completely coincide with the names of the scope parameters Data, then for filling we will use the built-in procedure FillPropertyValues \u200b\u200b(<Приемник>, <Источник>), which copies the property values<Источника> in properties<Приемника>.

While Fetch.Next () Loop FillPropertyValues \u200b\u200b(ScopeData.Parameters, Fetch); TotalSum \u003d TotalSum + Sample.Sum; TotalQuantity \u003d TotalQuantity + Sample.Quantity; TabDok.Display (ScopeData); End of Cycle;

Outputting the footer of a printing form to a spreadsheet document

It remains to fill and display the last area of \u200b\u200bthe layout - Basement... We have already prepared the data for filling, filling in and withdrawal is carried out according to the same scheme.

AreaBoard.Parameters.TotalQuantity \u003d TotalQuantity; AreaBoard.Parameters.TotalSum \u003d TotalSum; TabDok.Display (Area Basement);

The spreadsheet document is completely filled, it remains to display it on the screen so that the user can view the printed form and, if necessary, print. But in typical 1C 8 configurations, the procedures of special modules are responsible for the output of external printing forms. Therefore, it is enough to return from the function Print () completed spreadsheet document.

Return of TabDoc;

At this stage, the programming is over and the creation of the printing plate 1c is almost complete. Full function text Print () I will not give it here, you can see it in the printable file, which can be downloaded at the bottom of the article.

Creation of a printing form 1C. Auto registration parameters

When connecting an external printing form to the base, the system does not automatically determine which document or reference book the printing form is intended for; you have to select it manually. And if another person wrote the printed form, and you were only instructed to connect it, then the choice may become ambiguous. In order to avoid such problems, it is necessary to create a layout with auto-registration parameters in all external printable forms. If it is created and correctly formatted, then the system automatically determines which document or reference book the printed form is intended for.

It is done as follows:

  • In external processing creating a new layout. We call it "Auto-Registration_Parameters" (it's important not to be mistaken!).
  • In the first cell of the layout, write Documents. (or Reference books.) and the name of the document to which you want to connect the printable.

Connection to the base of an external printing plate

  • Run 1C 8 in mode Company;
  • Go to the menu Service -\u003e Additional reports and processing -\u003e Additional external printable forms;
  • Click the button Add to;
  • In the window that opens, click the icon Replace external processing file;
  • If you have created auto-registration parameters, then we agree to use them;
  • If you have not created auto-registration parameters, then in the tabular section Affiliation of the printing plate add required document or reference book;
  • Push the button OK.

After that, the external printable will be available in the menu Printing document Receipt of goods and services.The creation of the 1C printing form can be considered completed on this.