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: 

How to create selection variables in range parameter?

Former Member
0 Kudos
1,162

I have a date field that has a start and end date in a variant.

It is defined by a select option as i.e.  s_date for vbap-erdat.  And shows on screen as two fields - one for start of the date range and one for the end of the date range.

My need is to have the start date automatically fill with a date 90 days prior to the current date.  I do not have a problem using the 'selection variables' to create that.

But do not know how do a use the selection variables to have the end date in the range default to today's date.

I have found where someone did this can got the date range to look like this in the selection variables : "current_date - 90 , current date - 0" but I do not know how they did this.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
722

I found the selection variable that works - no need to do anything in the program.

9 REPLIES 9

arivazhagan_sivasamy
Active Contributor
0 Kudos
722

Hi Scott,

Write a code in Initialization event like below.

Initialization.

DATE1 = SY-DATUM - 90.

S_DATE-SIGN = 'I'.

S_DATE-OPTION = 'BT'.

S_DATE-LOW = DATE1.

S_DATE-HIGH = SY-DATUM.

APPEND S_DATE.

Arivazhagan S

edgar_nagasaki
Contributor
0 Kudos
722

Hi Scott,

Wouldn't simply to assign end date as 'current date' instead of 'current date -' work?

Regards,

Edgar

Former Member
0 Kudos
722

Hope I understand u

TABLES: t000.
SELECT-OPTIONS s_date FOR t000-CHANGEDATE.

INITIALIZATION.
  s_date-low = sy-datum - 90.

  s_date-high = sy-datum.

  APPEND s_date.

If you look for it in the variant sceen.

In the parameters tables. look for columns: "Selection Variables" and select the 'D'

In column 'Name of variable" Press F4 and select 'Current date - xxx,current date + yyy'

Good Luck

RaymondGiuseppi
Active Contributor
0 Kudos
722

What is your exact problem

  • Defining/using the variant using the date variable -> Assigning a Date Calculation Variable
  • Using the variant in the report -> Use RS_SUPPORT_SELECTIONS or similar FM or use variant in a transaction definition

Else you could use INITIALIZATION event to fill the select-options/range internal table (sign='I', option='BT' and fill low/high subfields before appending to range)

Regards,

Raymond

Former Member
0 Kudos
723

I found the selection variable that works - no need to do anything in the program.

atul_mohanty
Active Contributor
0 Kudos
722

Hi Scott -

Here is the code.

TABLES : vbap.

SELECT-OPTIONS : s_date FOR vbap-erdat.

INITIALIZATION.
  s_date-low = sy-datum - 90.
  s_date-high = sy-datum.
  s_date-sign = 'I'.
  s_date-option = 'BT'.

  APPEND s_date.

Let us know, if it helps.

Regards,

Atul Mohanty

edgar_nagasaki
Contributor
0 Kudos
722

Hi Scott,

Please share the solution

Thanks,

Edgar

0 Kudos
722

To set selection variables to date range where fist is minus 90 days and second is the current date:

Use the "selection variables' button  and then select the  'CURRENT DATE - XXX DAYS, CURRENT DATE - YYY' format.

It will prompt you to enter values in ot XXX and YYY.

Replace XXX with 90 days (it will go back 90 days - no negative sign needed).  Replace YYY with 0 and it will take current date - 0 = current date.

For example:  Date From: 10/23/2013  To Date:  10/21/2014

0 Kudos
722

Oh, got it!

Thanks Scott!