Using built-in and additional processing. Using built-in and additional processing We write the command handler code


Attention! This is an introductory version of the lesson, the materials of which may be incomplete.

Login to the site as a student

Log in as a student to access school materials

Creating 1C configurations: adding processing

We continue to study the basics of creating configurations on 1C.

In this lesson, we will create a new processing together, and then write commands for it that demonstrate how to work with the “Employees” directory.

We return to the configurator and open the configuration tree.

Adding a new processing

Right-click on the “Processing” section and select “Add”:

The window for creating a new processing opens. Let's go to the "Main" tab and specify "Directory Processing" as the processing name:

Creating a form for processing

Let's go to the "Forms" tab, click on the green plus sign to add a new form (visual representation of our processing):

A form creation constructor has appeared. Let's leave everything as default and click "Finish":

A new form has opened:

Create a new command for the form

Let's go to the "Commands" -> "Form Commands" tab:

Let's add a new command (green plus sign):

And in the properties of the new command we will indicate the name “OutputAllEmployees”:

In its properties, click on the magnifying glass next to the “Action” field to set the command handler. Select the option to create a handler "On Client" and click "OK":

We were transferred to the form module in the handler procedure of the "Output All Employees" command:

Writing the command handler code

Now our task is to write code in the internal 1C language that will iterate through all the elements of the “Employees” directory.

I want to say right away that this code cannot be written directly in the “Output All Employees” procedure, since it is executed on the client (pay attention to the special line before the “&OnClient” procedure). Trying to read data from the database in a client procedure will always result in an error (just remember this for now).

Therefore, let's add a procedure like this at the end of the module:

Please note that before it I indicated the “&OnServer” attribute. This means that it will be executed on the server, which means we can read directory data from it.

Now let’s organize a call to this procedure from the client “OutputAllEmployees”:

Here the logic is like this:

  1. The user calls the “Output All Employees” command (for example, by clicking on a button, which we really don’t have yet)
  2. The command launches the handler procedure of the same name “Output All Employees” on the client (after all, the button, and therefore the command, is on the client)
  3. The client procedure "OutputAllEmployees" makes a call to the server procedure "OutputAllEmployeesOnServer"
  4. The server procedure "Output AllEmployeesOnServer" reads directory data from the database and displays them in the message window

All we have left is to write the code for the “Output All Employees on Server” procedure, which goes through the elements of the “Employees” directory and displays them in the message window.

It's actually not difficult. Traversing all directories in 1C is the same. This means that having learned to do this now with the “Employees” directory, you can do the same with any other directories.

To access directory data, a manager is used, which is accessed as follows:

Manager = Directories. Employees;

In this sentence, the key part is to the right of the equal sign. On the left is just a variable into which we save the manager to work with it further. The name of this variable could be not only “Manager”, but also any other - even “Drummer”.

What is a directory manager? A manager is not the directory data itself. A manager is a program object (you can think of it as a black box) through which we can do something with the directory.

The directory manager is like a layer between our code and the directory data. And it turns out that if we need to read all the elements of the directory, we cannot do this directly. We can only ask our layer between us and the directory, that is, the manager, about this.

To do this, you need to call the “Select” method built into the manager. It is called with a dot after the name of the variable in which the manager is stored, and returns a collection of directory elements:

Manager = Directories. Employees; Sample = Manager. Choose() ;

What is a sample? A selection (again, this is just the name of the variable into which we save the result of the “Select” method and it could be anything else) is a collection, but not the same as, for example, an array or a list of values.

The selection is an object - again think of it as a box - but not yet the data itself. The peculiarity of this object is that it can iterate through the elements of the directory we need. Moreover, it sorts them out dynamically. This means that using sampling does not read all the directory elements at once, but selects them in portions from the database.

This approach allows you to quickly traverse large lists of directories using selection, without loading them all into the computer memory at once.

To get the next piece of data from a selection, you need to call the “Next” method built into the selection. Receiving chunks of data (one chunk corresponds to one directory element) usually occurs in a loop:

When the data (directory elements) in the selection runs out, the “Next” method will return False and the cycle will stop.

After each call to the “Next” method (provided that it returned “True”), the selection will contain all the fields with data of only the read directory element, which can be accessed by name separated by a dot:

It turns out in one moment - we work with the data of only one of the elements of the directory. And here we can either immediately display them to the user (using the “Notify” method) or, for example, we can put them in another collection (array) so that we can do something with them at once. It all depends on the problem we are solving.

Processings are application objects and configurations designed to perform various actions on information. Processing does not save data to the database, it only processes or changes it in some way.
In general, processing can be divided into built-in (located in the configuration) and external (most often supplied on ITS disks or self-written).
This article will discuss both built-in and external processing designed to significantly simplify the user’s life.

Processing "Search and replace values"

Processing "Search and replace values" is located on the ITS disk.
The universal processing "Search and replace values" is intended for searching and replacing reference values ​​in various objects of the 1C:Enterprise information base.

Example: Let’s say we need to replace a counterparty agreement with another (When generating documents, an incorrect agreement was entered, starting with the buyer’s order. Since all other documents were entered on its basis, an error in entering the agreement led to errors in all documents adjacent to the order) .

Sequencing:

1) In the “What to replace” field, select the directory “Counterparty agreements” and select the agreement of a specific counterparty. In the “What to replace with” field, select the counterparty agreement we need

1) Click the “Replace values” button and check the result by opening, for example, the “Buyer’s Order” document, and then looking at the structure of its subordination.

Processing “Universal selection and processing of objects”

Processing "Universal selection and processing of objects" is intended for searching for objects in directories and documents according to an arbitrary condition and further processing of the found objects. External processing, supplied on ITS disks.

First, the search object (the desired reference book or document) is filled in. Then fill in the “Selection by detail values” tab, in which the conditions for the selected objects are indicated, and click the “Find objects” button.
The "Found Objects" tab displays the data of the selection made.
The "Processing" tab contains options for possible actions that can be performed on a selected set of objects:

· Arbitrary algorithm – the processing is written by the specialist himself

· Setting details – replacing the values ​​of old details with new ones

· Renumbering of objects – numbering of objects in accordance with specified rules

· Mark for deletion

· Delete

· Conduct

· Cancel the event

Example 1:
Let's say we want to establish a single contract in an order to a supplier for a specific counterparty.
Sequence of actions - set “Order to supplier” as an object, select the supplier of interest to us. Click the "Find objects" button

We see the “Found Objects” tab filled in

Go to the "Processing" tab and select the "Custom algorithm" option.

A window appears in front of us in which the user can enter his own processing code, for example, replacing a contract in orders for a specific contract.

Let’s say we want to renumber the “Outgoing Payment Order” documents of any organization we have chosen, while changing the prefix of these documents.
Sequence of actions – set the document “Outgoing payment order” as an object. On the “Selection by values” tab, select the organization for which changes will occur:

We see the “Found Objects” tab filled in


Go to the "Processing" tab and select "Renumbering of objects", in the window that opens, change the document prefix and click "Run"

Processing "Universal document journal"

This processing in the UPP is built-in; you can find it using Service/Universal Document Log or Operations/Processing/Universal Document Log.

Processing allows you to display a list of documents, along with the values ​​of the details.

In this case, the composition of the list of documents and details can be customized at will.
Working with processing, as well as its appearance, is very similar to working with a document journal (For example, a journal of cash documents), the only significant difference is that the set of documents included in the journal is created by the user himself and the selection settings in this processing are more similar to the settings selection in reports rather than in journal list forms.

You need to start working with processing by clicking the “Composition” button and thereby defining the list of document types displayed in the journal.

Then make a selection by clicking the button on the toolbar (filter)

Let’s say we need to see all payment documents (PKO and incoming payment orders) under the “Main” Agreement (For example, we do not remember the counterparty, but we definitely remember that the payment took place under the “Main” Agreement, we also do not remember how the payment was made : through a cash register or through a bank).

Sequencing:

We determine the composition of the documents - an incoming cash order and an incoming payment order, fill in all the default columns

Based on the received documents, we make a selection (selection as in the report, when using a standard journal this is impossible). If necessary, we can add selection for the organization that interests us.

Built-in report that allows you to track movements on any document registered in the system. You can call the report by executing Operations/Reports/"Document movements by registers".

The user needs to select the document he is interested in, specify which one and click the generate button.

Example:
View the report on the document "Calculation of salaries to employees of the organization" and "Salaries payable to the organization"

Sequencing:

Select the data type - document "Payroll for employees of the organization"
Select a specific document

Click on the “Generate” button and get the result:


A built-in mechanism that can be used through Operations/Search for references to objects.

Add an object at the top to which the subsequently found objects should refer and click on the “Find” button. Elements appear at the bottom that use references to the object specified above.

Example: Let's say you need to find all documents in the transactions of which 51 accounts (current account) are used.
Sequencing:

We select the accounting chart of accounts as the data type.
Select 51 accounts and click on the “Find” button. Documents appear at the bottom:

Processing “Posting Documents”

Built-in mechanism, which can be found in the "Operations" menu item

Processing contains 2 tabs: “Processing documents” and “Recovering sequences”


It is necessary to check the boxes for all types of documents that need to be posted/reposted and enter the required date for posting/reposting (unchecking the “Do not limit” checkbox, otherwise entering the date will not be possible).
There are 3 options for document processing:

If you select the "Only posted" option, the documents will be re-posted in chronological order.
If you select the “Only unposted” option, all unposted documents will be posted.
To post all existing (including unposted) documents, select the “Posted and unposted” option.

On the “Sequence Recovery” tab, all sequences available in the program are listed and the relevance date of each of them is indicated.

Subsequence– 1C metadata object – designed for organized storage of multiple documents according to date and time.

Sequence boundary (SB)– position of the last entered document in the sequence. If after the GP there are other documents in the sequence, then the sequence is considered broken and must be restored.
Before the month-end closing procedure, it is strongly recommended to restore the sequence by re-posting the documents.

Full text search engine allows you to quickly find the necessary information in the information base data and in the help system.
You can find processing in the "Operations" menu item.
Before you start working with full-text search, the Manage Full-Text Search window often appears. To get started correctly, you need to click on the “Settings” button and check the “Allow full-text search” checkbox, then click “Update index”.

Appearance of processing

*Update index.
The system starts forming a search index.
To optimize the index formation process, a main index and an additional one are used, which is formed when entering data and contains information on the data entered after the last update of the main index. If the checkbox " Allow index merging" is set, the result of indexing the latest changes will be added to the main index. This mode may require quite a lot of time (if the size of the main index is large).

*Settings.
Sets whether or not to allow full-text search.

After completing all the steps, you can proceed to working with the built-in “Data Search” processing. (If these actions have not been completed, then when you start working with the “Data Search” processing, the system will ask a question about using full-text search and itself set the date of relevance of the index to the current date).
The full-text search mechanism in the data of the 1C:Enterprise system 8 allows you to search the database indicating search operators (AND, OR, NOT, NEXT, etc.).

Deleting objects marked for deletion

There is both built-in processing (Operations/Deleting objects marked for deletion) and external processing (supplied on ITS disks). Let's look at each of them.

1.Built-in processing.
When calling processing, the program checks how users work with this infobase and sets the exclusive operating mode. If they are working with the database, a message is displayed (but you can continue working in modal mode).
When processing starts, a list of database objects marked for deletion is displayed; each of these objects can be viewed by double-clicking on it.
It is possible to customize the list of objects to be deleted by checking or unchecking them.
To check whether there are objects in which references to the object being deleted exist, use the "Control" button (If such objects exist, then deleting the object is impossible). When you click on the "Control" button, a list of objects to be deleted, marked with green or red checkmarks, is displayed. Green - there are no links to the object to be deleted and the object can be deleted. Red – there are links to the object to be deleted, the object cannot be deleted (The “Links to the object to be deleted” field displays objects that refer to the object being deleted).
Then click “Delete” and delete all documents that are marked for deletion and do not have documents with links to them.
On the form that appears after clicking on the "Control" button, you can change settings by clearing or checking marks (for example, you can display or not display messages to the user about deleted objects)

2.External processing.
The essence of the external processing “Deleting marked objects” is no different from the built-in processing. The appearance has undergone slight modifications, and it is also possible to make a selection based on metadata (for example, delete only elements of a specific directory or documents of a specific type).
In external processing, referential integrity is also checked and it is impossible to delete objects that have links from other objects.

Using external processing "Deleting objects marked for deletion" is necessary in cases where:

· There are many marked objects in the database, deleting them takes a long period of time, and when the built-in processing “Deleting objects marked for deletion” is running, working with the database is impossible (there is no restriction regarding the exclusive mode).

· When there is no access to built-in processing

· If the built-in processing fails, it is recommended to use external processing.

Standard processing (Service/Group processing of directories and documents).
When working in the program, users constantly fill out reference books and documents. Sometimes there is a need to batch change the contents of directories and documents (for example, change the VAT rate in an item group or assign a new person in charge). It is in such situations that you can use this processing.

· Tab "Selection objects" - indicates which database objects will be processed

*Object type – directory or document

*Object type - one or more directories or documents (process tabular parts - makes it possible to make changes to the tabular parts of directories)

*Selection – conditions for selecting elements

· The “Processing” tab is the result of actions performed by the program (according to the selection conditions) and options for changing the results obtained.

Example of work:

Let’s say we want to see in the directory “individuals” the comment “Pre-retirement age” for all female employees who will be 60 or more years old in 2013.
The "Selection Objects" tab will look like this:

After the objects have been selected, set the action “Edit: [Comment]”, write the desired comment and click “Run”.

It is worth paying attention to such a processing settings item as “Allow changing object details” (the number of actions that can be performed on selected objects will increase). Let's say we are faced with the task of changing the VAT rate for each item that is a service.
Tab "Selection objects"

After the objects have been selected, set the action “Change: [VAT rate]”, select the rate and click “Execute”.

Find and replace duplicate values

There is both built-in processing (Service/Search and replacement of duplicate directory values) and external processing, supplied on ITS disks.
This processing allows you to search, replace and delete duplicate elements of any directory. The actions performed by this processing are irreversible.
The search can be performed in two modes: by equal attribute value, by similar words (only for string type attributes)

Typical processing option

Execute in transaction- replacement will be made only for all elements at the same time. Any unsuccessful attempt to replace one of the links will undo all previous changes to the data.
Disable write control -
Setting the degree of compliance– set only if the search is performed using a string attribute

Processing "Base rollup"

External processing. The "Base Collapse" processing is intended to perform the operation of collapsing information bases built on the basis of one of the standard configurations (UPP, BP, UT).
When performing a roll-up, documents are generated for entering balances in registers on a certain date (the roll-up date) and unused documents and movements in registers (information, accumulation, accounting) are deleted up to and including the roll-up date (roll-up period). Main goals of convolution:

  • Increasing the speed of the system.
  • Reducing the size of the information base.

Appearance:

1.Date of convolution. The collapse date refers to the last second included in the collapsed period. So, in order to collapse data for 2006 in the information base, you need to specify 12/31/2006 23:59:59 as the collapse date.

Number of lines in balance entry documents. This parameter determines the maximum possible number of lines in one document for entering balances. If the parameter is not filled in (equal to 0), then one document will be created for each register/account without limiting the number of lines.

2. At the second stage (second tab), it is determined which objects and for what period should be collapsed.
The following methods for processing objects are provided:

    1. Do not process - objects are not collapsed.
    2. To date - objects preceding the collapse date are collapsed.
    3. For period - all objects lying in the specified interval are collapsed.
    4. Clear - all objects preceding the rollup date are deleted, and balance entry documents are not created. The mode is available only for information registers.

Button "Fill in default settings" - documents and accumulation and accounting registers, periodic information registers (with the "adjustment of register entries" registrar) are collapsed to the date, periodic information registers without a registrar "adjustment of register entries" and non-periodic information registers are not collapsed

3. 3. At the third stage (on the third tab “Documents for entering balances”), documents for entering balances according to accumulation registers, information, and accounting will be generated. The created documents will be located in the next second after the rollup date, i.e. if the rollup date is 12/31/2006 23:59:59, then the documents will be created on 01/01/2007 00:00:00.

The documents “Adjustment of register entries” and “Operation (accounting and tax accounting)” are used as documents for entering balances.
To do this, you must successively click “Generate” and “Activate”.
Processing may take a long time to complete. After the database has been collapsed, it is strictly prohibited to make any changes or repost documents in the collapsed period.

In this article, we will consider step-by-step instructions for creating external processing in 1C 8.3 in managed application mode; accordingly, we will use managed forms. And most importantly, we will learn how to connect it to the mechanism of “external processing” of 1C configurations built on a library of standard subsystems version 2.0 and newer.

The task will be the following: to create the simplest external processing that will perform a group action on the “Item” directory, namely, set the selected VAT rate percentage for the specified group of items.

To do this, we will immediately make the necessary settings in the program (we are considering the 1C 8.3 configuration: “Enterprise Accounting 3.0” on managed forms).

Checking this box gives us the opportunity to use external processing.

Creating a new external processing in 1C 8.3 using an example

Now let's go to the configurator. In the "File" menu, select "New...". A window for selecting the type of file to be created will open. Select “External processing”:

A new external processing window will open. Let's give her a name right away. It will be offered when saving the processing to disk:

Let's add a new controlled processing form. We indicate that this is a form of processing and it is the main one:

We will have two details on the form:

  • Nomenclature group – link to the “Nomenclature” directory;
  • SelectVATRate – link to the transfer of the VAT Rate.

We create the details in the “Properties” column in the upper right window. Drag them with the mouse into the upper left window. The new details should immediately appear on the form below.

The order of details can be changed using the “Up” – “Down” arrows:

Get 267 video lessons on 1C for free:

All that remains is to add the “Install” button. In managed forms, you can't just add a button to the form. Even if you add it to the structure of form elements, it will not be visible on the form itself. The button must be associated with the command that it will execute. Go to the “Commands” tab and add the “Set VAT Rate” command. In the command properties, create an action. Select the command handler “On the client”. A command can also be added to the form by simply dragging it into the section with form elements.

A procedure of the same name will be created in the form module. In it we will call the procedure on the server:

&OnClient

Procedure Set VAT Rate (Command)

SetVATRateOnServer();

End of Procedure

In the procedure on the server, we will write a small request and actions related to setting the VAT rate:

&On server

Procedure SetVATRateOnServer()

Request = New Request;
Request.Text =
"CHOOSE
| Nomenclature.Link
|FROM
| Directory.Nomenclature AS Nomenclature
|WHERE
| Nomenclature.Link IN HIERARCHY (&Nomenclature Group)
| AND NOT Nomenclature.MarkDeletion
| AND NOT Nomenclature. This is a Group”;

Request.SetParameter("Item Group", Item Group);
ResRequest = Request.Execute();
SelectRecordDet = ResRequest.Select();

While SelectRecordDet.Next() Loop

Attempt
SprNomObject.Write();
Exception
Report("Error writing object """ + SprNomObject + """!
|» + DescriptionError());
EndAttempt;

EndCycle;

End of Procedure

We return to the “Form” tab, add a button to the form and associate it with the command:

As such, our processing is ready for use. To call it, in the “1C Enterprise” mode, you need to go to the “File” - “Open” menu and select the created file.

However, working in this mode is convenient for debugging processing, but is not entirely suitable for the user. Users are accustomed to having everything “at their fingertips,” that is, in the database itself.

This is what the “Additional reports and processing” section is for.

But in order to add our processing there, we must first give it a description and tell the program its properties.

Description of the function “Information about External Processing”

I will give an example of the contents of this function. It must be exportable and, accordingly, located in the processing module:

Function InformationOnExternalProcessing() Export

DataForReg = New Structure();
DataForReg.Insert("Name", "VAT rate setting");
DataForReg.Insert("SafeMode", True);
DataForReg.Insert("Version", "ver.: 1.001");
DataForReg.Insert("Information", "Processing for setting the VAT rate in the Nomenclature directory");
DataForReg.Insert("View", "AdditionalProcessing");

CommandTable = NewValueTable;
TabZnCommands.Columns.Add("Identifier");
TabZnCommands.Columns.Add("Usage");
TabZnCommands.Columns.Add("View");

NewRow = TabZnCommands.Add();
NewString.Identifier = "OpenProcessing";
NewRow.Use = "OpenForm";
NewRow.View = "Open processing";
DataForReg.Insert("Commands", TabZnCommands);

Return DataForReg;

EndFunction

To better understand which fields of the registration data structure need to be used, let’s look at the details of the “Additional reports and processing” directory:

As you can see, everything is quite simple. Only one attribute does not match: “Launch Option” – “Use”. If we look at the code of one of the common modules, we will see how a bunch of these fields arise:

To determine which fields of a structure are required, you can first not describe it, simply create an empty one, and then use the debugger. If you trace modules when registering processing, it becomes immediately clear which fields are required and which are not.

Connecting external processing in 1C 8.3

To work with external processing (and an external printing form is also an external processing), there is an object ExternalProcessing.

Let's consider two possible cases:

External processing is stored on disk separately from the infobase

To programmatically open external processing in 1C, you need to know the address of its file. Knowing it, you can either open a processing form or get a processing object to carry out further actions with it (for example, to call export functions from an object module).

Opening an external processing form

To programmatically open an external processing form in 1C, use the function GetForm() object ExternalProcessing. The function has several parameters. Consider a simple opening of the main processing form:


Form = ExternalProcesses. GetForm(FileAddress) ;
Form. Open();

To open a minor external processing form, you must specify its name.

//The FileAddress variable contains the full path to the external processing file
Form = ExternalProcesses. GetForm(FileAddress, "MinorForm") ;
Form. Open();

Opening external processing as an object

In order to receive external processing as an object, a function is used Create() object ExternalProcessing.

//The FileAddress variable contains the full path to the external processing file
ProcessingObject = ExternalProcessing. Create(FileAddress) ;

By default, all processing is opened in safe mode. To disable it, use the following options:

//The FileAddress variable contains the full path to the external processing file

External processing or printing form saved in infobase

In many configurations, it is possible to save external printed forms and processing directly in the infobase. For this purpose the reference book is used ExternalProcessing. The external processing itself is stored as binary data or in attributes StorageExternalProcessing, or in the tabular part Affiliation in the props StorageExternalProcessing.

To open external processing you need:

  1. Get it from storage.
  2. Save the processed file to disk.
  3. Open a form or get a processing object.
  4. If we are dealing with an external printed form, then we can fill in the standard details Object Reference and call the export function Seal.

//The RefLink variable contains a link to the ExternalProcessings directory element
DvData = RefLink. External Processing Storage. Get() ;
FileAddress = GetTemporaryFileName() ;
DvData. Write(FileAddress) ;
ProcessingObject = ExternalProcessing. Create(FileAddress, False) ;

Editor's Choice
In step-by-step instructions, we will look at how in 1C Accounting 8.3 accounting for finished products and costs for them is carried out. Before...

Usually, working with bank statements is configured automatically through the client-bank system, but there is the possibility of integrating client-bank and 1C...

When the duty of a tax agent is terminated in connection with the submission of information to the tax authorities about the impossibility of withholding personal income tax,...

Name: Irina Saltykova Age: 53 years old Place of birth: Novomoskovsk, Russia Height: 159 cm Weight: 51 kg Activities:...
Dysphoria is a disorder of emotional regulation, manifested by episodes of angry and melancholy mood, accompanied by...
You have entered into a relationship with a Taurus man, you feel strong sympathy for him, but it is too early to talk about love. Many women in...
Stones for the zodiac sign Libra (September 24 - October 23) The zodiac sign Libra represents justice, the kingdom of Themis (second wife...
Eating deliciously and losing weight is real. It is worth including lipotropic products in the menu that break down fats in the body. This diet brings...
Anatomy is one of the oldest sciences. Already primitive hunters knew about the position of vital organs, as evidenced by...