Check Table exist and display its records in CDS
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.
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.
- SAP Managed Tags:
- ABAP Development
- Labels:
- ABAP CDS Views
this is exactly the behavior of LEFT OUTER JOIN.
Best regards,
Michael
- SAP Managed Tags:
- ABAP Development
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 |
4000000 | 10000000 | 0010 | notif txt 1 |
4000001 | 10000001 | 0020 | notif 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 |
10000003 | Desc 1 |
10000004 | Desc 2 |
Output expected in CDS :
Order (Key | Notification (Key) | Operation (Key) | Notification text |
4000000 | 10000000 | 0010 | notif txt 1 |
4000001 | 10000001 | 0020 | notif 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.
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.
- SAP Managed Tags:
- ABAP Development
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK