on 2024 Dec 05 5:30 AM
Hello Experts,
Is it possible to get the count of entries from multiple tables (with no linkage) into a single CDS view.
Actually we are trying to use this CDS for reconciliation purposes and send this information to non SAP data lake to compare the count of records.
Thank You.
Vinod
Request clarification before answering.
Thank yo all for the reply.
As mentioned tried to resolved the issue with Union All, and it worked.
As mentioned by @Sandra_Rossi the output looks exactly same. I have added more tables now to get the count of records against table as an output.
Code :
<General anntaions>
@EndUserText.label: 'Count Recon Test'
define view ZTEST_COUNT_VB1 as
select from mara as a {
'MARA' as TableName,
count(*) as RecordCount
}
union all select from makt as b {
'MAKT' as TableName,
count(*) as RecordCount
}
union all select from kna1 as c {
'KNA1' as TableName,
count(*) as RecordCount
}
union all select from cdpos as d {
'CDPOS' as TableName,
count(*) as RecordCount
}
One can go on adding tables along with Union All statement.
Thank You
Vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can do that with AMDP easily. If you must have a CDS interface, you can prepare the CDS in the form of a table function and write AMDP behind it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank You All for your reply. I just tried with below code (Union All) and seems like it worked without AMDP and Table Function. Please provide your feedback if see any issue
@AbapCatalog.sqlViewName: 'ZTESTCOUNTVB1'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Count Recon Test'
define view ZTEST_COUNT_VB1 as select from mara as a {
'MARA' as TableName,
count (*) as RecordCount
}
union all select from makt as b {
'MAKT' as TableName,
count (*) as RecordCount
}
union all select from kna1 as c {
'KNA1' as TableName,
count (*) as RecordCount
}
| User | Count |
|---|---|
| 17 | |
| 8 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.