使用函数RP_CALC_DATE_IN_INTERVAL进行日期的年月日的加减

data LV_DATE type DATS.

** Add/Substract years to date
call function 'RP_CALC_DATE_IN_INTERVAL'
 exporting
  DATE = SY-DATUM
  DAYS = 0
  MONTHS = 0
  SIGNUM = '-' " to calculate previous date
  YEARS = 1
 importing
  CALC_DATE = LV_DATE.

WRITE: 'Today', SY-DATUM, /.
WRITE: 'Previous year', LV_DATE, /.

** Add/Substract months to date
call function 'RP_CALC_DATE_IN_INTERVAL'
 exporting
  DATE = SY-DATUM
  DAYS = 0
  MONTHS = 1
  SIGNUM = '+' " to calculate following date
  YEARS = 0
 importing
  CALC_DATE = LV_DATE.

WRITE: 'Today', SY-DATUM, /.
WRITE: 'Next month', LV_DATE, /.

** Add/Substract days to date
call function 'RP_CALC_DATE_IN_INTERVAL'
 exporting
  DATE = SY-DATUM
  DAYS = 7
  MONTHS = 1
  SIGNUM = '+' " to calculate next dates
  YEARS = 2
 importing
  CALC_DATE = LV_DATE.

WRITE: 'Today', SY-DATUM, /.
WRITE: 'Add 2 Years, 1 Month and 7 Days (or 1 week)', LV_DATE, /.

发布了372 篇原创文章 · 获赞 76 · 访问量 355万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术工厂 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览