1

Check Table exist and display its records in CDS

 1 month ago
source link: https://community.sap.com/t5/application-development-discussions/check-table-exist-and-display-its-records-in-cds/td-p/13674602
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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.

Check Table exist and display its records in CDS
shilpi-a

shilpi-a

Explorer

yesterday

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
BiberM

BiberM

Active Participant

2 hours ago

this is exactly the behavior of LEFT OUTER JOIN.

Best regards, 

Michael

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK