• 计算两个日期之间的工作日


    兰大顾的。。。

    FUNCTION zget_workdays.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(I_DATE1) LIKE  SY-DATUM
    *"     VALUE(I_DATE2) LIKE  SY-DATUM
    *"  EXPORTING
    *"     VALUE(E_DAYS) TYPE  I
    *"----------------------------------------------------------------------
      DATA: week1   TYPE scal-week,
            monday1 TYPE sy-datum,
            sunday1 TYPE sy-datum,
            week2   TYPE scal-week,
            monday2 TYPE sy-datum,
            sunday2 TYPE sy-datum,
            days1    TYPE i,
            days2    TYPE i,
            wotnr1   TYPE p,
            wotnr2   TYPE p.
    
      CHECK i_date2 GE i_date1.
    
      CALL FUNCTION 'DAY_IN_WEEK'
        EXPORTING
          datum = i_date1
        IMPORTING
          wotnr = wotnr1.
    
      CALL FUNCTION 'DAY_IN_WEEK'
        EXPORTING
          datum = i_date2
        IMPORTING
          wotnr = wotnr2.
    
      "计算开始日期所在周
      CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
        EXPORTING
          date   = i_date1
        IMPORTING
          week   = week1
          monday = monday1
          sunday = sunday1.
    
      "计算结束日期所在周
      CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
        EXPORTING
          date   = i_date2
        IMPORTING
          week   = week2
          monday = monday2
          sunday = sunday2.
    
      IF week1 EQ week2.
        IF wotnr1 GE 5.
          e_days = 0.
          EXIT.
        ELSE.
          IF wotnr2 LE 5.
            e_days = i_date2 - i_date1 .
          ELSEIF wotnr2 EQ 6.
            e_days = i_date2 - i_date1 - 1.
          ELSEIF wotnr2 EQ 7.
            e_days = i_date2 - i_date1 - 2.
          ENDIF.
        ENDIF.
      ELSE.
        IF wotnr1 gt 5.
          days1 = 0.
        ELSE.
          days1 = sunday1 - 2 - i_date1 + 1.
        ENDIF.
    
        IF wotnr2 GT 5 .
          days2 = 4.
        ELSE.
          days2 = i_date2 - monday2.
        ENDIF.
    
        e_days = ( week2 - week1 - 1 ) * 5 + days1 + days2.
    
      ENDIF.
    
    
    ENDFUNCTION.
  • 相关阅读:
    操作系统——第四章 文件管理
    操作系统——第三章 内存管理
    操作系统——第二章 进程管理
    last-child到底怎么用
    Https个人总结
    白话https
    RSA算法
    算法导论笔记:11散列表(哈希表)
    算法导论笔记:10基本数据结构(番外)
    算法导论笔记:09中位数和顺序统计量
  • 原文地址:https://www.cnblogs.com/sapSB/p/7047732.html
Copyright © 2020-2023  润新知