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

How to create selection variables in range parameter?

Former Member
0 Likes
2,303

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
Read only

Former Member
0 Likes
1,863

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

9 REPLIES 9
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,863

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

Read only

edgar_nagasaki
Contributor
0 Likes
1,863

Hi Scott,

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

Regards,

Edgar

Read only

Former Member
0 Likes
1,863

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,863

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

Read only

Former Member
0 Likes
1,864

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

Read only

atul_mohanty
Active Contributor
0 Likes
1,863

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

Read only

edgar_nagasaki
Contributor
0 Likes
1,863

Hi Scott,

Please share the solution

Thanks,

Edgar

Read only

0 Likes
1,863

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

Read only

0 Likes
1,863

Oh, got it!

Thanks Scott!