Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
uladzislau_pralat
Contributor
937

I wish S/4HANA ABAP CDS views supported date-to-factory-date conversion using an out-of-the-box built-in function, similar to currency or unit conversion. Unfortunately, that’s not the case. But don’t worry—I’ve got you covered with a custom-built S/4HANA ABAP CDS view.

S/4HANA provides DATE_CONVERT_TO_FACTORYDATE standard function module for date-to-factory-date conversion. Base on factory, for example, CA Canada:

uladzislau_pralat_0-1737040490889.png

 

The function module converts date to closest next factory date (default "+" conversion option):

uladzislau_pralat_2-1737040875350.jpeg

or closest prior factory date ("-" conversion option):

uladzislau_pralat_3-1737040914086.jpeg

The same date-to-factory-date conversion can be achieved using custom-built ABAP CDS view 

uladzislau_pralat_4-1737041466998.png

All it takes a simple custom built ABAP CDS view

uladzislau_pralat_6-1737041728164.jpeg

uladzislau_pralat_0-1737054646707.png

Above code does a trick transforming pivoted and nested factory calendar data 

uladzislau_pralat_8-1737044160689.jpeg

into factory calendar on date level

uladzislau_pralat_0-1738352486659.jpeg

followed by a couple of window functions to find next and previous factory date for first / last week-end or holiday date

uladzislau_pralat_0-1737651483013.png

and copy it over to other week-end / holiday dates as well fill next factory date / previous factory date for weekdays.

uladzislau_pralat_1-1737651537888.png

Source code for the CDS view can be downloaded below:

ZI_FactoryCalendar 

ZCL_FACTORY_CALENDAR 

 

 

 

 

 

 

 

 

Labels in this area