SAP CLIENT HANDLING - Guide



Get Example source ABAP code based on a different SAP table
  



Client Handling

ABAP_BACKGROUND
A client indicates a data area in an AS ABAP database that contains independent application data. The application data of different clients use the same database tables, but are flagged with a three-figure client ID within these tables.
When logging on to AS ABAP, this client ID must be entered. This selects the client whose data is processed by the user session. The current client is entered in the system field sy-mandt.
AB-SQL statements work with implicit client handling, where the data of the current client is accessed by default. This is specified by passing an implicit condition for the current client to WHERE conditions, and ignoring clients specified in modifying statements in work areas. Implicit client handling in AB_SQL can be switched to one more different clients by using the addition USING in queries or the additions USING or CLIENT SPECIFIED in write statements.
Native SQL and ADBC do not apply implicit client handling. The client in question does not need to be selected explicitly when Native SQL or AMDP is used to access client-dependent database tables or views.

ABAP_RULE
Do not access the data of other clients
In the persistency services of business applications, access the data of the current client only.

ABAP_DETAILS
Each client within the AS ABAP is to be viewed as a self-contained unit. The additions USING CLIENT and CLIENT SPECIFIED should not be used in AB-SQL statements of business applications. When Native SQL or AMDP is used, only the current client should be selected.
The system field sy-mandt does not generally need to be evaluated, unless Native SQL or AMDP is used to access client-dependent database tables or views. The client ID is then needed to select the data of the current client explicitly.



Latest notes:

Client-independent database tables (tables without client ID) are usually system tables. This means that client-independent access to these tables is also reserved for system programs.
The addition CLIENT SPECIFIED is fully obsolete in queries and partially obsolete in write statements.
ABAP_HINT_END

ABAP_EXAMPLE_BAD
The following source code demonstrates AB-SQL access on application data where implicit client handling is switched to a different client. SELECT SINGLE ...
FROM scarr USING '...'
WHERE ... ...
INTO ...
ABAP_EXAMPLE_END

ABAP_EXAMPLE_GOOD
The following source code demonstrates the recommended use of AB_SQL where implicit client handling accesses the current client by default. SELECT SINGLE ...
FROM scarr
WHERE ...
INTO ...
ABAP_EXAMPLE_END