cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP CDS getting count of multiple tables in one CDS

VinodB1
Explorer
0 Kudos
408

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

View Entire Topic
VinodB1
Explorer

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