Error while creating Database view in ABAP

30 Views Asked by At

I am trying to create a database view in ABAP Dictionary.

I have given the join condition for tables table_a and table_b as table_a-data = table_b-data.

I have mentioned all the primary key fields in the view fields tab and I have mentioned where conditions where Mandt = '602' and facing the following errors

  1. selection condition is not permitted for client

  2. field table_a-data does not belong to base table.

I have tried to modify the comparison value but didn't work. also switched the tables order to eliminate the error with base table but didn't work.

1

There are 1 best solutions below

0
Satish Kumar On

You cannot hardcode the client value in selection conditions.

Follow the below steps for proper handling of client in database view

  • In Table/Join conditions, use table_a-mandt = table_b-mandt (so that data from cross clients is not used in join condition)
  • Have MANDT as the first field in View Fields (so that compiler can pass current client as default value during data selection).

If you want access to cross-client data, you can achieve the same using CLIENT SPECIFIED or USING CLIENT key words as below.

SELECT * from DataBaseView USING CLIENT '062' into table @data(lt).

SELECT * from DataBaseView CLIENT SPECIFIED where mandt = '062' into table @data(lt).