Inside PCN874.TXT: the O header record, transaction records, the X closing record and the entry-type code table - and how to make monthly generation automatic.
Key takeaways
- The file is named `PCN874.TXT` and has a fixed structure - a field shorter than the specification requires is padded with leading zeros.
- The header record opens with the fixed value `O` and carries the dealer number, the reported month as `YYYYMM`, tax totals and record counts.
- The closing record opens with the fixed value `X` and carries the submitter's dealer number.
- Every transaction record carries a single entry-type letter deciding what the document is: sale, input, import, export or self-invoice.
- By default the file covers the calendar month prior to the month of file production.
PCN874.TXT is a fixed-structure text file built from three layers: a single header record of type O, one transaction record per document, and a closing record of type X. Automating it means every field is derived from a query over your own data instead of being retyped at the end of the month.
The file in three layers
One header record. It opens with a one-character entry-type field holding the fixed value O. Then the licensed dealer number in nine characters, the reported month in six characters as YYYYMM, the report type, and the file generation date. The second half of the header is totals: total taxable sales excluding VAT, total VAT on taxable sales, total zero-value and exempt sales, total VAT on other inputs, total VAT on equipment inputs, and the VAT to pay or receive for the period. Each total has its own separate sign field.
Transaction records. One per document, holding: the entry-type letter, the nine-character VAT identification number of the other side - the customer on sales, the supplier on inputs - the document date as YYYYMMDD, a four-character reference group, a nine-character reference number, the VAT amount on the invoice, a sign field for credits, and the invoice total excluding VAT in ten characters. Both amount fields are always submitted as positive values; what makes it a charge or a credit is the sign field.
One closing record. Entry type X followed by the dealer number of whoever is submitting.
The entry-type code table
This is the field that decides which section of the report a document lands in, and it is the source of most mapping mistakes:
| Code | Meaning |
|---|---|
S | Sale - regular sale to an identified commercial customer |
L | Sale - unidentified customer, including aggregated cash-register sales |
M | Sale - self invoice |
Y | Sale - export |
I | Sale - Palestinian Authority customer |
T | Input - regular Israeli supplier |
K | Input - petty cash |
R | Input - import |
P | Input - supplier from the Palestinian Authority |
H | Input - other single document required by law |
C | Input - self invoice |
Where each field comes from in your own data
- The entry-type letter derives from the transaction type and the account card, not from the document type alone.
- The counterparty number comes from the customer or supplier master record, which is why reporting quality is decided by master-data quality.
- The reference number is taken as the first nine positions from the right, so a long internal numbering scheme is truncated predictably.
- The reference group attributes a document to a branch or series, and may be filled with zeros.
- The VAT amount is rounded to the nearest whole shekel.
For a mixed transaction carrying both a taxable component and an exempt or zero-rated one, the specification allows two treatments: count and summarise it as a taxable invoice, or report it twice - once at the normal rate and once at zero, with the same document type, customer, date and reference number. Either treatment has to be agreed with whoever maintains the books, because it changes what the report shows.
How do you turn this into a monthly process rather than a manual task?
- Pull every document in the reported month, including cancellations and credits.
- Classify each one to an entry-type letter using explicit mapping rules held as configuration, not in code.
- Run an exceptions report - documents with no counterparty identifier, dates outside the month, empty references.
- Compute the header totals and record counts from the very same collection of transactions that gets written to the file.
- Write the file in the fixed structure with zero padding, and keep a timestamped copy.
- Compare the header totals to your internal report before transmitting.
Step four is the whole thing. The header must be derived from the transactions, never computed separately. Compute it from a second query and any small difference in filtering produces a gap that looks exactly like a data error.
What has to reconcile between the header and the transactions?
The header declares the count of sales records and the count of input records, along with the accumulated totals. These are control values: they exist to be compared against what was actually accepted. So generation has to be one atomic operation - the transaction set is built once, and both the lines and the counters come out of it.
Special documents that break that assumption: on an export entry the counterparty field carries the export entry number, and for exported services or intangible goods it is 999999999. On a self invoice the supplier number goes into the counterparty field. On a petty-cash entry the reference field carries the number of invoices included in the record rather than a document number.
The wider monthly picture is covered in automating VAT reporting in Israel, and what happens when the file is refused is in common PCN874 import errors.
What stays manual even after automation
- Deciding how to classify an unusual document that no existing mapping rule covers.
- Signing off the totals with bookkeeping before transmission.
- Handling a correction to a month already reported.
- Tracking parameter changes, since the specification says explicitly that parameter values may change from time to time and are published in guidance.
Automation shortens the repetitive part. It does not replace judgement, and it is not supposed to.
This is a technical description of a file structure, not tax advice. The obligations that apply to a specific business, and the deadlines, must be checked against the official source and with whoever maintains the books.
Sources
Frequently asked questions
Which month does the file cover?
By the specification, the file by default includes data relating to the calendar month prior to the month in which the file was produced. That is a default of the file structure and not a statement about submission deadlines, which should be taken from the official source and your accountant.
Why is the VAT amount always positive?
Because the sign lives in a separate field. The amount field always carries a positive value rounded to the nearest shekel, and the sign field decides whether it is a charge or a credit. When the amount field is zero, the value of the sign field is plus.
How is a self invoice reported?
On a self invoice the supplier number is entered in place of the counterparty number. The specification notes the transaction can be reported as a sale and possibly also as an input, and that the input VAT may be lower than the VAT on the sale in cases of partial deductibility.
How does a representative's file differ from a single dealer's?
A representative's structure is defined in a separate appendix. It opens with a record carrying the fixed value `A` with the representative's number and the reported month, holds reports for several dealers for the same period, and carries summary records with the fixed value `Z` for control purposes.
Keep reading
Related service
Dashboards
One screen with the few numbers that actually change a decision.
About the author
Yehonatan Saadia
Freelance automation, web & MVP developer
I'm Yehonatan Saadia, a senior developer who builds business automation, custom websites, and MVPs for small and mid-sized companies across the US, Europe, and Israel. These guides come from real client work, not theory.
Work with meHave a project like this?
Tell me what you're trying to automate or build. I reply within 24 business hours with a few targeted questions, then we walk through it on a free 30-minute call, with no commitment. You come away with a scope, a timeline and a fixed price - or a straight answer that it isn't worth building.
