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

date ranges(5 months)

naveen_inuganti2
Active Contributor
0 Likes
1,127

Hi all...

Iam having one date field in the selection screen....

so when i excuted the program i have to get exact five months back date as low range and current date as high range...

thank you,

Naveen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,077

Hi,

do like this.


select-options:s_date for sy-datum.
data:past_date type sy-datum.

initialization.
s_date-high = sy-datum.
past_date = sy-datum.
past_date+4(2) = past_date+4(2) - 5.
IF past_date+4(2) <= 0.
  past_date(4) = past_date(4) - 1.
  past_date+4(2) = 12 - ( 5 - sy-datum+4(2) ).
ENDIF.
s_date-low = past_date.
append s_date.

rgds,

bharat.

Hi all...

Iam having one date field in the selection screen....

so when i excuted the program i have to get exact five months back date as low range and current date as high range...

thank you,

Naveen

6 REPLIES 6
Read only

Former Member
0 Likes
1,077

you mean you want to display the dates on selection screen

itself?

then you can query in

At selection screen output

something like

select date from table where s_low = sy-datum-

i guess this is what you want ?

Hope it helps else if you clear a little bit more

Read only

peter_ruiz2
Active Contributor
0 Likes
1,077

hi naveen,

use this code


CALL FUNCTION 'CCM_GO_BACK_MONTHS'
  EXPORTING
    currdate         = v_today
    backmonths       = 5
  IMPORTING
    NEWDATE          = v_mback.

regards,

Peter

Read only

Former Member
0 Likes
1,077

Hi,

1.Call this Function module in Initialization.

2.You can use the function module 'SALP_CALC_DATE'.

Pass 'M' to IN_RECTYPE, '-5' to IN_NBR_DWXMQY and current date to IN_DATE import parameters of the function module.

Regards,

Shiva kumar

Read only

Former Member
0 Likes
1,078

Hi,

do like this.


select-options:s_date for sy-datum.
data:past_date type sy-datum.

initialization.
s_date-high = sy-datum.
past_date = sy-datum.
past_date+4(2) = past_date+4(2) - 5.
IF past_date+4(2) <= 0.
  past_date(4) = past_date(4) - 1.
  past_date+4(2) = 12 - ( 5 - sy-datum+4(2) ).
ENDIF.
s_date-low = past_date.
append s_date.

rgds,

bharat.

Read only

Former Member
0 Likes
1,077

Hi

You can make use of the code below :



Ranges : gr_date for bsis-budat.

data : gv_datum like sy-datum.

  CALL FUNCTION 'CCM_GO_BACK_MONTHS'
    EXPORTING
      currdate   = sy-datum
      backmonths = '5'
    IMPORTING
      newdate    = gv_datum.

gr_date-sign = 'I'.
gr_date-option = 'BT'.
gr_date-low = gv_datum.
gr_date-high = sy-datum.
append gr_date.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,077

Hi Naveen

try the following

data : bk_date type sy-datum.

select-options: so_date for sy-datum.

INITIALIZATION.

call function 'CCM_GO_BACK_MONTHS'

exporting

currdate = sy-datum

backmonths = 5

importing

newdate = bk_date.

.

clear so_date.

so_date-sign = 'I'.

so_date-option = 'BT'.

so_date-low = bk_date.

so_date-high = sy-datum.

append so_date.

reward if useful.

Regards

Prabumanoharan