Sub topic 2
The client: the top-level, self-contained unit
This chapter assumes you know what an ERP system does, understand relational tables and keys, and can log on to an SAP system. You do not need to have configured one.
What a client is
A client is the highest organisational unit in an SAP system. It is a self-contained environment with its own master data, transaction data, and customizing settings. Users log on to one client at a time, and everything they see and change belongs to that client.
A single SAP system (one installation, one database) can hold several clients. Typical examples are a development system with a customizing client, a unit-test client, and a sandbox client, or a production system with a single productive client.
Notice that company code 1000 exists in both clients. The two are unrelated objects that happen to share a key, because each client is isolated from the others.
Why the client matters
The client is the boundary for data separation and for most configuration.
- Data isolation. Business data in one client is invisible to the others. A user logged on to client 100 cannot read the orders of client 200 with standard transactions.
- Client-dependent versus client-independent data. Most business and customizing data is client-dependent. Some data is client-independent and applies to the whole system, such as ABAP programs, repository objects, and certain system-wide settings.
- Organisational anchor. Every other unit in this tutorial, such as the company code, plant, and storage location, is defined inside a client.
How the client appears in tables
Client-dependent tables have a client field as the first key field. In SAP ERP this field is called MANDT. The key of a material stock table, for example, begins with MANDT, followed by the material, plant, and storage location.
Open SQL handles this for you. By default, a SELECT on a client-dependent table reads only the client you are logged on to. You do not write MANDT in the WHERE clause.
DATA lv_werks TYPE werks_d VALUE '1000'.
SELECT lgort, lgobe
FROM t001l
WHERE werks = @lv_werks
INTO TABLE @DATA(lt_storage_locations).This query returns storage locations for plant 1000 in the current client only. Another client may define plant 1000 with different storage locations, and those rows are never returned here.
You can read the current client at runtime from the system field sy-mandt.
WRITE: / 'Logged on to client', sy-mandt.Client-dependent customizing and its consequences
Customizing settings, such as the definition of company codes and plants, are normally stored per client. Two practical consequences follow.
- A new client does not automatically contain your enterprise structure. You must define or copy it.
- Changes made in one client do not affect another, unless a transport or client copy carries them across.
Clients are created and maintained in transaction SCC4. Copying the contents of one client into another uses the client copy tools, such as SCCL. Treat both as administrator tasks, because a client copy can overwrite existing data.
Choosing how many clients you need
A common pattern keeps each client dedicated to a purpose.
| Client purpose | Typical content |
|---|---|
| Customizing | Configuration is made here and then transported onward |
| Test | Test master data and transactions for quality checks |
| Production | Real business data and live postings |
Putting several independent businesses in separate clients of one production system is possible but has trade-offs. Cross-client reporting is hard, and some system-wide settings are shared. Many organisations prefer one production client and use company codes to separate legal entities.
Exercise
A query on a client-dependent table in a program returns no rows in client 200, though you saw matching rows in client 100. Give two likely reasons, and say what the query does not need in its WHERE clause.
Show answer
Either the data was never created in client 200, because master data and customizing are stored per client, or the customizing was not copied or transported there. Open SQL filters on the current client automatically, so the WHERE clause does not need to mention MANDT.
Exercise
Why can company code 1000 exist in two clients of the same SAP system without conflict?
Show answer
The client is the first key field of client-dependent tables, so the full keys differ (client 100 plus 1000, and client 200 plus 1000). Each client is a separate, isolated set of data.