> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Processing Purchase Orders

A purchase order is a document sent from a customer to a vendor and used for ordering goods, indicating types, quantities, and agreed prices. The difference between a purchase order and an invoice is that the purchase order confirms the order has been placed, while the invoice requests payment for the order. Nevertheless, the processing of purchase orders is in many ways similar to the processing of invoices and uses similar algorithms and instruments: a database of companies, training batches for documents originating from a specific company, country settings for country-specific keywords and tax rates, etc.

> [!NOTE]
>
> To use the functionality in ABBYY FlexiCapture SDK, you will need a license that allows you to use the Document Definition associated with the solution.

Purchase order processing is configured for the following countries and languages:

* USA (English)
* Germany (German)
* France (French)
* Spain (Spanish)

For the countries and languages listed above, a number of settings and keywords have been added to provide data capture from purchase orders of these countries.

ABBYY FlexiCapture SDK processes purchase orders within ABBYY FlexiCapture 12 projects. To use this functionality, do the following:

1. Create a new project of a Purchase Orders type with the help of ABBYY FlexiCapture 12 Developer's Package.
2. Customize the project to your needs, managing validation rules and using data sets.
3. Open it in ABBYY FlexiCapture SDK using the [**OpenProject**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine-openproject.md) method of the [**Engine**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine.md) object (see also [Opening the Project](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/engine-openingproject.md)).

## Training to extract fields using a "Variants" data set

For a project of a Purchase Orders type, you can train field extraction for a variant of a Document Definition section. Document Definition has a "Variants" data set to which you should add a record populating the information about your purchase order.

1. Add a new record to the "Variants" data set using [**AddNew**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/datasettablerecords-addnew.md) method of the [**DataSetTableRecords**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/datasettablerecords.md) object.
2. Add a new training batch using the [**AddNew**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldsextractiontrainingbatches-addnew.md) method of the [**FieldsExtractionTrainingBatches**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldsextractiontrainingbatches.md) object.
3. Pass the [**SectionDefinition**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/sectiondefinition.md) object for the section and the [**DataSetTableRecord**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/datasettablerecord.md) object record from the "Variants" data set for the section variant.
4. [Add the images for training to the batch](https://docs.abbyy.com/flexi-capture/sdk/guided-tour/engine-addingimages.md). Call the [**Recognize**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/batch-recognize.md) method of the [**Batch**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/batch.md) object to match the Document Definition and recognize all the documents in the batch.
5. Correct the layout of the fields that will be trained. Assign the correct region to each field by calling the [**SetFieldRegion**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/page-setfieldregion.md) method of the [**Page**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/page.md) object.
6. Train field extraction. Get the [**FieldsExtractionTrainer**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldsextractiontrainer.md) object from the training batch and call its [**Train**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldsextractiontrainer-train.md) method. The Document Definition will be updated automatically.

## Processing purchase orders without data sets

The process of capturing purchase orders can be carried out without data sets. In this case, training uses the clustering feature, which is enabled by default when creating a project with the help of ABBYY FlexiCapture 12 Developer's Package.

1. Add a new training batch using the **AddNew** method of the **FieldsExtractionTrainingBatches** object. Pass NULL as a value of the *Record* parameter.
2. Add some documents for training. On each page, find the fields that you are going to train, for example, the *Total* field.
3. Get the **FieldsExtractionTrainer** object using the [**FieldsExtractionTrainer**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldsextractiontrainingbatch.md#fieldsextractiontrainer) property of the [**FieldsExtractionTrainingBatch**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/fieldsextractiontrainingbatch.md) object.
4. Train fields extraction by calling the **Train** method of the trainer object.
5. Now you can recognize the documents from the working batch similar to those used in training calling the **Recognize** method of the **Batch** object. The fields you have trained should be detected and extracted more precisely.
