Application Development 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: 

selecting RANGE of dates

Former Member
0 Kudos
8,227

hi guys,

i have a parameter field on selection screen of type SY-DATUM.

iam using RANGES to select range of dates from 1st january 2006 till the date i select

in the selection screen.

i will pass 1st january 2006 in LOW and

parameter date in HIGH.

i want to select all the dates between this range and store it into a internal table.

how can i do it.

is there any fn module or ............ how can i do.

ahmed

6 REPLIES 6

sourabhshah
Advisor
Advisor
0 Kudos
1,134

hi

Select * from dbname into itab where datefield IN <Rangestable>.

Regards,

Sourabh

0 Kudos
1,134

hi,

you can also use the BT (BeTween ... and ...) option.

take a F1 on IN or BT for futher help.

Sourabh

Former Member
0 Kudos
1,134
data : begin of it_dates occurs 0,
           dates like sy-datum,
         end of it_dates.

data: v_date like sy-datum.

loop at it_range.
  if  v_date eq ita_range-high.
    it_dates-date = it_range-high.
    append it_dates.
    cleat it_dates.
     exit.
  else.
    v_date  = it_range-low.
    it_dates-date = v_date.
    append it_dates.
    cleat it_dates.
   v_date = v_date + 1. 
  endif.
endloop.

Message was edited by:

Chandrasekhar Jagarlamudi

Former Member
0 Kudos
1,134

So what u can do is.

LOOP at range_table.

reange_table-high = Parameterdate.

modify range_table

endloop.

Use this table in the select command.

If useful reward.

Vasanth

Former Member
0 Kudos
1,134

ur range table will have low value as 01'Jan & high value as sy-datum.

Select <data> from <table> where <condition> IN <range-table>.

Former Member
0 Kudos
1,134

use below demo code and reward points if helpfull -

tables :pa0006.

data begin of itab occurs 0.

include structure pa0006.

data end of itab.

SELECT-OPTIONS : p_blartf for sy-datum.

parameters p_date like sy-datum.

INITIALIZATION.

P_BLARTF-LOW = '20060101'.

P_BLARTF-SIGN = 'I'.

P_BLARTF-OPTION = 'EQ'.

APPEND P_BLARTF.

Start-of-selection.

read table p_blartf index 1.

P_BLARTF-high = p_date.

modify p_blartf index 1.

select * from pa0006 up to 20 rows into table itab

where begda in p_blartf.

loop at itab.

write:/ itab-begda.

endloop.