ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP SQL → ABAP SQL - Overview
ABAP SQL - Client Handling
As a term, client handling describes the way application data in a client is handled. Client handling is generally employed to restrict user access to the application data to only the client whose client ID was specified in the logon. ABAP SQL uses implicit client handling. This method of client handling dictates that ABAP SQL statements handle the client column in a special way when client-specific data sources are accessed:
- The client column cannot be evaluated in the
SQL conditions of the
SELECT
statements of queries and of the write statementsUPDATE SET
andDELETE FROM
.
- Instead, the SQL statements passed to the database by the ABAP SQL interface contain an additional condition for the client column.
- Furthermore, joins between client-specific data sources insert an
ON
condition that checks the client columns for equality.
- The variants of the write statements
INSERT
,UPDATE
,MODIFY
, andDELETE
, which use data from work areas, internal tables, or subqueries specified afterFROM
, ignore their client columns and the value is set by ABAP SQL instead.
Implicit client handling uses the client ID of the current client by default. This ID is also in the
system field sy-mandt
.
- The condition passed implicitly in selections checks the content of the client column for equality with the client ID of the current client.
- In write statements, ABAP SQL uses the client ID of the current client for the client column of
the target instead of the values of the client column of the work areas, internal tables, or subqueries specified after
FROM
.
This means that ABAP SQL uses only the data of the current data by default and this does not need to be specified explicitly by the developer. Implicit client handling can, however, also be switched from the default current client to other clients using additions of the ABAP SQL statements. The cases described above must also be distinguished here:
- The implicit condition of queries and the write statements
UPDATE SET
andDELETE FROM
can be switched from the current client to other clients as follows:
- The addition
USING CLIENT
of theSELECT
statement and the addition USING CLIENT of the write statements are used to specify the client ID from the addition instead of the current client ID. Implicit client handling works as if the current user is logged on with the specified client ID.
- The additions
USING [ALL] CLIENTS [IN]
of theSELECT
statement andUSING [ALL] CLIENTS [IN]
of the write statements are used to replace the equality condition for a client with different conditions for multiple clients (or remove it completely). The condition is then polyvalent instead of monovalent.
- The value set implicitly for the client column of the work areas, internal tables, or subqueries
specified after
FROM
in write statements can be switched from the current client to other clients as follows:
- ABAP SQL uses the addition USING CLIENT to specify the client ID from the addition instead of the current ID. Implicit client handling works as if the current user is logged on with the specified client ID.
- If ABAP SQL specifies the addition CLIENT
SPECIFIED, no replacement takes place. The values of the client column of the work areas,
internal tables, or subqueries specified after
FROM
are used. In internal tables and subqueries, there may be multiple client IDs.
Alongside the case of write statements with data sources after FROM
(described
above), the addition CLIENT SPECIFIED
can also be used instead of USING
in the other cases. This use is
obsolete in queries and
obsolete in the write statements UPDATE
SET and DELETE FROM
. The addition CLIENT SPECIFIED
disables implicit client handling in full in these statements. This means that no implicit WHERE
condition is created for the client column and no ON condition is created
between the client columns in joins. The client column in the SQL conditions of the ABAP SQL statements,
on the other hand, can or must itself be evaluated. Disabling implicit client handling in this way is
prone to errors and hence not recommended. The USING
additions for switching implicit handling should be used instead.
Other versions:
7.31 | 7.40 | 7.54
Programming Guideline
Notes
- The client data from an AS ABAP is depicted in closed units. No cross-client access to databases
should take place in application programs. This is why the additions
USING
andCLIENT SPECIFIED
should never be used here. If ABAP SQL is used, there is generally no need to accesssy-mandt
in application programs either.
- For information about accessing client-specific CDS entities, see the following descriptions:
- The database table T000 contains the potential client IDs in AS ABAP. Client columns of application tables should contain only those client IDs specified in T000. This is not, however, checked by ABAP SQL.
- True multitenancy, with which the system ensures that different tenants' application data is isolated from each other, is not supported by the ABAP runtime environment in the current release.
- Native SQL and AMDP do not implement implicit client handling. The current client must always be specified explicitly here.