I am creating a CDS view to fetch records from ACDOCA. My requirement is to fetch records from ACDOCA and for the combination of Company code, fiscal year and document number, i want to fetch the customer of the minimum line item of a particular document for which customer is not blank. For eg: -
BUKRS GJAHR BELNR DOCLN KUNNR
Gb11 2018 100001 01 ABCD
Gb11 2018 100001 02
Gb11 2018 100001 03 XYZA
Gb11 2018 100001 04 EFGH
Gb11 2018 100001 05
In the above scenario, for a combination of ( BUKRS+GJAHR+BELNR ), minimum line item for which KUNNR is not null is 01 for which KUNNR is ABCD. So in my CDS view, I want to populate the blank KUNNR rows for a Combination of BUKRS+GJAHR+BELNR with the KUNNR of minimum line item KUNNR so that my CDS view output should look like below.
BUKRS GJAHR BELNR DOCLN KUNNR
Gb11 2018 100001 01 ABCD
Gb11 2018 100001 02 ABCD
Gb11 2018 100001 03 XYZA
Gb11 2018 100001 04 EFGH
Gb11 2018 100001 05 ABCD
Can anyone help me out wih the logic, to build a CDS view so that ACDOCA hit is minimum. Since we are dealing with ACDOCA, which has a huge record base. So we want to hit ACDOCA as minimum times as possible.
Thanks in advance.