cancel
Showing results for 
Search instead for 
Did you mean: 

One Month Default Date on Variable.

Former Member
0 Kudos

Hi Folks,

I need to create a date variable with one month default vaules.

e.g if i ran the query today the selection would be from 02/13/07 to 03/13/07.

How can I accomplish that?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you want to remove the user input and use a range of todays date to the same day one month ago, you could create a user exit variable. The code would be something like this:

WHEN '<Variable Name Here>'.
    W_DATE = SY-DATUM.
    W_DAY = W_DATE+6(2).
    W_MTH = W_DATE+4(2).
    W_YEAR = W_DATE(4).
    
    IF W_MTH = 1.
        W_MTH = 12.
        W_YEAR = W_YEAR - 1.
    ELSE
        W_MTH = W_MTH - 1.
    ENDIF.

    CONCATENATE W_YEAR W_MONTH W_DAY INTO W_DATE.

    ZE_T_RANGE-LOW = W_DATE.
    ZE_T_RANTE-HIGH = SY-DATUM.
    ZE_T_RANGE-SIGN = 'I'.
    ZE_T_RANGE-OPT = 'EQ'.
    APPEND ZE_T_RANGE TO E_T_RANGE.

So, this will keep the same day value for both ends of the range, and make the low end equal to the current month value minus 1. In the case that the month is January, it sets the month equal to December and subtracts one from the year.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kara.

You will have to define a customer exit variable.

Please take a look at this link:

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/f1/0a56f5e09411d2acb90000e829fbfe/content.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/f1/0a56f5e09411d2acb90000e829fbfe/content.htm</a>

You can also find lots of links if you search the forums for "customer exit".

Hope it helps.

BR

Stefan