вторник, 1 июля 2014 г.

Exclude calendar weekends

    DATA:
      lt_day_attributes TYPE TABLE OF casdayattr
     .

     RESULT 0.
     IF   SOURCE_FIELDS-csm_clda <> SOURCE_FIELDS-csm_crda
       AND SOURCE_FIELDS-csm_clda IS NOT INITIAL
       AND SOURCE_FIELDS-csm_crda IS NOT INITIAL.

        "Exclude calendar weekends
        CALL FUNCTION 'DAY_ATTRIBUTES_GET'
          EXPORTING
            factory_calendar           'RU'
            holiday_calendar           'RU'
            date_from                  SOURCE_FIELDS-csm_crda
            date_to                    SOURCE_FIELDS-csm_clda
          TABLES
            day_attributes             lt_day_attributes
          EXCEPTIONS
            factory_calendar_not_found 1
            holiday_calendar_not_found 2
            date_has_invalid_format    3
            date_inconsistency         4
            OTHERS                     5.

        DELETE lt_day_attributes WHERE FREEDAY 'X' OR HOLIDAY 'X'.
        DESCRIBE TABLE lt_day_attributes LINES RESULT.

        IF RESULT > 0.
          SUBTRACT FROM RESULT.
        ENDIF.
      ENDIF.

Комментариев нет: