Sub topic 2
Clients as the unit of business data separation
Prerequisites
This chapter assumes you can log on to SAP GUI and run transaction codes. It also assumes you know what a database table and its key are, and that you have heard the word "client" in an SAP context. It does not assume you have set up a client yourself.
What a client is
A client is the highest organizational unit in an SAP system. It is a self-contained business and technical unit. Each client has its own master data, transaction data, user master records and Customizing settings. Several clients can live in one system, and they share the same database, the same installed software and the same repository objects.
Technically, a client is a value in the first key field of most tables. That field is usually named MANDT and has the data type CLNT (three characters, such as 100). When you log on, you type a client number. The system stores it in the system field sy-mandt for the whole session.
Think of a client as a tenant in a multi-tenant application. Users in client 100 cannot see the business data of client 200 through normal application transactions, even though both sets of rows sit in the same physical tables.
Why clients exist
Clients let one installation serve several purposes without installing the software several times. Typical uses:
- Separating Customizing, testing and training activities inside one system.
- Running a sandbox where consultants can try settings without affecting the main development client.
- Hosting separate legal entities or business groups that must not share business data.
In practice, most projects use clients to separate roles in a landscape (development, quality assurance, production), and each of those roles usually lives in its own system. Using one client per business group inside a production system is possible, but it is less common today because it complicates support and upgrades.
How the client is applied to data
The client is part of the table key, so each row belongs to exactly one client. Open SQL, the database access layer of ABAP, adds the client condition for you. If you read a client-dependent table, you only get rows for the current logon client.
The following report reads company codes from table T001. There is no MANDT condition in the statement, yet only rows of the current client are returned.
REPORT zdemo_company_codes.
SELECT bukrs, butxt, ort01, waers
FROM t001
ORDER BY bukrs
INTO TABLE @DATA(company_codes).
LOOP AT company_codes INTO DATA(cc).
WRITE: / cc-bukrs, cc-butxt, cc-ort01, cc-waers.
ENDLOOP.Run it in client 100 and then in client 200 of the same system. You will see different lists if the company codes were defined differently in each client. The code is identical. Only sy-mandt changed.
Because the client handling is automatic, you rarely write WHERE mandt = ... yourself. Native SQL bypasses this protection, so it is a common source of data leaks between clients when developers use it carelessly.
What is shared and what is separate
The split between shared and separate data matters, because it decides what a change affects.
| Kind of data | Scope | Example |
|---|---|---|
| Client-dependent | One client only | Company codes, customer master, sales orders, user master records |
| Cross-client | All clients in the system | Programs, table definitions, data dictionary objects |
Both kinds exist in the same system. The next chapter covers the distinction in detail. For now, remember the practical result: a change to a cross-client object is visible in every client the moment it is activated, while a change to client-dependent data affects only the client where you made it.
Client settings in SCC4
Each client has attributes that control how it behaves. You maintain them in transaction SCC4, and they are stored in table T000. The settings that matter most for this tutorial are:
- Client role. A category such as Production, Test, Customizing, Demonstration, Training/Education or SAP reference. It is informational and also used by some tools to decide what is allowed.
- Changes and transports for client-specific objects. Controls whether Customizing changes are allowed and whether they are recorded in a request.
- Cross-client object changes. Controls whether repository and other cross-client objects can be changed from this client.
- Client protection. Restricts actions such as client copy and comparison tools.
The next report reads these values for the current client.
REPORT zdemo_client_settings.
SELECT SINGLE mandt, mtext, cccategory, cccoractiv, ccnocliind
FROM t000
WHERE mandt = @sy-mandt
INTO @DATA(client_settings).
IF sy-subrc = 0.
WRITE: / client_settings-mandt, client_settings-mtext,
/ 'Role:', client_settings-cccategory,
/ 'Change recording:', client_settings-cccoractiv,
/ 'Cross-client changes:', client_settings-ccnocliind.
ENDIF.T000 is itself a special case: it holds one row per client and is not filtered by the logon client the way ordinary tables are. The WHERE mandt = @sy-mandt condition is therefore a deliberate choice here, so you read only your own client's row.
Why the client role matters for transports
The client settings decide where a configuration change can be made and whether it can travel. In a typical landscape:
- The development system has a Customizing client where changes are allowed and recorded.
- The quality system has a test client where Customizing changes are locked, so settings arrive only by import.
- The production client allows no direct Customizing changes at all.
If recording is switched off in a client, you can change settings there and nothing is captured for transport. The same setting in another system then differs silently. That is one of the most common causes of "it works in test but not in production". Later chapters build on this when they cover how a change lands in a request.
Common errors
- Assuming a client is a separate system. Clients share the repository and all cross-client data. A program change in client 100 is live in client 200 too.
- Customizing in the wrong client. If a team makes configuration changes in a client that is not the designated Customizing client, those changes may never reach the transport route.
- Forgetting the logon client in tests. A test that passes in client 100 can fail in client 200 simply because the master data or settings there are different.
- Using native SQL without a client condition. The statement reads rows from every client. Use Open SQL unless you have a specific reason not to.
- Leaving recording open in production. Allowing direct changes in a production client weakens audit and change control.
Exercises
Exercise
A report that reads table T001 with Open SQL and no MANDT condition returns 12 rows in client 100 and 3 rows in client 200 of the same system. Why do the results differ, and which table tells you how each client is configured?
Show answer
T001 is client-dependent, so Open SQL adds the condition on the logon client automatically (sy-mandt) and returns only that client's rows. Client 100 and client 200 hold different company codes. The client attributes, such as role and change recording, are stored in table T000 and maintained in transaction SCC4.
Exercise
A consultant changes a setting in a quality-system client and later finds the production system does not have the change. Name two client-related reasons that could explain it.
Show answer
First, the client may have change recording switched off in SCC4, so the change was never written to a Customizing request. Second, the change may have been made in a client that is not on the transport route, or directly in a test client, so it was never released and imported into production. (Another valid answer: the setting is client-dependent, and it was imported into a different client than the one being tested.)