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: 

CDS Views: return most recent record

tafkap95
Participant
0 Kudos
199

Hi,

I am new to CDS View and I am facing a simple problem I guess.

My CDS View entity is defined as:

define view entity ZV_SER03
  as select from ZV_OBJK_1_MAX as objk
  association [1] to ser03 on ser03.obknr = objk.obknr
{
  key ser03.obknr,
      objk.matnr,
      ser03.datum,
      ser03.uzeit
}
where
      ser03.werk     = objk.b_werk
  and ser03.lagerort = objk.b_lager
  and ser03.shkzg    = 'S';

And here is an example of the result it returns:

matnr;obknr;datum;uzeit
0000000000002364065;32983;20270605;160321
0000000000002364065;33043;20230606;113445
0000000000006666666;33047;20240606;113526
0000000000066666666;33048;20230606;114025
0000000000007777777;33051;20230606;114117

From this example I would like to create a new CDS view entity that returns for each MATNR/OBKNR the most recent record, from the datum and uzeit fields.

The result from the example above should therefore be:

matnr;obknr;datum;uzeit
0000000000002364065;32983;20270605;160321
0000000000006666666;33047;20240606;113526
0000000000007777777;33051;20230606;114117

Thanks in advance for your help.

 

2 REPLIES 2

geek
Participant

0 Kudos
104

I've only skimmed it so far but it looks very interesting, thank you very much. 😉