1s 8 reading xml example. Generating an XML file. Easy upload for third party application. The process of uploading data to xml

It will save time on entering information about the purchase of Peterhost services into 1C.
To do this, you need to upload an XML file to 1C and from it the document “Receipt of goods and services” will be generated, containing information about the purchased services. An invoice can be generated based on this document.

Detailed instructions are provided below.

1. Connecting external processing

1.1. If you use the 1C:Enterprise 8.X infobase with the Enterprise Accounting 2.0 configuration, you need to connect external processing () to upload a document in the CommerceML format
This can be done in two ways:
1. Save the external processing file locally to disk and open via the menu "File" → "Open" before each data loading in CML format.
2. Connect processing to the infobase (IB) permanently. Then it will be available to everyone (in the case of working over a network) from the menu "Tools" → "Additional reports and processing" → "Additional external processing".

  • In the "Service" menu, select "Additional reports and processing" - "Additional external processing".
  • Click the "Add" button. A form for adding a new directory element will open:
  • In the "Name" field, specify the name of the processing, for example, "Download data in CommerceML format (RU-CENTER Group)".
  • Press the file selection button and specify the path to the download processing file ().
  • Press the "OK" button Now the processing is connected to the infobase and is located in the "Additional external processing" directory, and it can be opened by double-clicking the mouse.

1.2. In the case of using the configuration "Manufacturing Enterprise Management" (version 10.3 and higher) and "Trade Management" (version 1.3 and higher), this processing is already enabled and you can proceed to step 2.

2. Formation of the document "Receipt of goods and services"

As a result of the actions performed below, information about the services purchased from Peterhost will be entered in 1C.
1. Next, you need to save to your computer an XML file with the data of the document "Receipt of goods and services" for the required period. The file in XML format is located in the Personal Account section under the link "XML for 1C".
Press the selection button to the right of the "Data file name" field and select this file (see Figure 1). To the question "Read data from a file?" answer "OK". The data file will be read by processing.
2. If the processing succeeds in determining all correspondences between the data elements of the file and the infobase data, then the question “Save data to the infobase?” will be asked. If you answer "Yes", then a new document "Receipt of goods and services" will be created. Go to point 3.
3. If not all data matches are determined, then a message will be displayed: “When loading data, the program could not automatically find IS objects corresponding to the elements transferred in the exchange file ...” and will offer to perform the comparison manually. In this case, you must do the following:

  • Press OK. A form for matching file objects and IB objects will open. It has several tabs that correspond to different types of objects (organizations, contractors, nomenclature, etc.). If data of some type has not been matched, then red exclamation marks will appear on the corresponding tabs (see Figure 2).
  • Go to the appropriate tabs and manually match the elements. It should be noted that counterparty and organization matches are searched for by TIN, and nomenclature matches are searched first by article number, then by name. If the element that corresponds to the file data is not in the IB, then it can be created automatically from the file data by clicking the "Create from file data" button.
  • When adding an item, check the "Service" property (see Figure 3). You can also change the full and short names of the stock item.
  • On the "Accounts" tab, it is desirable to add inventory accounting accounts so that when creating the "Receipt of goods and services" document, these numbers are entered automatically. For example, the following values ​​can be set for services: “Account” - 25 (General production expenses) and “Account for VAT presented” - 19.04 (VAT on purchased services) (see Figure 4).
  • After matching all the elements and pressing the "OK" button, the program will ask for confirmation to upload the document to IB, after which it will create a new document "Receipt of goods and services" (see Figure 5).

3. Posting the document "Receipt of goods and services"

To post the document "Receipt of goods and services", you need to open it by double-clicking and fill in the missing fields, such as "Setting off advances" (for example, "Automatic") and the fields on the "Settlement accounts" tab (see Figure 6). The values ​​of these fields are determined by the accounting policy of your organization. To post the document, click the "OK" button.

4. Formation of the document "Invoice"

After the successful creation and posting of the document "Receipt of goods and services", you can create the document "Invoice received" on the basis of it. To do this, click on the appropriate link in the lower left part of the document form.

Data transfer is a very important process in any accounting system, the 1C 8.3 and 8.2 platform is no exception. Below we will look at instructions on how to most easily transfer data from one system to another that has a similar configuration (for different configurations, you can use the tool for programmers - or).

Before any action is necessary, changes are irreversible!

The easiest and most convenient way to transfer data from 1C 8.3 to 1C 8.3 accounting 3.0 is to use the processing of Unloading and loading data in XML format (download - for 8.2 or for 1C 8.3 or on ITS). Processing is universal and suitable for any configuration.

We will not go into details, we will consider step-by-step instructions for data migration using this processing using the example of the simplest transfer of goods.

Exporting data to XML

First of all, let's open the processing in the source database (from where we will unload goods) and look at the interface:

Get 267 1C video lessons for free:

You must immediately fill in the "File name" field - a new data file will be created along this path, which we will upload to the receiver database. A little lower, in the tabular part "Data to unload", you need to select the data that we want to unload from the database.

After selecting an object from the left tabular section, you can apply a selection in the right tabular section:


In our example, I want to unload all products with the name "Rake".

After all the settings are filled, the data can be uploaded. To do this, click on the "Upload data" button:


Loading data from xml to 1s 8.3

The data has been unloaded from the source database, now it needs to be transferred to the destination database.

To do this, you need to start processing already in the database into which you want to load data, and go to the "Download" tab, select the uploaded file on the disk and click on the "Download data" button:


This example is only suitable for transferring data between identical configurations on the 1C platform. To understand the mechanism of exchanges, for programmers, we wrote an article -.

The transfer of information between databases is one of the tasks of their support and administration. For its effective implementation, processing is created in automated 1C complexes. They greatly facilitate routine work, speed up the process of uploading and downloading information and at the same time control its correctness. Uploading from 1s to xml allows you to create a file with the contents of any customized configuration object, and use it when you need to upload data to an identical configuration.

Tools for creating an upload

To export information contained in databases, the xml format is mainly used. For 1C, a lot of processing has been developed (for example, UploadUploadDataxml82 epf), with the help of which it is possible to output to a file and upload data. In this case, the user must receive a file of a certain structure, which allows you to load the information stored in it into your native database or transfer it to another location. When creating a download, the following rules must be observed:

  • Save the created files until the moment of full restoration and completion of the procedures for checking the correctness of the transferred information;
  • In the case of using processing as a backup tool, create separate subfolders for data copies and keep a log of their accounting for quick search.

The universal processing "Uploading and loading XML data" supplied in the 1C user support program, which can be found on the ITS website or disks, is an excellent tool for exporting and importing information. A computer user can unload both the entire database and its individual objects, while in addition to the actual export, various information verification operations are performed to help get rid of critical errors in the data. Processing 1s unloading in xml works in two modes:

  • Unloading. Creates a file containing user-defined pageable objects;
  • Loading. Reads the previously exported file and writes the information contained in it to the infobase.

Processing allows you to check objects for invalid characters, and also includes the function of exporting information with restrictions.

Uploading can be used not only when exchanging information between 1C databases. With its help, it is possible to ensure the integration of various complexes, for example, 1C and the Parus system. The versatility of the XML format allows you to create programs for transferring information for almost any information bank. Processing the upload and download of xml data is the most important tool for exchanging information.

The process of uploading data toxml

Consider how to unload from 1s to xml in the usual way. After downloading the processing UploadUploadDataxml.epf and opening it, you must perform the following steps:

  • Select objects for export;
  • Set the necessary filters, for example, by period;
  • Determine the location of the file with information on the disk subsystem;
  • Start uploading objects.


It must be remembered that the header part of the upload file format differs from the file format used when uploading according to exchange plans.

xml

Loading xml in 1s is performed in the destination base with a configuration identical to the source base. Before loading xml 1s into 1s, you need to open processing in the receiving base. Then you need to specify the path to the previously uploaded file and load the data by clicking on the "Download data" button.

If necessary, checkboxes are activated to load data in exchange mode in a distributed infobase and ignore errors that occur when loading objects.


After that, you need to check the bases and make sure that all elements are loaded correctly so as not to lose them, for example, if an error occurs in the event handler after loading the object.


This processing allows you to exchange data between the same (identical) configurations on the 1C 8.2 platform - Bukh, ZUP, UT, SCP and others, the main thing is that the configurations are the same!

Processing screenshots

(foto)

Operating modes

Processing implements 2 modes of operation: Unloading (creating an unloading file of data specified by the user) and Loading (reading an unloading file created by the mode of the same name and writing the data contained in it). The mode is set by selecting in the Mode field.

Before launching a particular mode (pressing the Run button), you must specify the name of the upload file either by entering it manually in the "File name" field, or using the button for selecting this field and the standard file selection dialog.

In download mode, it is possible to edit the use of totals when writing registers, which can affect the download speed.

The "Disable totals" and "Enable totals" buttons are available when the "Enable the ability to edit the use of totals when loading data" flag is set and are used to manually control the mode of using totals when loading data.

Processing Applicability Conditions

Processing can be used only in cases where the infobase in which the data was uploaded and the one in which the data is uploaded are homogeneous (the configurations are identical, the data may differ), or all uploaded objects are almost completely identical in composition and types of details, and tabular parts, properties of the "leading" metadata object, etc. It should be noted that, due to these limitations, processing is mainly intended for exchanges between homogeneous IBs.

The upload file format differs from the file format created when uploading according to the exchange plan by the header part. To unload data (elements of reference books, sets of register records, etc.), processing uses the same XML-serialization mechanism as unloading according to exchange plans, in this part the file formats are identical.

Determination of the composition of the unloading

Processing allows you to carry out both full and partial unloading of infobase data into a file. The composition of the uploaded data is configured in the dialog by setting the checkboxes in the tree column that displays the metadata objects for which data can be uploaded. An additional flag column, "If necessary", sets the need to unload objects of this type "by reference". That is, if the checkbox is set only in the "If necessary" column, then the data on such an object will not be fully uploaded, but only to the extent necessary to maintain referential integrity in the infobase that will download the upload file.

When the form is opened, the processing sets the unloading by reference flag for all objects, which guarantees the referential integrity of the unloaded infobase fragment.

When you click on the "Define objects uploaded by link" button, the processing analyzes what data links can be contained in objects that have the full upload flag set, and automatically fills in the flag column indicating the need to upload by link. If the object already has the full unload flag set, then the unload by reference flag is not set.

Possible applications

The use of this processing is possible, for example, to create a full or partial backup of data, to exchange data between infobases, and also as an auxiliary tool for restoring problematic infobases.

In an organization, accounting can be kept not only in solutions based on the 1C: Enterprise platform, but also in other software systems (Galaktika, Parus, SAP, etc.). In this case, the tasks of integrating two applications appear.

For example, some application (let's call it "X") needs to read a list of configuration documents. We will not talk about the practical benefits of solving such a problem, I will only note that the most convenient and universal way in such a situation would be to upload a list of documents in XML format.

The exchange using this format is universal, since most applications can work with it. Let's consider how you can upload a list of configuration documents from 1C:Enterprise to an XML file.

Export to XML

And so, let's move on to the main thing. We need to iterate over the list of document metadata and generate the list in an XML file. The following screenshot shows the algorithm for generating an XML file:

CreateXML() Function Export // Get the name of the temporary file Path = GetTemporaryFileName() ; // Initialize the class "WriterXML" Entry = New EntryXML; // Open a temporary file for writing - 8 ") ; // Write XML file declaration Record. WriteDeclarationXML() ; // Write. WriteElementStart(" DocumentsConfigurations") ; // First element // Attribute of the first element with the file generation date Record. WriteAttribute(" generated " , Format(CurrentDate() , " DF = yyyy-MM- ddThh:mm:ss; DLF= DT")) ; // Write an element for each configuration document. We put the name of the document in the text. For Each Doc Of Metadata. Documents Cycle Record. WriteItemStart("Document") ; Record. WriteText(Doc. Name) ; Record. WriteEndElement() ; EndCycle; // Finish writing the first element Record. WriteEndElement() ; Record. Close() ; // Close the file // Get the file's binary data and put it in temporary storage BinaryData = New BinaryData(Path) ; Address = PlaceInTempStorage(BinaryData, New UniqueIdentifier) ​​; Return Address; // Return the address of the file in storage EndFunctions

Each created element must be correctly completed. After executing the "WriteStartElement()" method, the "WriteEndElement" method must be executed, otherwise the structure of the XML file will be incorrect.

The general template for creating XML files is the following sequence:

// 1. Initialize the "XML Write" class Entry = New EntryXML; // 2. Open a temporary file for writing Record. OpenFile(Path, "UTF-8") ; // 3. Write the declaration of the XML file Record. WriteDeclarationXML() ; // // 4. ++ Write the contents of the XML file Record. WriteElementStart(" XML Element ") ; Record. WriteEndElement() ; // -- Write the contents of the XML file // 5. Close the file Record. Close() ;

These five steps create almost any XML file.

In our example, the created file is converted into binary data and returned to the place where the "CreateXML" function was called. This file can then be written to the file system.

You could see an example of the uploaded file in the screenshot above.

Third Party Application

For example, I created an application on the .NET Framework to demonstrate reading an XML file in a third-party application.

The program reads the created file and displays the documents in the form of a list:

You can try it yourself, the application is available for download from the link at the end of the article.

Versatility

The XML format is used in most configurations for data exchange between application solutions on the 1C:Enterprise platform. Another commonly used communication method is a COM connection. XML allows you to exchange with almost any application, which deserves to be called universal.

Downloads:

XML file reader application.

Processing the formation of an XML file.

When an enterprise constantly uses some kind of software package in its work, then, of course, the question of its constant support and administration always arises. There is no way to do with the tasks of exchanging, storing and restoring data. Consider how to load or unload data from 1C in XML format, as this is an important procedure for this topic.

They are built in such a way that when unloading, you can get an XML format file in which the data necessary for the client will be recorded. At the same time, along with the recording, the correctness of the transferred records is also checked for critical errors.

Thus, unloading into an XML file (importing records) from one infobase and subsequent loading from XML into another represent an exchange of data in XML format between databases.

This procedure, especially with large amounts of information, saves a lot of manual work.

Import (received file) can also be used as an archive for recovery in unforeseen situations (in case of loss or damage).

A lot of such processing tools have been developed, and they are available on the Internet. The responsibility for their use falls on the shoulders (and head) of the client.

But for official users of one, developers have created a universal handler "Unloading / loading XML data".

IMPORTANT. Export to XML in 1C and further loading into XML from 1C is allowed for identical configurations - otherwise it will be damaged.

Generic Handler

Key points for using universal developer:

  • Import files to save until the end of the transfer of records and checking their correctness;
  • When used as backups, they should be counted for sorting searches.

It has two modes of operation: creating a file while saving information and reading/writing it when importing.

In addition, the user can set additional restrictions both when exporting and loading data.

Retrieving Records

You can upload data both for the entire database and selectively - object by object.

After downloading, installing and opening the handler, the following is performed:

Their selection is made in the dialog box that opens after the launch. To do this, check the boxes in the list that displays the metadata objects to be extracted;

  1. Necessary filters are configured (for example, by date);
  2. A place on the disk space is selected;
  3. The operation itself starts.

Uploading records to the receiver

The first step to accept data into the destination database is to open the handler program in it.

After the path to the source file is specified and the checkboxes for the procedure settings are activated (if necessary), you can start the process with the "Load data" button.


Now you know how to upload or download data from 1C in XML format to save data and exchange between databases.

Write in the comments about your experience in this matter.

When an enterprise constantly uses some kind of software package in its work, then, of course, the question of its constant support and administration always arises. There is no way to do with the tasks of exchanging, storing and recovering data. Consider how to load or unload data from 1C in XML format, as this is an important procedure for this topic.

They are built in such a way that when unloading, you can get an XML format file in which the data necessary for the client will be recorded. At the same time, along with the recording, the correctness of the transferred records is also checked for critical errors.

Thus, unloading into an XML file (importing records) from one infobase and subsequent loading from XML into another represent an exchange of data in XML format between databases.

This procedure, especially with large amounts of information, saves a lot of manual work.

Import (received file) can also be used as an archive for recovery in unforeseen situations (in case of loss or damage).

A lot of such processing tools have been developed, and they are available on the Internet. The responsibility for their use falls on the shoulders (and head) of the client.

But for official users of one, developers have created a universal handler "Unloading / loading XML data".

IMPORTANT. Export to XML in 1C and further loading into XML from 1C is allowed for identical configurations - otherwise it will be damaged.

Generic Handler

Key points for using universal developer:

  • Import files to save until the end of the transfer of records and checking their correctness;
  • When used as backups, they should be counted for sorting searches.

It has two modes of operation: creating a file while saving information and reading/writing it when importing.

In addition, the user can set additional restrictions both when exporting and loading data.

Retrieving Records

You can upload data both for the entire database and selectively - object by object.

After downloading, installing and opening the handler, the following is performed:


Their selection is made in the dialog box that opens after the launch. To do this, check the boxes in the list that displays the metadata objects to be extracted;

  1. Necessary filters are configured (for example, by date);
  2. A place on the disk space is selected;
  3. The operation itself starts.

Uploading records to the receiver

The first step to accept data into the destination database is to open the handler program in it.

After the path to the source file is specified and the checkboxes for the procedure settings are activated (if necessary), you can start the process with the "Load data" button.

Now you know how to upload or download data from 1C in XML format to save data and exchange between databases.

Operating modes

Processing UnloadingLoadingXML82Data implements 2 modes of operation: Unloading (creating an unloading file of user-specified data) and Loading (reading an unloading file created by the mode of the same name and writing the data contained in it). The mode is set by selecting in the Mode field.

Before launching a particular mode (pressing the Run button), you must specify the name of the upload file either by entering it manually in the “File name” field, or using the button for selecting this field and the standard file selection dialog.

In download mode, it is possible to edit the use of totals when writing registers, which can affect the download speed. The “Disable totals” and “Enable totals” buttons are available when the “Enable the ability to edit the use of totals during data loading” flag is set and are used to manually control the mode of using totals when loading data. ** Processing applicability conditions**

Processing can be used only in cases where the infobase in which the data was uploaded and the one in which the data is uploaded are homogeneous (the configurations are identical, the data may differ), or all uploaded objects are almost completely identical in composition and types of details, and tabular parts, properties of the “leading” metadata object, etc. It should be noted that, due to these limitations, processing is mainly intended for exchanges between homogeneous IBs.

The upload file format differs from the file format created when uploading according to the exchange plan by the header part. To unload data (elements of reference books, sets of register records, etc.), processing uses the same XML-serialization mechanism as unloading according to exchange plans, in this part the file formats are identical.

Determination of the composition of the unloading

Processing allows you to carry out both full and partial unloading of infobase data into a file. The composition of the uploaded data is configured in the dialog by setting the checkboxes in the tree column that displays the metadata objects for which data can be uploaded. An additional column of flags, “If necessary”, sets the need to unload objects of this type “by reference”. That is, if the checkbox is set only in the “If necessary” column, then the data on such an object will not be fully uploaded, but only to the extent necessary to maintain referential integrity in the infobase that will download the upload file.

When the form is opened, the processing sets the unloading by reference flag for all objects, which guarantees the referential integrity of the unloaded infobase fragment.

When you click on the “Define objects uploaded by link” button, the processing analyzes what data links can be contained in objects that have the full upload flag set, and automatically fills in the flag column indicating the need to upload by link. If the object already has the full unload flag set, then the unload by reference flag is not set.

Possible applications

The use of this processing is possible, for example, to create a full or partial backup of data, to exchange data between infobases, and also as an auxiliary tool for restoring problematic infobases.

Working with XML documents is available directly from the built-in language of the 1C:Enterprise 8 system.

There is a possibility:

  • sequentially read and write xml documents:
    • convert from a string derived from the element's text or XML attribute value to a value according to the specified type;
    • get a string representation of a value to put in the element's text or XML attribute value;
    • get the XML data type corresponding to the type passed as a parameter;
    • check the possibility of reading from XML the value of the specified type;
    • perform XML schema validation when reading XML
    • write the value in XML format;
    • return a type corresponding to the XML data type.
  • use the object data access model of xml documents (DocumentDOM) that conforms to the following standards:
    • DOM Level 2;
    • XPath (DOM Level 3);
    • DOM Load and Save (DOM Level 3).
  • use the XML Schema object model (XML Schema);
  • use the canonical XML standard 1.1 (Canonical XML 1.1).

Using an external connection and mechanisms for working with XML, it is possible to organize integration with application systems according to the formats adopted in these systems. To do this, XSL transformation mechanisms are used. For example, for such integration, you can use Microsoft's BizTalk server:

fast infoset

The platform provides tools for working with XML documents in the Fast Infoset binary format. The Fast Infoset technology uses an alternative syntax for displaying XML data. This results in smaller files and faster processing than data written in the normal XML format. A file written in the Fast Infoset format has the extension .fi or .finf.



Have questions?

Report a typo

Text to be sent to our editors: