Sub topic 3
The company code: the legal entity for financial accounting
This chapter assumes you know the client from the previous chapter, can read basic Open SQL, and understand what a balance sheet and a profit and loss statement are. You don't need accounting expertise.
What a company code is
A company code is the smallest organisational unit for which a complete, self-contained set of accounts can be drawn up. In practice it represents a legal entity, such as a limited company or a national subsidiary. SAP Financial Accounting (FI) uses the company code to produce the statutory reports: balance sheet, profit and loss statement, and the tax returns that go with them.
Three facts define the unit:
- It has a four-character key, such as
1000orDE01. The key is unique within a client. - Every financial posting belongs to exactly one company code.
- Every accounting document balances to zero within its own company code.
The third fact explains much of how SAP behaves. If a posting touches two company codes, for example one subsidiary paying an invoice for another, the system adds automatic clearing lines so that each company code still balances on its own.
Where it sits in the hierarchy
The company code lives inside a client. Everything below it, such as plants and storage locations, ultimately belongs to a company code.
A company code can have many plants. A plant belongs to exactly one company code. The company, covered in the next chapter, is an optional grouping above company codes used for consolidated reporting.
What the company code controls
Creating a company code means giving it a set of parameters. These parameters fix how all its accounting data behaves.
| Parameter | Meaning | Field in table T001 |
|---|---|---|
| Company code key | Four-character identifier | `BUKRS` |
| Name | Legal name shown on reports | `BUTXT` |
| City | Location of the legal entity | `ORT01` |
| Country | Drives tax and legal defaults | `LAND1` |
| Currency | The local currency for all postings | `WAERS` |
| Language | Default language for the entity | `SPRAS` |
| Chart of accounts | The list of general ledger accounts used | `KTOPL` |
| Fiscal year variant | Defines posting periods | `PERIV` |
| Controlling area | Link to cost accounting | `KOKFI` |
| Company | Optional grouping for consolidation | `RCOMP` |
Some points about these parameters:
- The local currency is the currency in which the company code's books are kept. Documents can be entered in other currencies, but the system also stores the amount in local currency.
- The chart of accounts is a list of general ledger (G/L) accounts. Several company codes can share one chart, which is the usual way to keep reporting consistent. Each company code uses one operational chart.
- The fiscal year variant defines how many posting periods exist and when the year ends. Two company codes with different year ends need different variants.
Data kept per company code
Many master and transaction records exist at company code level. Account data is the clearest example. A vendor, a customer, or a G/L account has a general part that is shared across the client, and a company code part that holds data specific to one legal entity.
| Object | General data (client level) | Company code data |
|---|---|---|
| G/L account | `SKA1` | `SKB1` |
| Customer | `KNA1` | `KNB1` |
| Vendor | `LFA1` | `LFB1` |
| Accounting document header | none | `BKPF` |
| Accounting document items | none | `BSEG` |
The company code data holds the reconciliation account, payment terms, and payment methods. These can differ between legal entities even when the business partner is the same. This split is the reason one customer record can be used by several subsidiaries.
Reading company codes with Open SQL
Table T001 stores one row per company code. The following report lists them. It uses the demo output class CL_DEMO_OUTPUT, which is available in standard ABAP systems.
REPORT z_list_company_codes.
SELECT bukrs, butxt, ort01, land1, waers, ktopl, periv
FROM t001
ORDER BY bukrs
INTO TABLE @DATA(lt_company_codes).
cl_demo_output=>display( lt_company_codes ).You never need to filter on the client field MANDT. Open SQL applies the current client automatically, which is why a company code key only has to be unique within its client.
Because plants carry no direct company code field, the link goes through table T001K, where BWKEY is the valuation area. For a plant, the valuation area normally equals the plant key. The next query counts plants for each company code.
REPORT z_plants_per_company_code.
SELECT k~bukrs,
COUNT(*) AS plant_count
FROM t001w AS w
INNER JOIN t001k AS k ON k~bwkey = w~bwkey
GROUP BY k~bukrs
ORDER BY k~bukrs
INTO TABLE @DATA(lt_counts).
cl_demo_output=>display( lt_counts ).The join starts from T001W, the plant table. This matters if your system values stock at company code level, where T001K rows have a BWKEY equal to the company code, not a plant. Such rows have no partner in T001W, so the inner join drops them and only plants are counted.
Configuration
Company codes are defined in Customizing, which is the SAP term for system configuration. You reach it through the Implementation Guide (transaction SPRO) under Enterprise Structure.
| Transaction | Purpose |
|---|---|
| `OX02` | Define or edit a company code (name, city, country, currency, language) |
| `OBY6` | Company code global parameters (fiscal year variant, chart of accounts assignment, and more) |
| `EC01` | Copy a company code, including its dependent settings |
| `OX15` | Define a company (the grouping above company codes) |
| `OX19` | Assign a company code to a company |
Customizing changes are recorded in a transport request, which moves the change from the development system to test and production. Company code definitions are client-dependent, so they must be set up in every client where you need them.
Company code versus neighbouring concepts
Beginners often merge the company code with another unit. These are the common mix-ups.
- Company code and plant. The company code is a legal and accounting unit. The plant is an operational site. One company code can own several plants. A plant never spans two company codes.
- Company code and company. A company code is a book-keeping entity. A company is a reporting group of company codes, mainly for consolidation. You can have company codes with no company assigned.
- Company code and client. The client holds many company codes. Data is separated by client, while company codes in one client can still be consolidated and can post to each other.
- Company code and business area. Business areas, an older construct, allowed reporting across company codes. Many systems use profit centres or segments instead.
Common mistakes
- Creating one company code per plant by default. A plant is not a legal entity. Create a company code only when a separate set of statutory books is needed. Extra company codes multiply master data, period-end work, and intercompany reconciliation.
- Merging legal entities into one company code to save effort. If two entities file separate tax returns, they need separate company codes. Splitting one later is far harder than splitting at the start.
- Choosing the wrong currency at the start. The local currency is part of every posted line. Changing it needs a migration, not a setting.
- Forgetting the plant assignment. A plant with no company code assignment cannot take part in valuated inventory movements. Assignment itself is covered in a later chapter.
- Assuming the key is unique across systems. The key
1000in the development client has no relation to1000in production unless both were configured the same way. Transport the configuration instead of retyping it.
Quick check of a company code
You can verify a company code in a live system without writing code:
- Run transaction
OX02and select the company code. Confirm country, currency, and language. - Run
OBY6and confirm the fiscal year variant and chart of accounts. - Run
SE16Non tableT001to see the same data as table rows. - Run
SE16NonT001Kfiltered onBUKRSto list the valuation areas, which are normally plants, assigned to it.
Exercise
A group has one factory and two warehouses in Germany, all owned by the same GmbH, and one sales subsidiary in France that files its own tax return. How many company codes and how many plants does the minimum sensible design contain, and why?
Show answer
Two company codes: one for the German GmbH and one for the French subsidiary, because each legal entity needs its own set of books and tax return. The factory and the two warehouses can all be plants (three plants) assigned to the German company code, since a company code can own many plants and the three sites share one legal entity. The French sales site may need a plant if it holds or moves stock, and it would be assigned to the French company code.
Exercise
You run the plants-per-company-code query and a company code known to have plants does not appear in the result. Name one likely cause.
Show answer
The plants may have no row in T001K, which means they were never assigned to a company code. Another possible cause is that the system values stock at company code level, in which case T001K rows carry the company code as BWKEY and have no matching row in T001W, so the inner join removes them.