Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Data Definitions →  ABAP CDS - Views →  ABAP CDS - Client Handling in CDS Views 

CDS Views, Obsolete Client Handling

This example demonstrates how obsolete cross-client CDS views are handled.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA(out) = cl_demo_output=>new( ).

    out->next_section( 'Data Types' ).

    out->write(
      name = 'Not client dependent, no client field, CDS entity'
      data = CAST cl_abap_structdescr(
                    cl_abap_typedescr=>describe_by_name(
                      'DEMO_CDS_SPFLI_CLIENT_2' )
                        )->components ).

    out->write(
      name = 'Not client dependent, no client field, database view'
      data = CAST cl_abap_structdescr(
                    cl_abap_typedescr=>describe_by_name(
                      'DEMO_CDS_PRJCTN2' )
                        )->components ).

    out->write(
      name = 'Not client dependent, client field, CDS entity'
      data = CAST cl_abap_structdescr(
                    cl_abap_typedescr=>describe_by_name(
                      'DEMO_CDS_SPFLI_CLIENT_3' )
                        )->components ).

    out->write(
      name = 'Not client dependent, client field, database view'
      data = CAST cl_abap_structdescr(
                    cl_abap_typedescr=>describe_by_name(
                      'DEMO_CDS_PRJCTN3' )
                        )->components ).

    out->next_section( 'SELECT Statements' ).

    SELECT *
           FROM demo_cds_spfli_client_2
           ORDER BY carrid, connid
           INTO TABLE @DATA(result1)
           UP TO 1 ROWS.
    out->write(
      name =  'Not client dependent, no client field, CDS entity'
      data = result1 ).

    SELECT *
           FROM demo_cds_prjctn2
           ORDER BY carrid, connid
           INTO TABLE @DATA(result2)
           UP TO 1 ROWS.
    out->write(
      name =  'Not client dependent, no client field, database view'
      data = result2 ).

    SELECT *
           FROM demo_cds_spfli_client_3
           WHERE mandt = @sy-mandt
           ORDER BY carrid, connid
           INTO TABLE @DATA(result3)
           UP TO 1 ROWS.
    out->write(
      name = 'Not client dependent, client field, CDS entity'
      data = result3 ).

    SELECT *
           FROM demo_cds_prjctn3 CLIENT SPECIFIED
           WHERE mandt = @sy-mandt
           ORDER BY carrid, connid
           INTO TABLE @DATA(result4)
           UP TO 1 ROWS.
    out->write(
      name = 'Not client dependent, client field, database view,' &
             ' CLIENT SPECIFIED'
      data = result4 ).

    out->display( ).

Description

The program accesses the following CDS views:

@AbapCatalog.sqlViewName: 'DEMO_CDS_PRJCTN2'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientDependent: false
define view demo_cds_spfli_client_2
as select from
spfli
{
key spfli.carrid,
key spfli.connid,
spfli.cityfrom,
spfli.cityto
}    
@AbapCatalog.sqlViewName: 'DEMO_CDS_PRJCTN3'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientDependent: false
define view demo_cds_spfli_client_3
as select from
spfli
{
key spfli.mandt,
key spfli.carrid,
key spfli.connid,
spfli.cityfrom,
spfli.cityto
}    

They are used to demonstrate the behavior in rare cases where views with the obsolete notation ClientDependent:false are made into cross-client views even though they contain client-specific data sources:

  • DEMO_CDS_SPFLI_CLIENT_2 is a cross-client CDS view in which the client column is not specified in the SELECT list.
  • DEMO_CDS_SPFLI_CLIENT_3 is a cross-client CDS view in which the client column is specified in the SELECT list.

RTTI is used to read the components of the associated data types:

  • The structure of the cross-client CDS entity without client column in the SELECT list does not have a client column.
  • The database view of the cross-client CDS view without client column in the SELECT list has a client column.
  • The structure of the cross-client CDS entity without client column in the SELECT list does not have a client column.
  • The database view of the cross-client CDS view with client column in the SELECT list has a client column, which makes it client-specific.

The statement SELECT is used to make the following accesses:

  • Regular access to a cross-client CDS entity without client column in the SELECT list. The data is read from all clients. No conditions can be specified for the client. The results set does not have a client column.
  • Regular access to a database view of the cross-client CDS entity without client column in the SELECT list. The data is read from all clients. No conditions can be specified for the client. The results set does not have a client column.
  • Regular access to a cross-client CDS entity with client column in the SELECT list. The data of the client specified in the WHERE condition is read. It is not possible to specify the obsolete addition CLIENT SPECIFIED here. The results set has a client column.
  • Access to a database view of the cross-client CDS with client column in the SELECT list using the obsolete addition CLIENT SPECIFIED. The data of the client specified in the WHERE condition is read. The results set has a client column.


Note

The accesses to the database views of the CDS shown here are for demonstration purposes only. This way of accessing CDS views is obsolete and only the CDS entities should now be accessed.