Skip to Content
0
Sep 18, 2023 at 05:41 AM

Dynamic Date Range - Set default values in OData v2

118 Views

We have created a List-Report using ABAP CDS. We are using dynamic date rate. Our requirement is to set the default date range as 2 weeks i the past (14 days) until 4 weeks in the future (28 days).

Below code is working when we set the TODAYFROMTO as default, but it is taking -1day to +1 day as the default range.

                    "settings": {
                        "condensedTableLayout": true,
                        "smartVariantManagement": true,
                        "enableTableFilterInPageVariant": true,
                        "filterSettings": {
                            "dateSettings": {
                                "useDateRange" : false,
                                "fields": {
                                    "vfdat": {
                                        "defaultValue": {
                                            "operation": "TODAYFROMTO"
                                        },
                                        "selectedValues": "TOMORROW,TODAYFROMTO,LASTYEAR ",
                                        "exclude" :false
                                    }
                                }
                            }                           
                        }
                    }

image.png

We want to set this to -14 days to +28 days

We found a code snippet in help.sap relating to this, but it seems like this will work only in Odata V4 (we are using V2)

image.png

Is there any way to achieve this with Odata V2?

Attachments

image.png (25.5 kB)
image.png (5.2 kB)