Ansicht
Dokumentation

ABENINSERT_CLIENT_ABEXA - INSERT CLIENT ABEXA

ABENINSERT_CLIENT_ABEXA - INSERT CLIENT ABEXA

BAL_S_LOG - Application Log: Log header data   General Material Data  
This documentation is copyright by SAP AG.
SAP E-Book

INSERT, CLIENT

This example demonstrates client handling in the statement INSERT.

Source Code

Execute

Description

The example demonstrates how the additions USING CLIENT and CLIENT SPECIFIED are used in INSERT statements that use various subqueries as data sources. The example uses two DDIC database tables, the client-dependent table DEMO_CLNT and the client-independent table DEMO_NO_CLNT, which are linked in the subqueries using a join.

  • First, DELETE statements are used to delete all data in both DDIC database tables without specifying a condition or a source. For the client-dependent table, the addition USING ALL CLIENTS is used to delete the data of all clients.
  • INSERT statements are then used to fill both tables with data from internal tables constructed in a host expression. For the client-dependent table, the addition CLIENT SPECIFIED is used to respect the client IDs in the client column of the internal table.
  • The output shows the result set of the query used as a subquery in the following INSERT statement. This query uses the addition USING CLIENT to ensure that data from the client 100 is read. A LEFT OUTER JOIN between the client-dependent table and client-independent table produces a null value in the client column.
  • When the result set of the subquery is inserted, INSERT also uses the addition USING CLIENT. This ensures that the content of the client column of the subquery is overwritten by the value 100 for each row. This means that the null value itself is ignored. The result is shown in the output.
  • The next output shows the result set of a further query that uses the addition USING CLIENTS IN @rtab instead of USING CLIENT. The ranges table also selects only the client 100, which means that the result is the same as in the preceding query.
  • However, a difference arises when the query is used as a subquery in an INSERT statement. USING CLIENTS IN @rtab is interpreted in such a way that the client ID of the subquery is to be inserted, which is why implicit client handling by the INSERT statement using CLIENT SPECIFIED has to be switched accordingly. Since the client column of the subquery contains a null value, the corresponding exception is raised.
  • The final INSERT statement bypasses the exception by using the COALESCE function in the SELECT list to replace the null value with the client ID 100.





Vendor Master (General Section)   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 3768 Date: 20240425 Time: 092939     sap01-206 ( 49 ms )