Sub topic 2
The client: the top-level, self-contained unit
This chapter assumes you know what an ERP system does, can name the main business functions (finance, purchasing, production, warehousing), and understand relational tables and primary keys. Being able to log on to an SAP system helps, but you can follow the chapter without it.
What a client is
A client is the highest organisational unit in an SAP system. It is a self-contained unit with its own master data, its own transaction data and its own user master records. Everything else in this tutorial (company codes, plants, storage locations) exists inside exactly one client.
You can think of a client as a separate "tenant" of the system. Two clients on the same SAP installation share the same program code and the same database, but they cannot see each other's business data.
When you log on, you enter a three-digit client number, such as 100 or 800. That number is part of your logon, so it decides which data you work with.
Why the client matters
The client sets the boundary for three things:
- Data separation. Business data in one client is invisible to the others. A material created in client 100 does not exist in client 200.
- User administration. User master records are client-specific. A user who exists in client 100 cannot log on to client 200 unless an administrator creates that user there too.
- Organisational structure. Company codes, plants and storage locations are defined within a client. Their business meaning is local to it.
Most organisations run one productive client per system, where real business happens. They run other clients for development, testing, training and so on.
Client-dependent and client-independent data
Not everything in an SAP system belongs to a client. The system distinguishes two kinds of data.
| Kind | Scope | Typical examples |
|---|---|---|
| Client-dependent | Visible only in one client | Material master, customer and vendor master, purchase orders, user master, most Customizing settings |
| Client-independent | Visible in all clients of the system | ABAP programs, data dictionary definitions, some Customizing (for example, client definitions themselves), repository objects |
This split explains an important behaviour. If a developer changes an ABAP program, the change affects every client in that system. If a consultant changes a client-dependent Customizing setting, only that client changes.
The client field in database tables
In the database, client-dependent tables carry the client number as their first key field. It is called MANDT, which is short for the German word Mandant, meaning client.
For example, the key of the plant table T001W is the client plus the plant:
| MANDT | WERKS | NAME1 |
|---|---|---|
| 100 | 1000 | Hamburg plant |
| 100 | 1010 | Berlin plant |
| 200 | 1000 | Test plant |
Plant 1000 appears in client 100 and in client 200. These are two different rows, because the full key is MANDT plus WERKS. This is the technical basis of data separation.
Open SQL handles the client for you
When you write Open SQL in ABAP, you normally do not mention MANDT. Open SQL applies an automatic client handling rule. It reads only rows of the current logon client.
REPORT z_client_demo.
SELECT werks, name1
FROM t001w
INTO TABLE @DATA(lt_plants)
UP TO 10 ROWS.
cl_demo_output=>display( lt_plants ).The query returns only plants of the client you are logged on to. MANDT does not appear in the SELECT list or in a WHERE clause. The runtime adds the client condition for you.
You can read the logon client from the system field sy-mandt:
REPORT z_client_info.
WRITE: / 'Current client:', sy-mandt.Reading across clients
Occasionally you need to read data from all clients, for example in a technical analysis report. Open SQL provides the addition USING CLIENT or CLIENT SPECIFIED, which switches off the automatic handling.
REPORT z_clients_overview.
SELECT mandt, werks, name1
FROM t001w CLIENT SPECIFIED
WHERE mandt IN ( '100', '200' )
INTO TABLE @DATA(lt_all_clients).
cl_demo_output=>display( lt_all_clients ).Use this with care. It bypasses the data separation that the client exists to enforce. Many organisations restrict it with authorisations or code reviews.
Typical client landscape
An SAP landscape is usually a chain of systems, and each system can hold several clients. A common layout looks like this:
| System | Client | Purpose |
|---|---|---|
| Development (DEV) | 100 | Golden client: Customizing and development |
| Development (DEV) | 200 | Unit test client |
| Quality (QAS) | 300 | Integration testing |
| Production (PRD) | 400 | Real business operations |
The number and purpose of clients differ between companies. What matters is the principle: each client is an isolated working area.
How changes move between clients
Because client-independent changes apply to the whole system, and because Customizing must reach the quality and production systems, SAP uses transport requests. A transport request packages changes so that they can be imported into another client or system in a controlled way.
Two client settings matter here:
- Changes and transports for client-specific objects. This setting controls whether Customizing can be changed in the client at all. In a production client, it is usually locked so that Customizing cannot be edited directly.
- Cross-client object changes. This setting controls whether client-independent objects, such as ABAP programs, can be changed when you are logged on to that client.
Both settings are maintained in the client definition. Setting them correctly is a standard safeguard: in production, nobody should edit Customizing or programs directly.
Creating and maintaining clients
Administrators define clients in Customizing (transaction SCC4, "Client Administration" in the table maintenance view). A client definition holds:
- The three-digit client number and a short description.
- The city and logical system name.
- The role of the client, such as Production, Test, Customizing or Demo.
- The change and transport protection settings described above.
Creating the definition only creates an empty entry. To fill a new client with content, administrators use client copy tools (transaction SCCL for a local copy). A copy can take only the base Customizing, or Customizing plus master data, or everything including transaction data and user records. The right profile depends on the purpose of the new client.
Common errors and edge cases
- Wrong client at logon. A user creates master data in a test client and wonders why it is missing in production. The data is correct but it sits in another client. Always check the client number in the logon screen or in the status bar.
- Missing user in a client. "User unknown" at logon often means the user exists in another client only.
- Assuming program changes are client-local. A fix transported to a system affects all clients, because the program is client-independent.
- Testing in a client with wrong data. A test client copied long ago may have outdated Customizing, so results differ from production.
- Overusing
CLIENT SPECIFIED. It is easy to forget themandtcondition and read more rows than intended. - Several companies in one client. The client can hold many company codes, so it is not the same as a legal entity. The legal entity is the company code, covered in the next chapter.
Client versus other units
The client is not a business unit in the legal or operational sense. It is a technical and organisational container. Business meaning begins one level below it.
| Unit | Role | Relation to client |
|---|---|---|
| Client | Technical container, data boundary | Top level |
| Company code | Legal entity for financial accounting | Defined within one client |
| Plant | Operational site | Defined within one client, assigned to one company code |
| Storage location | Place where stock is kept | Defined within one plant |
The line between company code and plant shows an assignment, not ownership. Later chapters explain that each plant is assigned to exactly one company code.
Summary of key points
- A client is the top-level, self-contained unit of an SAP system, identified by a three-digit number.
- Client-dependent data is separated per client. Client-independent data, such as ABAP programs, is shared.
- Client-dependent tables have
MANDTas the first key field. Open SQL adds the client condition automatically. - Several clients can live in one system, and the client definition controls whether Customizing and programs can be changed.
- A client is not a legal entity. Company codes inside it play that role.
Exercise
A table has the key fields MANDT, WERKS. You run SELECT werks FROM t001w INTO TABLE @DATA(lt) in client 100 without any WHERE clause. Which rows do you get, and what would you add to read rows from all clients?
Show answer
You get only the plants whose MANDT is 100, because Open SQL applies automatic client handling. To read all clients, add CLIENT SPECIFIED after the table name, and select MANDT too so you can tell the clients apart. This bypasses data separation, so use it only when you have a clear reason.
Exercise
A developer changes an ABAP report in client 200 of the development system. A user in client 100 of the same system runs the report. Do they see the change? Why?
Show answer
Yes. ABAP programs are client-independent objects, so a change is visible in every client of that system. Client-dependent data, such as Customizing or master data, would stay local to the client.