Data Composition System Expression Language (1Cv8). Data composition system expression language (1Cv8) 1c custom expression field

We examined in some detail the settings of reports implemented on the basis of the access control system. Now let's look at more subtle and detailed settings for report options. The window for “advanced” settings of the report option is called by the command “More” - “Other” - “Change report option”.

The window for changing the report version is divided into two parts:

1. Report structure.

2. Report settings.


The report option structure section is similar to the “Structure” tab of the standard report settings. The purpose and configuration of groupings is discussed in detail in Part 1 of the article.

The report variant structure table, in addition to the actual column with groupings, contains several additional columns:

The report option settings section gives the user ample opportunities to configure the report to suit their needs. It almost completely coincides with the standard report settings discussed in Part 1. Let’s look at all the tabs of the section and note the differences.

The settings section consists of the following tabs:

1. Parameters. Contains ACS parameters available to the user.

The SKD parameter is a value used to obtain report data. This can be a condition value for selecting or checking data, as well as an auxiliary value.


The parameter table is presented in the “Parameter” - “Value” format. If necessary, you can change the parameter values. Clicking the “Custom Settings Element Properties” button opens the custom settings of the element.


In this window, you can select whether the element will be included in the user settings (that is, visible to the user when setting up a report), set the element's presentation and editing mode (quick access in the report header, normal in the report settings, and inaccessible).

Custom settings item properties also have groupable fields, margins, selections, and conditional appearance elements.

2. Custom fields. Contains fields that are generated by the user himself based on the data selected by the report.


The user can add two types of fields:

  • New selection field...
  • New expression field...

Selection fields allow you to calculate a value based on a given condition. The selection field editing window contains a field title and a table in which the selection, value and presentation of the field are specified. Selection is a condition, depending on which the desired value will be substituted.


For example, let's calculate an estimate of the number of sales. We will assume that if less than 10 units of a product are sold, we sold a little, and if more than 10 units, we sold a lot. To do this, we will set 2 values ​​for the calculated field: the first will be with the selection “Number of goods Less than or equal to “10””, the second with the selection “Number of goods Greater than “10””.

Expression fields allow you to calculate a value using arbitrary algorithms. They can use the functions of the query language and the built-in 1C programming language. The expression field editing window contains two fields for expressions of detailed and summary records. Total records are groupings configured in the “Report Structure” area; they must use aggregate functions (“Sum”, “Minimum”, “Maximum”, “Quantity”).

For example, let's calculate the average discount percentage. The average discount percentage is calculated using the formula: [Sales amount without discount] - [Sales amount with discount] / [Sales amount without discount]. It is important to remember that the sales amount without a discount may be zero, so we use the SELECT operator to check. We get the following expressions:

· For detailed entries:

Choice

When [Sales amount without discount] = 0

Then 0

Otherwise [Sales amount without discount] - [Sales amount with discount] / [Sales amount without discount]

End

· For summary records:

Choice

When Amount([Sales amount without discount]) = 0

Then 0

Otherwise Sum([Sales amount without discount]) - Sum([Sales amount with discount]) / Sum([Sales amount without discount])

End

As mentioned earlier, in the expression of total records we use the aggregate function “Sum”.

3. Groupable fields. Contains fields by which the results of the report variant will be grouped. Grouped fields are configured separately for each grouping, but you can set general grouped fields for a report option if you select the “Report” root in the structure tree. You can add a field from the report result, a custom field, or select an auto field, then the system will select the fields automatically. This tab also allows you to change the order of grouped fields.


4. Fields. Contains the fields that will be output as a result of the report variant. Fields are configured separately for each grouping, but you can set common fields for a report option if you select the root “Report” in the structure tree. You can add a field from the report result, a custom field, or select an auto field, then the system will select the fields automatically. This tab also allows you to change the order of the fields.

Fields can be grouped to logically highlight any part of the report or to specify a special arrangement of columns. When adding a group, the “Location” column becomes active and allows you to select one of the location options:

  • Auto - the system places fields automatically;
  • Horizontal - fields are positioned horizontally;
  • Vertical - fields are arranged vertically;
  • In a separate column - fields are located in different columns;
  • Together - the fields are located in one column.


5. Selection. Contains selections used in the report variant. Setting up selections was discussed in detail in part 1 of this article. Filters are configured separately for each grouping, but you can set general filters for a report option if you select the root “Report” in the structure tree.


6. Sorting. Contains the sort fields used in the report variant. Setting up sort fields was discussed in detail in Part 1 of this article. Sorting is configured separately for each grouping, but you can set general sorting fields for a report option if you select the root “Report” in the structure tree.


7. Conditional registration. Contains conditional design elements used in the report variant. Setting up conditional appearance was discussed in detail in Part 1 of this article. Conditional appearance is configured separately for each grouping, but you can set general elements of conditional appearance for a report option if you select the root “Report” in the structure tree.


8. Additional settings. Contains additional report design settings. Allows you to select the general appearance of the report, the location of fields, groupings, details, resources, totals, set chart settings, control the display of the title, parameters and selection, determine the position of resources and fix the header and grouping columns of the report version.


In conclusion, I would like to note that report settings can not only be saved as a report option, but also uploaded to a file (menu “More” - “Save settings”). To download, you must select “Load settings” and select the saved file. Thus, we can transfer report variant settings between different databases that have the same configuration.


Based on this, we can summarize that the user can not only independently customize the report to suit his needs, but also save his settings and use them in the future if necessary.

Data Composition System Expression Language

The data composition system expression language is designed to write expressions used in various parts of the system.

Expressions are used in the following subsystems:

  • data layout diagram - to describe calculated fields, total fields, connection expressions, etc.;
  • data layout settings - to describe custom field expressions;
  • data layout layout - for describing expressions for connecting data sets, describing layout parameters, etc.

Literals

The expression may contain literals. The following types of literals are possible:

  • Line;
  • Number;
  • Date of;
  • Boolean.

Line

A string literal is written in “” characters, for example:

“String literal”

If you need to use the “” character inside a string literal, you should use two such characters.

For example:

“Literal ““in quotes”““

Number

The number is written without spaces, in decimal format. The fractional part is separated using the "." symbol. For example:

10.5 200

date

A date literal is written using the key literal DATETIME. After this keyword, the year, month, day, hours, minutes, seconds are listed in parentheses, separated by commas. Time specification is not required.

For example:

DATETIME(1975, 1, 06) – January 6th, 1975 DATETIME(2006, 12, 2, 23, 56, 57) – December 2nd, 2006, 23 hours 56 minutes 57 seconds, 23 hours 56 minutes 57 seconds

Boolean

Boolean values ​​can be written using the literals True (True), False (False).

Meaning

To specify literals of other types (system enumerations, predefined data), the keyword Value is used, followed by the name of the literal in parentheses.

Value(AccountType. Active)

Operations on numbers

Unary –

This operation is intended to change the sign of a number to the opposite sign. For example:

Sales.Quantity

Unary +

This operation does not perform any actions on the number. For example:

Sales.Quantity

Binary -

This operation is intended to calculate the difference of two numbers. For example:

ResidualsAndTurnovers.InitialRemaining – RemainingsAndTurnovers.FinalResidualsRemainingsAndTurnovers.InitialRemaining - 100 400 – 357

Binary +

This operation is designed to calculate the sum of two numbers. For example:

RemainingsAndTurnover.InitialRemaining + RemainingAndTurnover.Turnover ResiduesAndTurnover.InitialRemaining + 100 400 + 357

Work

This operation is designed to calculate the product of two numbers. For example:

Nomenclature.Price * 1.2 2 * 3.14

Division

This operation is designed to obtain the result of dividing one operand by another. For example:

Nomenclature.Price / 1.2 2 / 3.14

Remainder of the division

This operation is designed to obtain the remainder when one operand is divided by another. For example:

Nomenclature. Price % 1.2 2 % 3.14

String Operations

Concatenation (Binary +)

This operation is designed to concatenate two strings. For example:

Nomenclature.Article + “: ”+ Nomenclature.Name

Like

This operation checks whether the string matches the passed pattern.

The value of the LIKE operator is TRUE if the value<Выражения>satisfies the pattern, and FALSE otherwise.

The following characters in<Строке_шаблона>have a meaning different from just another character in the line:

  • % - percentage: a sequence containing zero or more arbitrary characters;
  • _ - underscore: one arbitrary character;
  • […] - one or more characters in square brackets: one character, any of those listed inside the square brackets. The enumeration may contain ranges, for example a-z, meaning an arbitrary character included in the range, including the ends of the range;
  • [^...] - in square brackets a negation icon followed by one or more characters: any character except those listed after the negation icon;

Any other symbol means itself and does not carry any additional load. If one of the listed characters needs to be written as itself, then it must be preceded by<Спецсимвол>, specified after the SPECIAL CHARACTER keyword (ESCAPE).

For example, template

“%ABV[abvg]\_abv%” SPECIAL CHARACTER “\”

means a substring consisting of a sequence of characters: the letter A; letters B; letters B; one digit; one of the letters a, b, c or d; underscore; letters a; letters b; letters v. Moreover, this sequence can be located starting from an arbitrary position in the line.

Comparison Operations

Equals

This operation is intended to compare two operands for equality. For example:

Sales.Counterparty = Sales.NomenclatureMainSupplier

Not equal

This operation is intended to compare two operands for inequality. For example:

Sales.Counterparty<>Sales.NomenclatureMainSupplier

Less

This operation is designed to check that the first operand is less than the second. For example:

SalesCurrent.Amount< ПродажиПрошлые.Сумма

More

This operation is designed to check that the first operand is greater than the second. For example:

SalesCurrent.Sum > SalesPast.Sum

Less or equal

This operation is designed to check that the first operand is less than or equal to the second. For example:

SalesCurrent.Amount<= ПродажиПрошлые.Сумма

More or equal

This operation is designed to check that the first operand is greater than or equal to the second. For example:

SalesCurrent.Amount >= SalesPast.Amount

Operation B

This operation checks for the presence of a value in the passed list of values. The result of the operation will be True if the value is found, or False otherwise. For example:

Item B (&Product1, &Product2)

Operation of checking the presence of a value in a data set

The operation checks for the presence of a value in the specified data set. The validation dataset must contain one field. For example:

Sales. Counterparty To Counterparties

Operation of checking a value for NULL

This operation returns True if the value is NULL. For example:

Sales.Counterparty IS NULL

Operation of checking a value for NULL inequality

This operation returns True if the value is not NULL. For example:

Sales. Counterparty IS NOT NULL

Logical operations

Logical operations accept expressions of type Boolean as operands.

Operation NOT

The NOT operation returns True if its operand is False and False if its operand is True. For example:

NOT Document.Consignee = Document.Consignor

Operation I

The AND operation returns True if both operands are True, and False if one of the operands is False. For example:

Document.Consignee = Document.Consignor AND Document.Consignee = &Counterparty

OR operation

The OR operation returns True if one of its operands is True, and False if both operands are False. For example:

Document.Consignee = Document.Consignor OR Document.Consignee = &Counterparty

Aggregate functions

Aggregate functions perform some action on a set of data.

Sum

The Sum aggregate function calculates the sum of the values ​​of the expressions passed to it as an argument for all detail records. For example:

Amount(Sales.AmountTurnover)

Quantity

The Count function calculates the number of values ​​other than NULL. For example:

Quantity(Sales.Counterparty)

Number of different

This function calculates the number of distinct values. For example:

Quantity(Various Sales.Counterparty)

Maximum

The function gets the maximum value. For example:

Maximum(Remaining.Quantity)

Minimum

The function gets the minimum value. For example:

Minimum(Remaining.Quantity)

Average

The function gets the average of non-NULL values. For example:

Average(Remaining.Quantity)

Other operations

Operation SELECT

The Select operation is intended to select one of several values ​​when certain conditions are met. For example:

Select When Amount > 1000 Then Amount Otherwise 0 End

Rules for comparing two values

If the types of the values ​​being compared are different from each other, then the relationships between the values ​​are determined based on the precedence of the types:

  • NULL (lowest);
  • Boolean;
  • Number;
  • Date of;
  • Line;
  • Reference types

The relationships between different reference types are determined based on the reference numbers of the tables corresponding to a particular type.

If the data types are the same, then the values ​​are compared according to the following rules:

  • for the Boolean type the value TRUE is greater than the value FALSE;
  • the Number type has the usual comparison rules for numbers;
  • for the Date type, earlier dates are smaller than later ones;
  • for the String type - comparison of strings in accordance with the established national characteristics of the database;
  • reference types are compared based on their values ​​(record number, etc.).

Working with NULL Value

Any operation in which one of the operands is NULL will produce a NULL result.

There are exceptions:

  • The AND operation will return NULL only if none of the operands is False;
  • The OR operation will only return NULL if none of its operands are True.

Operation priorities

The operations have the following priorities (the first line has the lowest priority):

  • B, IS NULL, IS NOT NULL;
  • =, <>, <=, <, >=, >;
  • Binary +, Binary – ;
  • *, /, %;
  • Unary +, Unary -.

Data Composition System Expression Language Functions

Calculate

The Calculate function is designed to calculate an expression in the context of a certain grouping. The function has the following parameters:

  • Expression. Type String. Contains a calculated expression;
  • Grouping. Type String. Contains the name of the grouping in the context of which the expression is to be evaluated. If an empty string is used as the grouping name, the calculation will be performed in the context of the current grouping. If the GrandTotal string is used as the group name, the calculation will be performed in the context of the grand total. Otherwise, the calculation will be performed in the context of the parent group with the same name. For example:
Sum(Sales.SumTurnover) / Calculate("Sum(Sales.SumTurnover)", "Total")

In this example, the result will be the ratio of the amount for the "Sales.AmountTurnover" field of the grouping record to the amount of the same field in the entire layout.

Level

The function is designed to obtain the current recording level.

Level()

NumberInOrder

Get the next sequence number.

NumberByOrder()

NumberInOrderInGrouping

Returns the next ordinal number in the current grouping.

NumberByOrderInGroup()

Format

Get a formatted string of the passed value.

The format string is set in accordance with the 1C:Enterprise format string.

Options:

  • Meaning;
  • Format string.

Format(Invoices.Doc Amount, "NPV=2")

Beginning of period

Options:

    • Minute;
    • Day;
    • A week;
    • Month;
    • Quarter;
    • Decade;
    • Half year.

StartPeriod(DateTime(2002, 10, 12, 10, 15, 34), "Month")

Result:

01.10.2002 0:00:00

End of Period

The function is designed to extract a specific date from a given date.

Options:

  • Date of. Type Date. Specified date;
  • Period type. Type String. Contains one of the following values:
    • Minute;
    • Day;
    • A week;
    • Month;
    • Quarter;
    • Decade;
    • Half year.

EndPeriod(DateTime(2002, 10, 12, 10, 15, 34), "Week")

Result:

13.10.2002 23:59:59

AddToDate

The function is designed to add a certain value to a date.

Options:

  • Magnification type. Type String. Contains one of the following values:
    • Minute;
    • Day;
    • A week;
    • Month;
    • Quarter;
    • Decade;
    • Half year.
  • Amount – by how much you need to increase the date. Type Number. The fractional part is ignored.

AddToDate(DateTime(2002, 10, 12, 10, 15, 34), "Month", 1)

Result:

12.11.2002 10:15:34

Date Difference

The function is designed to get the difference between two dates.

Options:

  • Expression. Type Date. Original date;
  • Expression. Type Date. Subtracted date;
  • Difference type. Type String. Contains one of the following values:
    • Second;
    • Minute;
    • Day;
    • Month;
    • Quarter;

DATEDIFFERENCE(DATETIME(2002, 10, 12, 10, 15, 34), DATETIME(2002, 10, 14, 9, 18, 06), "DAY")

Result:

Substring

This function is designed to extract a substring from a string.

Options:

  • Line. Type String. The string from which the substring is extracted;
  • Position. Type Number. The position of the character from which the substring to be extracted from the string begins;
  • Length. Type Number. Length of the allocated substring.

SUBSTRING(Accounts.Address, 1, 4)

Line Length

The function is designed to determine the length of a string.

Parameter:

  • Line. Type String. A string whose length is determined.

Line(Counterparties.Address)

Year

This function is designed to extract the year from a Date type value.

Parameter:

  • Date of. Type Date. The date by which the year is determined.

YEAR(Expense.Date)

Quarter

This function is designed to extract the quarter number from a Date type value. The quarter number normally ranges from 1 to 4.

Parameter

  • Date of. Type Date. The date by which the quarter is determined
QUARTER(Expense.Date)

Month

This function is designed to extract the month number from a Date type value. The month number normally ranges from 1 to 12.

  • Date of. Type Date. The date by which the month is determined.
MONTH(Expense.Date)

Day of the Year

This function is designed to obtain the day of the year from a Date type value. The day of the year normally ranges from 1 to 365 (366).

  • Date of. Type Date. The date by which the day of the year is determined.
DAYYEAR(ExpenseAccount.Date)

Day

This function is designed to obtain the day of the month from a Date type value. The day of the month normally ranges from 1 to 31.

  • Date of. Type Date. The date by which the day of the month is determined.
DAY(Expense.Date)

A week

This function is designed to obtain the week number of the year from a Date type value. The weeks of the year are numbered starting from 1.

  • Date of. Type Date. The date by which week numbers are determined.
WEEK(Expense.Date)

Day of the Week

This function is designed to obtain the day of the week from a Date type value. The normal day of the week ranges from 1 (Monday) to 7 (Sunday).

  • Date of. Type Date. The date by which the day of the week is determined.
DAY OF THE WEEK(Expense.Date)

Hour

This function is designed to obtain the hour of day from a Date type value. The hour of the day ranges from 0 to 23.

  • Date of. Type Date. The date by which the hour of the day is determined.
HOUR(Expense.Date)

Minute

This function is designed to obtain the minute of the hour from a Date type value. The minute of the hour ranges from 0 to 59.

  • Date of. Type Date. The date by which the minute of the hour is determined.
MINUTE(Expense.Date)

Second

This function is designed to obtain the second of a minute from a Date type value. The second of a minute ranges from 0 to 59.

  • Date of. Type Date. The date by which the seconds of the minute are determined.
SECOND(Expense.Date)

Express

This function is designed to extract a type from an expression that may contain a compound type. If the expression contains a type other than the required type, NULL will be returned.

Options:

  • Expression to convert;
  • Type indication. Type String. Contains a type string. For example, "Number", "String", etc. In addition to primitive types, this line may contain the name of the table. In this case, an attempt will be made to express a reference to the specified table.

Express(Data.Props1, "Number(10,3)")

IsNull

This function returns the value of the second parameter if the value of the first parameter is NULL.

Otherwise, the value of the first parameter will be returned.

YesNULL(Amount(Sales.AmountTurnover), 0)

Functions of common modules

A data composition engine expression may contain calls to functions of global common configuration modules. No additional syntax is required to call such functions.

In this example, the "AbbreviatedName" function will be called from the general configuration module.

Note that the use of common module functions is only permitted if the appropriate data composition processor parameter is specified.

Additionally, functions of common modules cannot be used in custom field expressions.

For competent management, any trading organization needs prompt receipt of information about the current state of goods, sales, and profits. However, if we consider that organizations often work with a wide range of goods and a large number of counterparties, then the analytical report customization tool plays an important role in obtaining the necessary information. Let's take a closer look at how to work with custom fields in standard program reports (rev. 11).

The development of the 1C: Enterprise 8 platform offers users more and more opportunities. For example, in version 8.2, reports became more flexible, allowing them to be customized to suit various requirements without the help of qualified programmers.

Changing report settings

To view or change report settings, go to the “All actions” menu and select the “Change option” command. After this, a window with settings for the open report opens in front of the user.

In the upper part of the settings window, you can see the structure of the report, which is nothing more than a visual reflection of the report columns and groupings of its rows, which essentially makes it possible to imagine the order in which analytical data is displayed in this report.

At the bottom of the settings window, the actual information and field settings are displayed, relating either to the report or to the elements of its structure (columns and row groupings).

Custom fields

In a programme 1C: Trade Management 8 Edition 11 report settings provide users with more options in their generation.

In the window for editing settings and report structure, we would like to draw users’ special attention to the “Custom Fields” tab, which allows you to create your own fields and add them to the report. It should be recalled that previously the user could only use those fields that were implemented by the developer.

Let's look at the use of this function using an example.

Let’s assume that the head of a trading company that sells goods in Moscow and the regions wants to customize the “Sales History” report to his requirements, wanting to display in it data on the sale of products in Moscow and the regions in general, as well as to partners. This is very easy to do using custom fields.

Thus, a clear example shows that flexible settings for custom fields in a standard program 1C: Trade Management 8 provide the user with ample opportunities to customize reports, allowing them to quickly obtain the necessary information in a convenient form.

Each organization, in order to make timely and correct management decisions, needs operational information about the availability of goods in warehouses, its cost, and sales. Trade organizations work with a large number of items and counterparties, and this requires good setup of analytical accounting and quick acquisition of the required information from its data. The article discusses the basic techniques for working with standard reports in the standard solution “1C: Trade Management 8” (edition 11), built on the basis of a data composition system, and provides useful practical recommendations that will be useful to both novice users and those who have switched to the new edition from previous editions.

For example, let's take the report

  • Product availability analysis;

Settings.

In a collumn Type of comparison Nomenclature

  • Equals
  • Not equal
  • On the list
  • Not on the list
  • In Group Nomenclature;
  • Not in group Nomenclature;
  • In a group from the list Nomenclature;
  • Not in a group from the list Nomenclature.

Meaning

"Quick selections"

As the 1C:Enterprise 8 platform develops and the new version 8.2 appears, reports in systems become more flexible, and users have more and more opportunities to customize them to their requirements without the help of programmers.

New opportunities provided by the data composition system (DCS) allow you to experience the benefits of 1C:Enterprise 8 capabilities when creating reports like never before. And, despite the fact that the report interface has undergone significant changes (compared to edition 10.3 of the “Trade Management” configuration, hereinafter referred to as UT), the report settings are still available to the average user. Let's look at some basic techniques for working with them.

The first thing you can pay attention to is the quick selections. They allow you to display data in a report based on certain values ​​of report fields according to the user’s wishes.

For example, let's take the report Analysis of product availability in UT. Let us immediately note that the entire demonstration of the reporting capabilities in UT 11 will take place using the example of two reports:

  • Product availability analysis;
  • Revenue and cost of sales.

Selection by some fields can be done either directly in the report form or using a button Settings.

In a collumn Type of comparison the user can select different comparison conditions. For example, for the field Nomenclature You can select the following types of comparison:

  • Equals- the report will be built only for the selected item;
  • Not equal- the report will be generated for the entire product range, except for the selected item;
  • On the list- the report will be based on a list of item items;
  • Not on the list- the report will be built on the entire product range, except for selected items;
  • In Group- the report will be built on the entire item located in the selected directory folder Nomenclature;
  • Not in group- the report will be built on the entire product range, except for items located in the selected directory folder Nomenclature;
  • In a group from the list- similar to comparison In the list, only folders in the directory are selected as list values Nomenclature;
  • Not in a group from the list- similar to comparison Not in the list, only folders in the directory are selected as list values Nomenclature.

The checkbox to the left of the selection field indicates that selection for this field is “enabled,” i.e., is taken into account by the report.

Unchecked fields are not taken into account even if you have selected specific values ​​for those fields.

Depending on the selected type of comparison in the column Meaning a specific element or folder (group) of the directory, or a list of elements or folders is indicated.

“Quick selections” are available in all solutions on the 1C:Enterprise 8 platform.

An example of a simple change in report settings

To view/change report settings, you need to go to the menu All actions - Change option.

The settings window for the selected report option opens in front of us.

The report structure is displayed at the top of the window. In essence, this is a visual display of the groupings of rows and columns of the report, i.e. in what order the analytics data will be displayed in the report in rows and columns.

At the bottom of the window, information related to the report as a whole is displayed (if the top level is selected in the report structure Report), or to a specific grouping of rows or columns of the report (if a grouping at a lower level is selected), settings for displaying information and designing fields.

Example 1

Step 1. We need to remove the grouping by product characteristics, leaving only the grouping by product. To do this, at the top of the report settings window, click on the field Nomenclature, Characteristics. At the bottom of the window, go to the tab Groups.

Select the field Characteristic and click on the button Delete command panel.

Confirm changes to the report settings by clicking the button Finish editing in the lower left corner of the screen.

Step 2. After removing the characteristic, our task, according to the conditions of the example, will be to add a price group. In essence, this grouping should be at a level lower than the grouping by warehouse, but at a level higher than the grouping by item. Therefore, in the structure of the report we will highlight a grouping Stock.

By right-clicking on it, select the command from the context menu New group.

In the grouping field editing window that opens, select Nomenclature.Price group.

By clicking the button OK, we will see that a new grouping has been added to the report, subordinate to the grouping Stock.

Now let’s select the grouping by product and, without releasing the right mouse button, drag it inside (i.e. below) the grouping by price group. We will get the structure presented in Figure 1. The result of setting up the report is presented in Figure 2.

Rice. 1. The resulting report structure

Rice. 2. Result of report customization

Working with custom fields

Let's now take a closer look at the new options for customizing reports in the 1C: Trade Management 8 program.

In the form of editing the structure and settings of our report, let’s pay attention to the tab Custom fields.

Previously, we added fields to the report, the list of which was pre-specified by the developer. Using this tab, we can create our own fields that we need - Selection field or Expression field.

Example 2

Let’s customize the “Sales History” report (option of the “Revenue and Cost of Sales” report). We will display sales data by partners and product range. Let's assume that our company sells goods in Moscow and in the regions. Thus, each client in the information base belongs to a specific geographic region (the “Business Region” attribute in the “Partners” directory). We can easily group sales data in a report by region, but what if we are interested in more aggregated statistics, in particular, the answer to the question “How many goods were sold in Moscow, and how many in all other regions combined”? This is where “custom fields” come in handy.

Step 1. Let's open the report. Let's go to the form for setting up the report structure ( All actions -> Change option). Let’s delete in turn all the groups previously created in the report - to do this, select each of them and click on the button Delete command panel, or use the DEL key.

Just as in the previous example, let's add a grouping to the report by partner, and then by item. We already know how to do this, so it won’t take much time.

Step 2. Let's create a new custom field. Let's open the bookmark Custom fields and execute the command Add -> New Select Field.

Let's give our new field a name - Region in general.

Let's click on the button Add. In a new line, click on the button in the column Selection. In the selection editing form that appears, add selection by field Partner.Business region. Let's choose the type of comparison Equals, meaning - Moscow.

Let's click on the button OK, after which we will return to the custom field editing window. Next, you need to click on the button in the column Meaning and in the data type selection list that appears, select Line and write as value Moscow.

Let's repeat the operation. Let's add one more row to the table. This time for selection by field Partner.Business region choose the type of comparison Not equal.

Returning to the custom field editing window, in the column Meaning let's write Other regions(see Fig. 3).

Rice. 3. Editing a custom field

Let's click on the button OK. Our new field is ready.

Step 3. Let's add our new field to the report structure. Selecting the top level with the mouse Report in structure, add a new grouping. In props Field let's choose Region in general.

Let’s drag the grouping by partner and the subordinate grouping by item inside the newly created one with the mouse.

Let's generate a report and look at the result (shown in Fig. 4).

Rice. 4. Result of report generation

Selection and sorting

Let's return to the window for editing the report structure and settings and pay attention to the bookmarks Selection And Sorting.

If the root element is selected in the report structure ( Report), then the settings made on these tabs will apply to the entire report as a whole. If a report grouping is selected, the settings will affect only that grouping.

Example 3

As a result, the report Sales history Only those implementations where the manager is specified will be included. Ivanov Ivan Fedorovich.

Example 4

Save the changes made

If you change the report structure, you can always save it using the command All actions -> Save option.

In the form for saving an option, you can use the switch to select Save to existing report version(instead of one of the already available options), or Save new report version.

The report receives the balances of goods in warehouses in various sections (characteristics, series, units of measurement, etc.). In order not to complicate the example, we will leave only grouping by item and displaying only the final balance as of the reporting date. The final table will show the balances of the item in the warehouses.

But then the user reported that he needed to add two additional fields:

  1. Quantity alert. If the quantity is less than or equal to 5, then the alert is "Insufficient". If the quantity is greater than 5, then less than or equal to 10, then the alert is “Normal”. If the quantity is more than 10, then “Overabundance”.
  2. Formula for calculating the final balance. In the additional column, the user wants to see what actions the program performed to obtain the final balance value. That is, the formula “Initial balance + Turnover = Final balance”, where the corresponding values ​​will be substituted.

Of course, a programmer could intervene here and change the data composition scheme request and report settings, but we will complete the task in user mode without changing the report in configurator mode.

Additional fields

So, let's get started. Let's go to the report option settings:

The settings designer for the ACS report option will open in front of us. By going to the "Custom Fields" tab, we'll start creating them.

The screenshot already shows two created custom fields, the functionality of which was described above. Let's look at the settings for each. Let's start with the "Notification" field.

In the settings, we need to set the field title that will be displayed in the report, as well as set expressions for generating the value in the detailed records field and in the totals for this field. Since there is no need to show the alert in the totals, we will write an expression only for detailed records.

The expression syntax is similar to the 1C:Enterprise query language. There are some differences, but we will not touch on them in detail in this article. The expression uses the selection operator:

"Choice When Then Otherwise The End"

similar to an operator in a query language. Fields in custom field expressions are specified by their representation. In order for the platform to understand that the entered view represents a certain field, the view name is surrounded by square brackets "". If the field representation is one word, then the square brackets are optional. In the example above, we are looking at the Ending Balance field.

The settings for the "Formula for calculating the final balance" field are set in the same way:


Here it is necessary to mention some nuances:

  1. We can only show the formula in a cell as a line. Therefore, we convert all numeric values ​​to a string using the SKD expression language method “String()”, which converts any value to a string. Then we perform string concatenation.
  2. In order for the field to be displayed in the report totals, we will add a similar formula to the expression of the total records. You just need to add aggregation functions "SUM()" for each value in accordance with the totals.

You're ready to use fields in your report!

Setting up and generating a report

Add the "Formula for calculating the final balance" field to the output fields of the report:

We will add the expression “Notification” to detailed item records. To do this, add the expression field “Notification” to the “Nomenclature” grouping. After this, the report structure will take the following form:

The report setup is now complete. If necessary, the added settings can be saved for reuse. Let's generate a report:

As we can see, fields have been added to the report in accordance with the conditions of the task. At the same time, there was no need to modify the report in configurator mode. This is the main advantage of custom fields! A user trained to use them can use them to create a report on their requirements in-house, without the assistance of a programmer.

Believe me, it is possible to train him to use these features, because it is much easier than writing formulas in Excel spreadsheets.