the Internet Windows Android

We will fill in the table part. How to get the current line of tabular part

In this article, consider the process of writing the simplest external processing fill table part in 1C 8. For configurations using normal app. For example, take such a task: "In the configuration 1C: Accounting 2.0 Create external folding of table part Productsdocument Realization of goods and services, Data for filling to take from tabular part Products document Admission of goods and services". In this way, we need to fill out sales products on the basis of goods receipt, such a task is quite often found in the real practice of the programmer 1C.

2. Creating external processing

Go to B. 1C 8. In mode Configurator. Using the menu File -\u003e New or pictogram new document create new external processing.

In field Name We indicate: "simplest reclocution" and keep the external processing on hDD Using the menu File -\u003e Save or pictogram Save or key combination Ctrl + S..

Highlighting a branch Requisites In the processing metadata tree and pressing the button Add(Button with green plus) Create a new props of external processing - Document pay, choose a type for it DOCUMENTS DROVERNIK. BY DUTENIETETOVARYAVSHODSHUG, this props need to select the document Admission of goods and services, on the basis of which the implementation will be filled.

To select an admission document, we will need a separate form. Highlighting a branch Forms and using the same button - Add Create an external processing form. The form constructor window opens, you do not need to do any changes on the first page of the designer, so you just click the button Further.

On the second page of the designer, we need to choose the props Document pay(so that he appeared on created form) and click the button Ready.

After that, the created form will open, we need that the user would choose the document on it, and closed it. So when you press the button Perform The form must simply close. In order to implement this, select the button PerformI click on it right mouse button and choose the item Properties. In the properties of the button, in the string Act Choose action - Close. On this work with the form is completed, closing it.

3. Programming

We will proceed to programming the processing of the tabular part. Let's go to Object moduleexternal processing (on the bottom of the processing panel button Actions -\u003e Open object module).

In it, we need to create an export procedure. Initialize.

Procedure Initialize Export Extrudresses

note that procedure Initialize, as well as all its parameters, are mandatory for external processing of the filling tabular partIf you do not create it or do not specify all the parameters, your processing simply will not work.

Now let's start writing a program code. First, create a variable for the tabular part of the document. Realization of goods and serviceswhich we will fill out.

Watchboard \u003d object [NameTagged];

When performing the procedure in the parameter An object will contain an object of the document that we fill, and in the parameter NameTablished A string with the name of the tabular part that we fill. Thus, this line of code receives the tabular part of the filled document by its name.

We need to choose the user to select the document Admission of goods and services, Therefore, write the code for opening the form of document selection. To begin with, we get this form into a variable using the external processing method. Optional (<Форма>, <Владелец>, <КлючУникальности>) . We just fill out only the first parameter of this method, passing there a string named our form.

FormAvailability / Access \u003d Options ("Form");

Now open the resulting form using the modal opening (until the form is open all the other 1c windows are not available), because with this method of opening the future our code in the procedure Initialize It will not be executed until the user closes the form.

FormAllustration of complaining. OpenModally ();

After the user closes the form, we need to check whether the requisition is filled Document pay(In case the receipt document was not selected). If after checking Document pay It turns out to be empty, then further processing does not make sense, and it should be interrupted.

If you are not denominated (DocumentAmpsion) then to report (); Refund; Ended;

To verify the completion of the props, the global context function is used here. Document is filled (<Значение>) , it checks whether the value is transmitted in the default value of the same type. Procedure To report Displays the specified text in the 1C 8 message window. Keyword Return Interrupts the execution of the procedure.

We will start writing a query that will select data tabular Products document Admission of goods and services. Create a new request:

Request \u003d new request;

Request. Installation parameter ( "DocumentAmpsion", DocumentAmpsion);

Write the text of the request, we will do it with Designer query. It is not recommended to write the text of the query text manually, it is not effective and takes a bunch of time. To begin with, write a string:

Request.text \u003d "";

We will deliver the cursor between the characters of the quotes, click the right mouse button and select item Request Designer .... After that, a proposal will appear to create a new request, click the "OK" button. The designer window opens, all available database tables are located in the left part, we need a document Adaitetovarov Supervug. We will find it and reveal using the "+" symbol, select the tabular part Products and pulling it into the second part of the designer screen, which is called Tables(Also, move the desired table using the "\u003e" button).

Now reveal the "+" table we chose ( AdaitovyovarovyovServyvaryovas) and drag the fields necessary for our fill in the third part of the designer screen, which is called - Field. You will not choose all available fields, we will restrict ourselves to such a set: Nomenclature, number, price, amount, StavanS, Summands.

Since we need data for only one admission document (which we chose before filling), then in the "Conditions" tab, we will put the condition for the document link using the parameter transferred by us.

Creating a query text in the designer on this is complete, click the "OK" button. As a result, we turned out the following query text:

Request.text \u003d "Select | From | Where;

The created request remains only to perform and unload to the variable:

Result \u003d query. Fill (). Unload ();

In a variable Result Stored table of values \u200b\u200bwith rows of tabular part Products We have chosen documents Admission of goods and services. Now you can start filling out the tabular part Products Our implementation. But before you fill out the data, it should be cleaned, in the case there are already some lines.

Watchchast.Inter ();

With cycle For each Walk the table of values \u200b\u200bwith the query results.

For each element resulting from the result cycle of the endCycle;

In this cycle, create and fill in the string of the table part of the document Realization of goods and services. Create a new string We can with a variable Circuit partsThrough which you can make any actions with it.

NEWSTROCATCH \u003d WATCH CHAIN. Add ();

Fill the created tab of the tab. Parts of data from the query result string using the procedure Global Context - Filling out (<Приемник>, <Источник>) .

Filling out (newstock, elementural results);

But the data completed by us is not enough, so that the document would be done, you must fill out more accounting accounts Nomenclature. To do this, we use export

procedure FILLINGSETHETATINGS MANAGEMENTS from the document object module Realization of goods and services. Call it using the parameter An object(It should be noted,

what can we call only export Procedures from the module of the document object).

Object. Requirementsetsetting (newstrokatch, name data, truth);

On this programming of the table part for 1C 8. Completed. Processing can be used. Full text of the procedure Initialize, looks like that:

Procedure Initialize (Object, nameThe name \u003d undefined, TablePole \u003d Uncertain) Export Watchboard \u003d object [NameTagged]; FormAvailability / Access \u003d Options ("Form"); FormAllustration of complaining. OpenModally (); If it is not denominated (DocumentPlease) then to report ( "Not selected document receipt"); Refund; Ended; Request \u003d new request; Request. Installation parameter ( "DocumentAmpsion", DocumentAmpsion); Request.text \u003d "Select | Adamitiovarovarovyovyovariovari.Nanklatura, | Adamitiovarovarovyovyovyovari. Number, | Adamitetovarovyovyovyovarsa.Stavankands, | Adamitetovarovyovyovyovarsi.Summa, | Adamitetovarovyovyovyovaryovas.Summands, | Adamitiovarovarovyovyovyovari.zena | Is | Document. Not Dumstive Tovarovyvug.Thovarsa as admiretovarovasculators. | Where | Promplementovarovarovyovyovyovars.Link \u003d & DocumentAmpsions "; Result \u003d query. Fill (). Unload (); Watchchast.Inter (); For each element result from the result, the cycle of a new-frame \u003d clique list. Addly (); Filling out (newstock, elementural results); Object. Requirementsetsetting (newstrokatch, name data, truth); EndCycle; Extrudresses

In the next part, it will be described how to debug the processing of filling the tabular part and how to connect it to the document.

4. Debugging

Quite often to debug the code you write. In order to debug the processing of filling out the tabular part in 1C 8. Create it props Link Object Type Document roll.realizationSerovyovSerg.

It is necessary for us in order to choose a document of implementation when debugging, which we will fill out. Next, you need to create a debug form and accommodate the requisite created there. Link ObjectThe process of creating the debug form does not differ from the creation of the form of selection of the document of the receipt, so we will not stop in detail on it.

After the form is created, we turn into its module. We will find an automatically created procedure Advanced button. This procedure manages when the button is pressed Perform. Call from it the procedure Initializewhich is in the processing module, in the parameters will give the document object Realization of goods and services(which we get from the requisite Link Object) and the string with the title table part (in our case Products).

Procedure Fill button (button) Initialize (reflecting object. PREPARY OBJECT (), "Goods"); Extrudresses

Now it is necessary to make the created form of the main form of processing. To do this, choose it in the "Processing form" field.

Now you can put a breakpoint in the right place of procedure. Initialize or procedures Advanced button Debugging forms, and run the processing of filling tabular part in debug mode 1C: Enterprises.

5. Connect to the document

After the filling processing is written and debugged should be connected to the document from which it will be performed. To do this go to 1C 8. In mode Companymoving in the menu Service -\u003e Additional reports and processing -\u003e additional external processing table portions And add new element Director. Using the button Replace external file Add a file created by us to fill out the tabular part.

Fill the processing belonging, to do this, using the button Selection Choose a document Realization of goods and services

And specify that the filling is intended for the table part Products.

Press the button OK And on this all, the filling processing will be available in the menu Fill tabular Products document Realization of goods and services. Download the processing used for this example you can at the bottom of the article.

1. Statement of the task

In this article, consider the process of writing the simplest external processing of the filling tabular part in 1C 8. For configurations using the usual application. For example, take such a task: "In the configuration 1C: Accounting 2.0 Create external folding of table part Products document, data for filling take from tabular part Products document Admission of goods and services". In this way, we need to fill out sales products on the basis of goods receipt, such a task is quite often found in the real practice of the programmer 1C.

2. Creating external processing

Go to B. 1C 8. In mode Configurator. Using the menu File -\u003e New or pictogram new document Create new external processing.

In field Name We specify: "simplest reclocution" and save external processing on the hard disk using the menu File -\u003e Save or pictogram Save or key combination Ctrl + S..

Highlighting a branch Requisites In the processing metadata tree and pressing the button Add(Button with green plus) Create a new props of external processing - Document pay, choose a type for it DOCUMENTS DROVERNIK. BY DUTENIETETOVARYAVSHODSHUG, this props need to select the document Admission of goods and services, on the basis of which the implementation will be filled.

To select an admission document, we will need a separate form. Highlighting a branch Forms and using the same button - Add Create an external processing form. The form constructor window opens, you do not need to do any changes on the first page of the designer, so you just click the button Further.

On the second page of the designer, we need to choose the props Document pay(In order for it to appear on the form created) and click the button Ready.

After that, the created form will open, we need that the user would choose the document on it, and closed it. So when you press the button Perform The form must simply close. In order to implement this, select the button PerformI click on it right mouse button and choose the item Properties. In the properties of the button, in the string Act Choose action - Close. On this work with the form is completed, closing it.

3. Programming

We will proceed to programming the processing of the tabular part. Let's go to Object module external processing (on the bottom of the processing panel button Actions -\u003e Open object module).

In it, we need to create an export procedure. Initialize.

Procedure Initialize Export Extrudresses

note that procedure Initialize, as well as all its parameters, are mandatory for external processing of the filling tabular partIf you do not create it or do not specify all the parameters, your processing simply will not work.

Now let's start writing a program code. First, create a variable for the tabular part of the document. Realization of goods and serviceswhich we will fill out.

Watchboard \u003d object [NameTagged];

When performing the procedure in the parameter An object will contain an object of the document that we fill, and in the parameter NameTablished A string with the name of the tabular part that we fill. Thus, this line of code receives the tabular part of the filled document by its name.

We need to choose the user to select the document Admission of goods and services, Therefore, write the code for opening the form of document selection. To begin with, we get this form into a variable using the external processing method. Optional (<Форма>, <Владелец>, <КлючУникальности>) . We just fill out only the first parameter of this method, passing there a string named our form.

FormAvailability / Access \u003d Options ("Form");

Now open the resulting form using the modal opening (until the form is open all the other 1c windows are not available), because with this method of opening the future our code in the procedure Initialize It will not be executed until the user closes the form.

FormAllustration of complaining. OpenModally ();

After the user closes the form, we need to check whether the requisition is filled Document pay(In case the receipt document was not selected). If after checking Document pay It turns out to be empty, then further processing does not make sense, and it should be interrupted.

If you are not denominated (DocumentAmpsion) then to report (); Refund; Ended;

To verify the completion of the props, the global context function is used here. Document is filled (<Значение>) , it checks whether the value is transmitted in the default value of the same type. Procedure To report Displays the specified text in the 1C 8 message window. Keyword Return Interrupts the execution of the procedure.

We will start writing a query that will select data tabular Products document Admission of goods and services. Create a new request:

Request \u003d new request;

Request. Installation parameter ( "DocumentAmpsion", DocumentAmpsion);

Write the text of the request, we will do it with Designer query. It is not recommended to write the text of the query text manually, it is not effective and takes a bunch of time. To begin with, write a string:

Request.text \u003d "";

We will deliver the cursor between the characters of the quotes, click the right mouse button and select item Request Designer .... After that, a proposal will appear to create a new request, click the "OK" button. The designer window opens, all available database tables are located in the left part, we need a document Adaitetovarov Supervug. We will find it and reveal using the "+" symbol, select the tabular part Products and pulling it into the second part of the designer screen, which is called Tables(Also, move the desired table using the "\u003e" button).

Now reveal the "+" table we chose ( AdaitovyovarovyovServyvaryovas) and drag the fields necessary for our fill in the third part of the designer screen, which is called - Field. You will not choose all available fields, we will restrict ourselves to such a set: Nomenclature, number, price, amount, StavanS, Summands.

Since we need data for only one admission document (which we chose before filling), then in the "Conditions" tab, we will put the condition for the document link using the parameter transferred by us.

Creating a query text in the designer on this is complete, click the "OK" button. As a result, we turned out the following query text:

Request.text \u003d "Select | From | Where;

The created request remains only to perform and unload to the variable:

Result \u003d query. Fill (). Unload ();

In a variable Result Stored table of values \u200b\u200bwith rows of tabular part Products We have chosen documents Admission of goods and services. Now you can start filling out the tabular part Products Our implementation. But before you fill out the data, it should be cleaned, in the case there are already some lines.

Watchchast.Inter ();

With cycle For each Walk the table of values \u200b\u200bwith the query results.

For each element resulting from the result cycle of the endCycle;

In this cycle, create and fill in the string of the table part of the document Realization of goods and services. Create a new string We can with a variable Circuit partsThrough which you can make any actions with it.

NEWSTROCATCH \u003d WATCH CHAIN. Add ();

Fill the created tab of the tab. Parts of data from the query result string using the procedure Global ContextFilling out (<Приемник>, <Источник>) .

Filling out (newstock, elementural results);

But the data completed by us is not enough, so that the document would be done, you must fill out more accounting accounts Nomenclature. To do this, we use export

procedure FILLINGSETHETATINGS MANAGEMENTS from the document object module Realization of goods and services. Call it using the parameter An object(It should be noted,

what can we call only export Procedures from the module of the document object).

Object. Requirementsetsetting (newstrokatch, name data, truth);

On this programming of the table part for 1C 8. Completed. Processing can be used. Full text of the procedure Initialize, looks like that:

Procedure Initialize (Object, nameThe name \u003d undefined, TablePole \u003d Uncertain) Export Watchboard \u003d object [NameTagged]; FormAvailability / Access \u003d Options ("Form"); FormAllustration of complaining. OpenModally (); If it is not denominated (DocumentPlease) then to report ( "Not selected document receipt"); Refund; Ended; Request \u003d new request; Request. Installation parameter ( "DocumentAmpsion", DocumentAmpsion); Request.text \u003d "Select | Adamitiovarovarovyovyovariovari.Nanklatura, | Adamitiovarovarovyovyovyovari. Number, | Adamitetovarovyovyovyovarsa.Stavankands, | Adamitetovarovyovyovyovarsi.Summa, | Adamitetovarovyovyovyovaryovas.Summands, | Adamitiovarovarovyovyovyovari.zena | Is | Document. Not Dumstive Tovarovyvug.Thovarsa as admiretovarovasculators. | Where | Promplementovarovarovyovyovyovars.Link \u003d & DocumentAmpsions "; Result \u003d query. Fill (). Unload (); Watchchast.Inter (); For each element result from the result, the cycle of a new-frame \u003d clique list. Addly (); Filling out (newstock, elementural results); Object. Requirementsetsetting (newstrokatch, name data, truth); EndCycle; Extrudresses

In the next part, it will be described how to debug the processing of filling the tabular part and how to connect it to the document.

4. Debugging

Quite often to debug the code you write. In order to debug the processing of filling out the tabular part in 1C 8. Create it props Link Object Type Document roll.realizationSerovyovSerg.

It is necessary for us in order to choose a document of implementation when debugging, which we will fill out. Next, you need to create a debug form and accommodate the requisite created there. Link ObjectThe process of creating the debug form does not differ from the creation of the form of selection of the document of the receipt, so we will not stop in detail on it.

After the form is created, we turn into its module. We will find an automatically created procedure Advanced button. This procedure manages when the button is pressed Perform. Call from it the procedure Initializewhich is in the processing module, in the parameters will give the document object Realization of goods and services(which we get from the requisite Link Object) and the string with the title table part (in our case Products).

Procedure Fill button (button) Initialize (reflecting object. PREPARY OBJECT (), "Goods"); Extrudresses

Now it is necessary to make the created form of the main form of processing. To do this, choose it in the "Processing form" field.

Now you can put a breakpoint in the right place of procedure. Initialize or procedures Advanced button Debugging forms, and run the processing of filling tabular part in debug mode 1C: Enterprises.

5. Connect to the document

After the filling processing is written and debugged should be connected to the document from which it will be performed. To do this go to 1C 8. In mode Companymoving in the menu Service -\u003e Additional reports and processing -\u003e Additional external processing of table parts And add a new element of the reference book. Using the button Replace external file Add a file created by us to fill out the tabular part.

Fill the processing belonging, to do this, using the button Selection Choose a document Realization of goods and services

And specify that the filling is intended for the table part Products.

Press the button OK And on this all, the filling processing will be available in the menu Fill tabular Products document Realization of goods and services. Download the processing used for this example you can by.

Table parts exist in many objects in 1C:

  • Directories
  • Documentation
  • Reports and processing
  • Account plans
  • Features of characteristics
  • Plans for species calculation
  • Business processes and tasks

Table parts allow you to store an unlimited number of structured information belonging to one object.

Consider some work techniques with tabular parts.

How to get around the table part

You can use a cycle to climb a tabular part. For each

For each row from the circuit value cycle

Report (row. Requisite);

EndCycle;

On each iteration in the variable Linethe next line of tabular part is passed. Values \u200b\u200bof the row values \u200b\u200bcan be obtained by expression String. Employment.

How to get and bypass selected lines of tabular part

To display information from the table part of the object is the form element Table field. To enable multiple rows, you need to set the value on the table field. Multiple His feature Selection mode.

To get a list of selected rows, the following code is used:

In order to circumvent allocated strings use cycle For each:

Allocated tests \u003d elementforms. NameTablichnogopol. Allocated;

For each row from highlighted cycle

// Content cycle

EndCycle;

How to programmatically highlight the rows of the tabular part (tabular field) and remove the selection

To programmatically remove the highlighting line of the table field:

Elementforms. NameTablichnogopol. Separate. Clear ();

To programmatically allocate all rows of the table field:

For each current out of the circuit value cycle
Elementforms. NameTablichnogopol. Distributed. Add (current);
EndCycle;

How to Clean Table Part

Chalk. Clear ();

How to get the current line of tabular part

The current line is a period in which the user at the moment is the cursor. To get it, you need to refer to the element of control on the form, which is associated with the tabular part.

For conventional forms, the code will look like this:

Elementforms. NameTablichnogopol. Fluid;

For managed forms:

Elements. NameTablichnogopol. Fluid;

How to add a new string to the table part

Adding a new string to the end of the table part:

Newstock \u003d challenge. Add ();

Adding a new line to any place of tabular part (subsequent lines will be shifted):

Newstock \u003d challenge. Insert (index)
// Index - the number of the row added. Row numbering starts from scratch.

New line. Requisite1 \u003d "value";

How to programmatically fill out the details of the table part

If you need to programmatically fill out the details of the tabular part of the table, which the user adds, you must use the event handler of the tabular part Institution.

The procedure created by the handler has three parameters:

  • Element - Contains controls Table top.
  • New line- Boolevo. Contains value Trueif added new line tabular part and False,if the user began to edit already existing string.
  • Copy - Boolevo. Contains value Trueif the user copies the string and False in other cases.

Consider an example. Suppose we need to fill the props tabular part ControlIn the case when a new line is added. When editing an existing string, you do not need to change account account.

Procedure for timbanity processingRodata (element, newstream, copying)

// If the user edits an existing string, do not do anything
If not new
Return;
Ended;

// If the string is new, set the account of the account
Text \u003d element. Fluid; // received the current line of the tabular part
Trektroke. Accounting \u003d plans. Hoshorty. Needed;
Extrudresses