Sie sind auf Seite 1von 24

3/7/2019 Dynamic date selection in Variants | SAP Blogs

Products
Products Industries
Industries Services and Support
Services Support Training
Training Community
Community Developer
Developer

Partner
Partner About
About

 
Ask a Question Write a Blog Post Login

Anup Patil
July 24, 2012 4 minute read

Dynamic date selection in Variants


Follow RSS feed Like

36 Likes 126,702 Views 46 Comments

Dear All,

While answering one of the post related to screen variant creation/setup for SAP transactions, I thought of preparing a small document
on the same and sharing the same on forum. It might be possible that most of the SAP guru’s knowing this function but this blog will be
helpful to new comers in SAP…

So what’s it about… It’s about creating screen variants for SAP transactions with dynamic selections as desired.

Take an example of widely used QM transaction-QA32.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 1/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Above QA32 screen has a field-Lot Created On, with a date range already populated on initial screen. So how these dates are appearing?
And can I set my own date range here? Can I have any other fixed value on the same screen e.g. Plant ? Number of questions can come
up in mind…

To answer, yes, a respective user can set his/her own variant with specific values. I’m planning to explain it below, with few screenshots.

On Tcode-QA32 screen, click on ‘SAVE’. System will display an existing variant as below, showing a variable set for a particular field, if
any.

Put your own Variant Name along with meaning.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 2/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

As seen on above screen there are few functions available as SAP standard in variant attributes. E.g.

– Only for Background Processing: If you select the field Background only, the variant can only be executed in the background.
Otherwise, it can be run both in the background and online.

– Protect Variant: If you select this field, the variant can only be changed by the person who created it or last changed it.

Based on requirement one can select/deselect it.

Search for the field on which a dynamic/variable date needs to be setup. Go to column-Type of selection variable (Third from right hand
side) and click on the dropdown icon or press F4 to show the popup menu for the selection variable.

Double-click on the line “D” for dynamic date calculation. Selecting ‘type of variable’ is nothing but we are declaring the field which
need dynamic date calculation.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 3/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

To mention a dynamic value, we need to select a Variable. Click on the dropdown icon or press F4 on column-Name of variable to show
available selection variables.

You need to select a sign field which allows to enter either “I” or “E”.

“I” (Inclusive) means that the single value or range you specified is selected itself.

“E” (Exclusive) means that the single value or range you specified is excluded from the selection.

The default is “I”.


Along with the sign field, need to select ‘Option’. With the operators in this field, you specify whether the entered values are to be used
as a single value, range, or search string for limiting data selection. Possible operators are: EQ- Equal: Single Value, NE- Not Equal:
Everything Apart from the Specified Single Value, LE- Less or EQUAL: Everything <= Value in Field LOW, GT- Greater Than:
Everything > Value in Field LOW, GE- Greater or Equal: Everything >= Value in Field LOW and LT-Less Than: Everything < Value in
Field LOW.

Once you fill in selection variables on screen, click on ‘SAVE’.


On transaction selection screen, click on tab-Get Variant (Shift+F5) and select your own variant. Depending upon selection variables,
system will populate a particular field with required values (as below).

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 4/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Similarly, you can even choose other operators and check effect.

I chose option operator as ‘Less Than’ and variable as ‘Current Date +/- ??? days’. System will come up with a pop-up window and ask
value for days.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 5/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Put value with sign ‘-‘ in order to have date in past from current date whereas sign ‘+’ for future date.

Click on ‘SAVE’ & go back. Select your Variant to check.

In addition to above, we can chose a variable to set a date range. For the same, choose Variable name: Current date – xxx, current date +
yyy.

System will ask for date values as below.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 6/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Press Enter.

Click on save and go back (F3). Select your variant.

And you will see dates as per Variable selected (shown below).

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 7/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Similar way, one can try different options of variables.

Along with it, just by adding field values on initial screen and saving the variant, system will put some fixed values. E.g. one can have
his/her Plant as fixed value in his/her variant.

Hope this will help.

Thanks & Regards,

Anup

Alert Moderator

Assigned tags

SAP ERP | screen variants |

Related Blog Posts

Dynamic Selection for Scheduling a Program


By Gajendra Moond , Feb 19, 2015
Business Partner Identi cation record
By Sherry Wang , Jul 25, 2018
Create COND_A IDocs in Background Job
By Former Member , Dec 02, 2015

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 8/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Related Questions

Logical database ADA, only table ANLAV elds appearing in Dynamic selection criteria
By Kimmo Sirpoma , Oct 16, 2018
Compound Journal Entries G/L Account Line Item Display
By Jamie Pedro , Jun 21, 2019

Delete email adress stored in numerous variants


By Petria Claudiu , Apr 23, 2018

46 Comments

You must be Logged on to comment or reply to a post.

Anup Patil | Post author

July 27, 2012 at 10:55 am


Forgot to mention but comments will be appreciated… Thanks.

Like (1)

Former Member

July 27, 2012 at 12:11 pm


Good job

Like (0)

Andrea Fuschetto

July 8, 2014 at 3:35 pm


Hello Anup:

I’m changing my Planning area in both DP and SNP from 2 years to 5 years in monthly buckets.  I need to
release my forecast from DP into SNP for all buckets.  In the variant, I see the choice for “Current day +/-
days”.  When I try to enter any value over 1000 days, I get an error saying it can’t accept it (too long).

Entry too long (enter in the format __~V)

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 9/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

It appears that only 3 characters are accepted, so 999 is my limit.  But this is only 33 months instead of 60
months.

Do you know how I can get an option to enter “Current month +/- months”?  Then I could say “60 months”

I’m using /n/sapapo/mc90 to release the fcst from DP to SNP.

Thanks.

Andrea

Like (0)

Thomas Zloch

July 9, 2014 at 7:12 am


At the bottom of the choices for dynamic date calculation, I can see

“(Beginning of mth-xx months, end of mth+yy months)”

Try this for your scenario.

Thomas

Like (0)

Andrea Fuschetto

July 9, 2014 at 1:34 pm


Hi Thomas:

I wish I had that option.  In APO (mc90 and also in lcout), these are my choices.  (I’m selecting from Current
Date row, which is about 7 or 8 down in the list):

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 10/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Current Date

Current date +/- ??? days

current date +/- ??? work days

First day of current month

nth working day of current month

First day of next month

First day of previous month

Last day of previous month

Last Day of the Current Month

Do you know how I can get the “Beginning of mth-xx-months, end of mth+yy months” option to show?  That
would be perfect and exactly what I need.

Thanks.

Andrea

Like (0)

Thomas Zloch

July 9, 2014 at 1:57 pm


I don’t know in what way APO is special in this regard. For “normal” selection variants there is a function
module RS_VARI_V_INIT which collects the available options for dynamic date calculation.

I have SAP_BASIS 700 to 731 systems here, and all have the option I quoted above. What is your SAP_BASIS
level?

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 11/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

I once had the idea to enhance this function module to include a new option at the end (driven by a new Z-
function module that would contain the calculation logic), but enhancements there are forbidden by SAP with
a hint to “central basis” component.

Thomas

Like (0)

Andrea Fuschetto

July 9, 2014 at 2:15 pm


They must have used di erent programmers for APO because it is very di erent than ECC.  I see tons of other
choices in ECC, but only the ones I listed above in APO. 

I’m going to post in an APO forum and see what suggestions I get.

Thanks for the response, though.

Andrea

Like (0)

Jason Duncan

July 28, 2012 at 12:50 am


Great post here. I wish I had this the rst time I had to setup a variant. It would have made it much easier.

Like (0)

Anup Patil | Post author

July 28, 2012 at 2:38 pm


Thanks Jason for your appreciation and apologies for posting this a bit late…

But still you can go-in and change/overwrite your existing variants in SAP.

Thanks again.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 12/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Like (0)

Former Member

October 17, 2012 at 7:42 pm

How do I get all the dynamic date variables.  For instance, I do not have any that say “quarter”.   I only have
these:

Current Date

Current date +/- ??? days

current date +/- ??? work days

First day of current month

nth working day of current month

First day of next month

First day of previous month

Last day of previous month

Last Day of the Current Month

Like (0)

Jeevan Sagar

October 17, 2012 at 9:36 pm


What version of SAP are you on?

Like (0)

Former Member

October 17, 2012 at 10:06 pm


Actually its in APO.  But I am asking how to create new ones in general.  What if I wanted a new dynamic
variable for end of the year.   I know I can use TVARV variables.  But is it possible to create new dynamic date
variables.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 13/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Like (0)

Sven Ringling

July 28, 2013 at 9:37 pm


Hi Ken,

I happened upon this post only now, but maybe it’s still interesting for you:

if you need any additional variables, you can de ne them yourself in table TVARVC.

I the popup “choose selection variables” shown above you select T rather than D to access those variables.

However, you now need to take care of them being updated yourself. Could be manually in transaction
STVARVC or SM31, but usually you’d have a custom ABAP running in Batch every night (or whatever frequency
is needed) to update the values.

In older versions (R/3 4.5, if I remember correctly, not sure about APO), it was TVARV rather than TVARVC.
The old table was not client dependant.

Like (0)

Former Member

June 21, 2013 at 12:36 pm


Dear,

        Very informative !!

Like (0)

Pawan Kesari

June 21, 2013 at 1:08 pm


Good document.

Like (0)

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 14/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Samy Magdy

June 26, 2013 at 10:33 am


Nice one.

Like (0)

Thanga Prakash

March 19, 2014 at 12:41 pm


How can I create a dynamic variant for date only in TO, like below.

Date  <BLANK>  TO  <Current date – 365 days>

Like (0)

Thomas Zloch

March 19, 2014 at 12:50 pm


You would rather do it like “Date LE <Current date – 365 days>” using only the FROM date.

Thomas

Like (0)

Thanga Prakash

March 19, 2014 at 1:04 pm


If I do like that I will end up like below.

Created on 19.03.2013 TO <blank>.

My requirement is like FROM should be the initial date and TO should be current date – 365 days like.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 15/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Created on <blank> TO 19.03.2013.

Like (0)

Thomas Zloch

March 19, 2014 at 1:22 pm


But this means you want everything up to 19.03.2013. You can set “LE” (less or equal) as “option” for the
dynamic date variant “current date +/- ??? days” and that should do it.

Thomas

Like (0)

Former Member

April 15, 2014 at 9:35 am


Thanks, great post. I have a report which requires a date range including a working day and a non-working day.
I need the ‘date from’ to be working day – 1 and the ‘date to’ being yesterday.

This is so that on a Monday, document postings from Friday to Sunday are picked up. Does anyone know if this
is possible via SQ02 if not in the variant?

Thanks

Like (0)

Narayana N

April 19, 2014 at 6:13 pm


Dear Anup,

Good e ort keep it up

Regards,

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 16/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Narayan N

Like (0)

Former Member

June 19, 2014 at 12:27 pm


Thanks Anup , this is really helping me to understand the dynamic data .

Like (0)

Former Member

July 9, 2014 at 2:05 pm


I knew about this before, but it’s great to have it written down. Great post!

Like (0)

Former Member

August 6, 2014 at 10:33 am


nice document but i need Segment eld where i can get his eld.

Like (0)

Former Member

September 9, 2014 at 5:55 pm


Thank you.  Learned something new today.

Like (0)

Poonam Chawla

October 9, 2014 at 6:28 pm


Hi,

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 17/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

I have a requirement for date range where the rst date is xed (01/23/2013) and last date is current date
which varies depending on sy-datum.

Which option will help me to get this resolved.is it possible with dynamic selection screen?

Kindly reply.

Like (0)

Anup Patil | Post author

November 8, 2014 at 9:48 pm


Hi Poonam,

You can simply put in date value as ‘greater than or equal to 01/23/2013 (your xed date)’ in date eld and I
think it should work.

So whenever you run your report/program, system will take documents from that date (01/23/2013) to
current date on which you’re executing it.

Hope it helps.

Thanks.

Kind Regards,

Anup

Like (0)

Poonam Chawla

January 10, 2015 at 9:14 am


Thank you Anup

Like (0)

Kashi Yadaram

October 9, 2014 at 8:55 pm

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 18/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Excellent…wish I know this before.

Kashi

Like (0)

Former Member

November 19, 2014 at 1:18 pm


Exactly what I needed Thank you

Like (0)

Former Member

January 9, 2015 at 3:24 pm


Hello All,

My requirement is to select the variant “Current date + 0 , Current date + 50” in working days but when i
select the variant Date – xxx, Date + yyy(work days), it doesn’t work.

Could anyone help or give any suggestion regarding this?

Thanks,

Shashank

Like (0)

Anup Patil | Post author

January 14, 2015 at 7:40 pm


Hi Shashank,

I’ve given printscreen of the requirement same as yours & de nitely it would work.

Could you please check again in my blog about this & try?
https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 19/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Thanks.

Like (0)

John McKee

July 10, 2015 at 5:21 am


Hi

This is excellent material here.

However, I would like to know how we can use this with the updated data browser SE16N?
I have a requirement to run an extract for some HR data from table PA0001.
I want to extract all records where End Date is greater than the current date -1 and Start Date is less than
Current date +1, e ectively status as at today, eg ENDDA > 09.07.2015 and BEGDA <11.07.2015 meaning status
as at 10.07.2015 – but to have this update dynamically at run time.

I know how to do this in SE16 and save as a variant using Dynamic Date Calculation.

But how do you do this with and SE16N variant and schedule with SE16N_BATCH.  I can’t nd where to store
these parameters with SE16N?

Can this be done?

John McKee

Like (0)

Anup Patil | Post author

September 25, 2015 at 2:45 pm


Hi John,

Thanks for your comments above. Also to mention, I never tried this function in SE16N but shall check.
Thanks.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 20/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs
Like (0)

Former Member

July 16, 2015 at 12:14 pm


Really good stu .. thanks

Like (1)

Former Member

February 19, 2016 at 9:52 am


Very Useful

Like (1)

Timothy Bondy

April 26, 2016 at 4:41 pm


Thank you this was very helpful

Like (1)

Former Member

April 29, 2016 at 12:04 pm


Hello,

Need your suggestions to understand what am I doing wrong here.

I use a ZZ T-code which provide me a list with Purchase Orders, then I created a Variant to display only the last
working day PO’s created, and it is working well as your guidance above.

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 21/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

The problem appeared when I created a daily basis Job on SM36, to run this Variant with the dynamic date, the
result list of the Job display always the same day as the Job creation date, instead of getting updated after the
days past by.

If someone can help me with this, it will be of great assistance.

Best regards

Like (0)

Former Member

August 9, 2016 at 3:27 am


Hi,

What if we want these dates in “Exclude” selection column? How can we do that?

Thanks,

Like (0)

Former Member

August 11, 2016 at 11:01 am


Very useful article but it is possible to set rst and last date of current week? I can’t see any mention about it.

Like (0)

Subhadeep Kar

October 4, 2016 at 7:07 pm


Helpful Anup.

Like (1)

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 22/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

karan kothari

November 9, 2016 at 11:00 am


Hi

I am having requirement to create screen variant for a transaction that is executed based on scal year
parameter. I want to make it dynamic.

For eg. if I run the transaction today then it should executed for current scal year “-2”.

How we can do the same? Please Guide!!

Thanks
Karan 

Like (0)

Former Member

December 22, 2016 at 1:43 pm


many thanks for share this Anup

Like (1)

Former Member

August 16, 2017 at 1:55 pm


Very helpful. Thanks for Sharing.

Like (1)

Former Member

March 2, 2018 at 8:39 am


Dear Anup.

Many thanks for this useful document !

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 23/24
3/7/2019 Dynamic date selection in Variants | SAP Blogs

Share & Follow

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Preferencias para cookies

Sitemap Newsletter

https://blogs.sap.com/2012/07/24/dynamic-date-selection-in-variants/ 24/24

Das könnte Ihnen auch gefallen