2018 Jul 31 3:23 PM
Hi,
If the users execute the report on today's Date , I would like to fetch the sales orders created as on last day of last month IN ABAP CDS View.
Thanks,Naveen.2018 Aug 02 2:34 AM
1. Create a CDS view Table function with just one attribute - let's say lastDayofPrevMonth
2. Implement this table function with logic like below:
select last_day( add_months(current_date, -1 ) ) as "lastDateofPrevmonth" from dummy
3. Inner Join this view with your original sales order CDS View on the created date column.
2018 Aug 01 10:43 AM
Hello Naveen,
Create CDS view with input parameters (Refer help - https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenselect_cds_para_abexa.htm) and pass the last day of previous month to the CDS view via parameters (search SCN as there are associated threads for the same).
Still as a pointers, FM - SN_LAST_DAY_OF_MONTH / RP_LAST_DAY_OF_MONTHS
Regards,
Kiran
2018 Aug 01 3:01 PM
Hi Kiran,
Thank you for your suggestion , but in my requirement there is no input parameter.
I need to get the last day of the previous month in CDS view without input parameter.
Thanks,
Naveen.
2018 Aug 01 2:58 PM
Hi Kiran,
Thank you for your suggestion , but in my requirement there is no input parameter.
I need to get the last day of the previous month in CDS view without input parameter.
Thanks,
Naveen.
2018 Aug 02 2:34 AM
1. Create a CDS view Table function with just one attribute - let's say lastDayofPrevMonth
2. Implement this table function with logic like below:
select last_day( add_months(current_date, -1 ) ) as "lastDateofPrevmonth" from dummy
3. Inner Join this view with your original sales order CDS View on the created date column.
2021 Mar 10 11:40 AM
it works perfectly. but it displays date in format 21-02-28
Is there a option to convert it to 2021-02-28 ?
Regards,
Mehmet
2019 Jan 29 9:36 AM
Hello Naveen,
I also came across this problem today. A workaround would be: get the first day of the current month by replacing the last 2 digit to '01', then +1 month and -1 day to this date.
Test:
define view ZTest_DAT as select from usr02 {
erdat, --Test Date
DATS_ADD_DAYS(
DATS_ADD_MONTHS(
cast( concat( left( erdat, 6 ), '01' ) as abap.dats ), --FirstDay
1, 'FAIL'),
-1, 'FAIL')
as LastDay
}
Result:
Best regards,
Haolin
2019 Jan 29 10:16 AM
Why posting here? The question is different: "Last day of the previous month". Moreover, the question has already been answered correctly.
2019 Sep 11 2:59 PM
I disagree Sandra,
His answer is very helpfull because he is not going thrue a CDS View Table Function
Regards,
Alexandre