Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Check Table exist and display its records in CDS

shilpi-a
Explorer
0 Kudos
497

Hi Experts,

I have a scenario where I want to fetch records from standard table 'A' and display in a CDS.
Also, need to get records from custom table 'B' if it exists in server and display in same CDS.

So, if table - B exists then CDS should have records from both the tables (A & B)
else records from table A only.

kindly suggest me some way to get this resolved.

Thanks.

2 REPLIES 2

BiberM
Active Participant
0 Kudos
443

Hi,

this is exactly the behavior of LEFT OUTER JOIN.

 

Best regards, 

Michael

shilpi-a
Explorer
0 Kudos
421

I may not have explained my issue correctly. Let me try with tables and output expected.

Table A

Order (Key)Notification (Key)Operation (Key)Notification text
4000000100000000010notif txt 1
4000001100000010020notif txt 2

Custom Table B (if exist) will not have any data for Order, Operation . It will have data for Notification.

Notification (Key)Notification text
10000003Desc 1
10000004Desc 2
  

Output expected in CDS :

Order (KeyNotification (Key)Operation (Key)Notification text
4000000100000000010notif txt 1
4000001100000010020notif txt 2
 10000003 Desc 1
 10000004 Desc 2

if I add association / join :  i need to be confirmed that table B exist in system. only then i will be able to use that table and access its fields

if i add table function : we have to mention all tables which will be getting used in that method.

shilpia_0-1713507405533.png

 


so, if the table does not exist then i will give error and table function will not activate.

Please suggest what can be other ways.

Thanks.