Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Defaulting date 3 months from present date

Former Member
0 Likes
1,611

HI!

In my selection screen in my report I need to default a

selection option to a future date which is 3 months from the

present date. Can anyone tell me whats the way to do this so

that I can add 3 montsh from the present date and default it in my selection screen.

example : if we consider todays date then we need to

default that date to 9th of september 2008 so it keeps of

changing everyday as dates proceed.

Thanks

HI!

In my selection screen in my report I need to default a

selection option to a future date which is 3 months from the

present date. Can anyone tell me whats the way to do this so

that I can add 3 montsh from the present date and default it in my selection screen.

example : if we consider todays date then we need to

default that date to 9th of september 2008 so it keeps of

changing everyday as dates proceed.

Thanks

10 REPLIES 10
Read only

Former Member
0 Likes
1,386

use FM : BKK_ADD_MONTH_TO_DATE

Read only

Former Member
0 Likes
1,386

hi,

do this way ...


initialization.
V_DATE = SY-DATUM.
p_date = v_date + 90.
. 

Read only

Former Member
0 Likes
1,386

hi,

You can even use RP_CALC_DATE_IN_INTERVAL FM


parameters output_date type sy-datum.
data input_date type sy-datum.

initialization.
input_date = sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = input_date
days = '00'
months = '03'
signum = '+'
years = '00'
IMPORTING
calc_date = output_date. 

Regards,

Santosh

Read only

0 Likes
1,386

I have a my selection screen like this and if I try adding just 90 to it it gives me error , and regarding using FM , do I really need to use the FM to have this working as its just the selection screen , I am not sure..

p_rb2 RADIOBUTTON GROUP G1,

p_date AS CHECKBOX MODIF ID 234,

p_bedat TYPE vbak-guebg DEFAULT sy-datum MODIF ID 234,

p_endat TYPE vbak-gueen MODIF ID 234,<------

p_rental AS CHECKBOX MODIF ID 234.

<----- need to default this as present date plus 3 months.

Thanks

Read only

0 Likes
1,386

hi,

I am not getting any error in this way ......


parameters : p_rb1 RADIOBUTTON GROUP G1.
parameters : p_rb2 RADIOBUTTON GROUP G1,
p_date AS CHECKBOX MODIF ID 234,
p_bedat TYPE vbak-guebg DEFAULT sy-datum MODIF ID 234,
p_endat TYPE vbak-gueen MODIF ID 234, " 2008/09/07
p_rental AS CHECKBOX MODIF ID 234.  

initialization.
p_endat = sy-datum + 90. 

Read only

Former Member
0 Likes
1,386

TABLES bseg.
DATA: l_date TYPE sy-datum.
SELECT-OPTIONS: s_date FOR bseg-bzdat.

INITIALIZATION.
  CALL FUNCTION 'ADD_TIME_TO_DATE'
    EXPORTING
      i_idate                     = sy-datum
      i_time                      = '3'
      i_iprkz                     = '2'
*   I_RDMHD                     =
   IMPORTING
     o_idate                     = l_date
   EXCEPTIONS
     invalid_period              = 1
     invalid_round_up_rule       = 2
     internal_error              = 3
     OTHERS                      = 4.
  MOVE l_date TO s_date-high.
  s_date-sign = 'I'.
  s_date-option = 'EQ'.
  APPEND s_date.
Read only

Former Member
0 Likes
1,386

Check the below program :

REPORT ZTEST78 .

data v_fdate type d.

CALL FUNCTION 'HR_PSD_DATES_ADD_MONTHS'

EXPORTING

V_DATE = sy-datum

V_MONTHS = 3

IMPORTING

E_DATE = v_fdate

  • EXCEPTIONS

  • NOT_POSITIVE = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

write:/ v_fdate.

do not add 90 days ,some months may have 31 or 29 or 28,you will not get exact calculation,so use FM 'HR_PSD_DATES_ADD_MONTHS'

Thanks

Seshu

Thanks

Seshu

Read only

Former Member
0 Likes
1,386

Yes the dates are showing defaulted to 3 months from now . I have another question to it , if in my report I want to show the result based on these dates itself, like when I check this checkbox which has the dates inbeteen present date and 3 months from now as done in selection screen , how do I show the output based on this selection. As of now when I check this checkbox i.e with valid dates from today to valid date upto 3 months from now , it still is showing me the entire report and not the contracts in between these dates. Can anyone help me in explaining this please.

Thanks

Read only

0 Likes
1,386

you need to use that date in the select statement, in the where condition..clause..

Read only

Former Member
0 Likes
1,386

;;;