Wednesday, April 20, 2011

Add or Subtract to Date

Add or Subtract by Day or Month or by Year.

REPORT zvv_test.

parameters: p_date type sy-datum , " original date

p_days type T5A4A-DLYDY, " no of days to be added

p_month type T5A4A-DLYMO, " no of months to be added

p_year type T5A4A-DLYYR . " no of years to be added

skip.

parameters:add type T5A4A-SPLIT radiobutton group g1 , " to add the values

sub type T5A4A-SPLIT radiobutton group g1. " to subtract the values

data: calc_date type sy-datum,

days type T5A4A-DLYDY,

months type T5A4A-DLYMO,

years type T5A4A-DLYYR ,

sign type T5A4A-SPLIT .

if add = 'X'.

sign = '+'.

else.

sign = '-'.

endif .

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = p_date

days = p_days

months = p_month

SIGNUM = sign

years = p_year

IMPORTING

CALC_DATE = CALC_DATE.

write:/ 'the result date is:' , calc_date .

if add = 'X'.

write:/ 'days added' , p_days .

write:/ 'months added', p_month.

write:/ 'years added', p_year .

else .

write:/ 'days subtracted', p_days .

write:/ 'months subtracted', p_month.

write:/ 'years subtracted', p_year .

endif.

No comments:

Post a Comment