cancel
Showing results for 
Search instead for 
Did you mean: 

Wanted: I_CalendarDate like ABAP CDS View for Work Days of a Factory Calendar in S/4HANA

WRoeckelein
Active Participant
0 Kudos

Hi,

I am searching for a I_CalendarDate like ABAP CDS View which delivers only the working days as per a specified Factory Calendar in S/4HANA. I would prefer a released CDS view.

I there something better than VFCLM_BAM_DDL_DATE3 available?

Thanks,

Wolfgang

filipn
Active Participant
0 Kudos

I_FACTORYCALENDAR?

WRoeckelein
Active Participant
0 Kudos

filipn I_FactoryCalendar is only the factory calender object and not the working days of the factory calendar, take eg a look at the primary key which is only cr_wfcid and not also eg scal_tt_date.calendardate ...

Accepted Solutions (0)

Answers (3)

Answers (3)

WRoeckelein
Active Participant
0 Kudos

Hi Jøran,

are those

else '0' end

really needed? Wouldn't this defeat some optimiziations?

Regards,

Wolfgang

WRoeckelein
Active Participant
0 Kudos

Hi Jøran,

thank you very much, good idea, similar to what VFCLM_BAM_DDL_DATE3 does, but with no unions, so should be faster.

I still think SAP should provide something OOB ie a released CDS view entity.

Regards,

Wolfgang

joran13
Discoverer
0 Kudos

I agree Wolfgang, SAP should provide this feature OOB.

Br, Jøran

joran13
Discoverer
0 Kudos

Hi Wolfgang,

Came across your question and perhaps you have reached a solution. But if someone can find my approach to the problem useful I'll post what I found as a working solution anyway.

My problem was, like you: I could not find a SAP released CDS view, that lists only working dates from a factory calendar. My solution is very simple but it serves my purpose to get at selectable view with working dates only for any factory calendar.

To get a CDS view that only lists dates that are working days, you probably need to define a new CDS on top of this proposal, selecting only workdays like this. as select from ZI_FactoryCalendar ....where workday eq '1'.

@AbapCatalog.sqlViewName: 'ZTFACSDATES'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Factory calendar workday calendar'
define view ZI_FactoryCalendar
  as

  select from  tfacs _cal
    inner join scal_tt_year _year   on(
        _year.calendaryear = _cal.jahr
      )
    inner join scal_tt_month _month on(
      _month.calendaryear = _year.calendaryear
    )
    inner join scal_tt_date _date   on(
        _date.calendaryear      = _month.calendaryear
        and _date.calendarmonth = _month.calendarmonth
      )
{

  key _date.calendardate         as CalendarDate,

      ident                      as FactoryCalendar,
      jahr                       as CalendarYear,

      _year.isleapyear           as IsLeapYear,
      _year.numberofdays         as NumberOfDaysInYear,

      _month.calendarmonth       as CalendarMonth,
      _month.firstdayofmonthdate as FirstDateOfMonth,
      _month.lastdayofmonthdate  as LastDateOfMonth,

      _date.weekday              as Weekday,


      case _date.calendarmonth
       when '01' then
            case _date.calendarday
              when '01' then substring(mon01, 01, 1 )
              when '02' then substring(mon01, 02, 1 )
              when '03' then substring(mon01, 03, 1 )
              when '04' then substring(mon01, 04, 1 )
              when '05' then substring(mon01, 05, 1 )
              when '06' then substring(mon01, 06, 1 )
              when '07' then substring(mon01, 07, 1 )
              when '08' then substring(mon01, 08, 1 )
              when '09' then substring(mon01, 09, 1 )
              when '10' then substring(mon01, 10, 1 )
              when '11' then substring(mon01, 11, 1 )
              when '12' then substring(mon01, 12, 1 )
              when '13' then substring(mon01, 13, 1 )
              when '14' then substring(mon01, 14, 1 )
              when '15' then substring(mon01, 15, 1 )
              when '16' then substring(mon01, 16, 1 )
              when '17' then substring(mon01, 17, 1 )
              when '18' then substring(mon01, 18, 1 )
              when '19' then substring(mon01, 19, 1 )
              when '20' then substring(mon01, 20, 1 )
              when '21' then substring(mon01, 21, 1 )
              when '22' then substring(mon01, 22, 1 )
              when '23' then substring(mon01, 23, 1 )
              when '24' then substring(mon01, 24, 1 )
              when '25' then substring(mon01, 25, 1 )
              when '26' then substring(mon01, 26, 1 )
              when '27' then substring(mon01, 27, 1 )
              when '28' then substring(mon01, 28, 1 )
              when '29' then substring(mon01, 29, 1 )
              when '30' then substring(mon01, 30, 1 )
              when '31' then substring(mon01, 31, 1 )
              else '0' end

       when '02' then
            case _date.calendarday
              when '01' then substring(mon02, 01, 1 )
              when '02' then substring(mon02, 02, 1 )
              when '03' then substring(mon02, 03, 1 )
              when '04' then substring(mon02, 04, 1 )
              when '05' then substring(mon02, 05, 1 )
              when '06' then substring(mon02, 06, 1 )
              when '07' then substring(mon02, 07, 1 )
              when '08' then substring(mon02, 08, 1 )
              when '09' then substring(mon02, 09, 1 )
              when '10' then substring(mon02, 10, 1 )
              when '11' then substring(mon02, 11, 1 )
              when '12' then substring(mon02, 12, 1 )
              when '13' then substring(mon02, 13, 1 )
              when '14' then substring(mon02, 14, 1 )
              when '15' then substring(mon02, 15, 1 )
              when '16' then substring(mon02, 16, 1 )
              when '17' then substring(mon02, 17, 1 )
              when '18' then substring(mon02, 18, 1 )
              when '19' then substring(mon02, 19, 1 )
              when '20' then substring(mon02, 20, 1 )
              when '21' then substring(mon02, 21, 1 )
              when '22' then substring(mon02, 22, 1 )
              when '23' then substring(mon02, 23, 1 )
              when '24' then substring(mon02, 24, 1 )
              when '25' then substring(mon02, 25, 1 )
              when '26' then substring(mon02, 26, 1 )
              when '27' then substring(mon02, 27, 1 )
              when '28' then substring(mon02, 28, 1 )
              when '29' then substring(mon02, 29, 1 )
              else '0' end

* code blocks March through September, removed due to space limit 20 000 chars in blog.

       when '10' then
            case _date.calendarday
              when '01' then substring(mon10, 01, 1 )
              when '02' then substring(mon10, 02, 1 )
              when '03' then substring(mon10, 03, 1 )
              when '04' then substring(mon10, 04, 1 )
              when '05' then substring(mon10, 05, 1 )
              when '06' then substring(mon10, 06, 1 )
              when '07' then substring(mon10, 07, 1 )
              when '08' then substring(mon10, 08, 1 )
              when '09' then substring(mon10, 09, 1 )
              when '10' then substring(mon10, 10, 1 )
              when '11' then substring(mon10, 11, 1 )
              when '12' then substring(mon10, 12, 1 )
              when '13' then substring(mon10, 13, 1 )
              when '14' then substring(mon10, 14, 1 )
              when '15' then substring(mon10, 15, 1 )
              when '16' then substring(mon10, 16, 1 )
              when '17' then substring(mon10, 17, 1 )
              when '18' then substring(mon10, 18, 1 )
              when '19' then substring(mon10, 19, 1 )
              when '20' then substring(mon10, 20, 1 )
              when '21' then substring(mon10, 21, 1 )
              when '22' then substring(mon10, 22, 1 )
              when '23' then substring(mon10, 23, 1 )
              when '24' then substring(mon10, 24, 1 )
              when '25' then substring(mon10, 25, 1 )
              when '26' then substring(mon10, 26, 1 )
              when '27' then substring(mon10, 27, 1 )
              when '28' then substring(mon10, 28, 1 )
              when '29' then substring(mon10, 29, 1 )
              when '30' then substring(mon10, 30, 1 )
              when '31' then substring(mon10, 31, 1 )
              else '0' end

       when '11' then
            case _date.calendarday
              when '01' then substring(mon11, 01, 1 )
              when '02' then substring(mon11, 02, 1 )
              when '03' then substring(mon11, 03, 1 )
              when '04' then substring(mon11, 04, 1 )
              when '05' then substring(mon11, 05, 1 )
              when '06' then substring(mon11, 06, 1 )
              when '07' then substring(mon11, 07, 1 )
              when '08' then substring(mon11, 08, 1 )
              when '09' then substring(mon11, 09, 1 )
              when '10' then substring(mon11, 10, 1 )
              when '11' then substring(mon11, 11, 1 )
              when '12' then substring(mon11, 12, 1 )
              when '13' then substring(mon11, 13, 1 )
              when '14' then substring(mon11, 14, 1 )
              when '15' then substring(mon11, 15, 1 )
              when '16' then substring(mon11, 16, 1 )
              when '17' then substring(mon11, 17, 1 )
              when '18' then substring(mon11, 18, 1 )
              when '19' then substring(mon11, 19, 1 )
              when '20' then substring(mon11, 20, 1 )
              when '21' then substring(mon11, 21, 1 )
              when '22' then substring(mon11, 22, 1 )
              when '23' then substring(mon11, 23, 1 )
              when '24' then substring(mon11, 24, 1 )
              when '25' then substring(mon11, 25, 1 )
              when '26' then substring(mon11, 26, 1 )
              when '27' then substring(mon11, 27, 1 )
              when '28' then substring(mon11, 28, 1 )
              when '29' then substring(mon11, 29, 1 )
              when '30' then substring(mon11, 30, 1 )
              else '0' end

       when '12' then
            case _date.calendarday
              when '01' then substring(mon12, 01, 1 )
              when '02' then substring(mon12, 02, 1 )
              when '03' then substring(mon12, 03, 1 )
              when '04' then substring(mon12, 04, 1 )
              when '05' then substring(mon12, 05, 1 )
              when '06' then substring(mon12, 06, 1 )
              when '07' then substring(mon12, 07, 1 )
              when '08' then substring(mon12, 08, 1 )
              when '09' then substring(mon12, 09, 1 )
              when '10' then substring(mon12, 10, 1 )
              when '11' then substring(mon12, 11, 1 )
              when '12' then substring(mon12, 12, 1 )
              when '13' then substring(mon12, 13, 1 )
              when '14' then substring(mon12, 14, 1 )
              when '15' then substring(mon12, 15, 1 )
              when '16' then substring(mon12, 16, 1 )
              when '17' then substring(mon12, 17, 1 )
              when '18' then substring(mon12, 18, 1 )
              when '19' then substring(mon12, 19, 1 )
              when '20' then substring(mon12, 20, 1 )
              when '21' then substring(mon12, 21, 1 )
              when '22' then substring(mon12, 22, 1 )
              when '23' then substring(mon12, 23, 1 )
              when '24' then substring(mon12, 24, 1 )
              when '25' then substring(mon12, 25, 1 )
              when '26' then substring(mon12, 26, 1 )
              when '27' then substring(mon12, 27, 1 )
              when '28' then substring(mon12, 28, 1 )
              when '29' then substring(mon12, 29, 1 )
              when '30' then substring(mon12, 30, 1 )
              when '31' then substring(mon12, 31, 1 )
              else '0' end

       else '0'
      end                       as Workday

}

Best reagards

Jøran Sanna