cancel
Showing results for 
Search instead for 
Did you mean: 

Help in variables

Former Member
0 Kudos

Hi All,

Iam having a requirement where in during the execution of a Query, my user would enter the value for Calender date,

then my report should bring the data for same date for previous months.

Say for eg: if my user enters 27th April 2006, then my report should have data for 27th March 2006, 27th Feb 2006, 27th jan2006...... 27th April 2005.

can anyone help me in this regard.

Thanks and regards,

Manick

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Manick,

You can use offsets or you can use CMOD on the variables.

Robably it is better with offsets.

Let me know if you need more information.

Ciao.

Riccardo.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Manick,

The logic is the following.

You have a user entry variable. Create 11 customer exit variables. Determine the month of this date (5th & 6th characters) and the year (first 4 characters).

In the exit subtract the number of month (1,2... 11) depending on the variable from the determined date month.

If the result of subtraction is less or equal zero, add 12 and subtract 1 from determined year.

Then replace by the month and year the appropriate parts of the entered date.

Create a structure in columns. In each selection put your KF and 0CALDAY restricted by appropriate variable.

Think it over what you will do if the user enters 31 day of the month (not all month have so many days).

Search forums for the code samples. Believe with them you'll be able to write the code by yourself.

Best regards,

Eugene

former_member184494
Active Contributor
0 Kudos

Meiappan ,

curious that there is such a request for a report .. what happens for dates like 31st Jan ? or 30th April ... which would invalidate February , and other months without 31 days ...?

Is this a case for client education ? and keeping this in mind , should the report calculate for the last 30 days or the same date last month ?

Calculating for the value 30 days before is much easier , make the client see reason in the same instead of some convoluted logic for arriving at the right date.

Hope this helps ...

Arun

Former Member
0 Kudos

Hi All,

My requirement doesn`t bother about the number of days in a month...

instead the user must be able to compare his sales for the same date last monthsss...

The number of previous month required is constant say for eg 12...

i tried the same using offset variables... i was only able to get the previous month alone and not for previous 12 months...

can this achieved using offset variable...???

if we have to write exit, then can anyone give a sample code for this case...

Regards,

Manick

Former Member
0 Kudos

Hi

Created 12 seperate Rsetricted kf's using the same variable .

starting from 1 you can go on change the offset of variable in each restr. kf

Hope this helps

Shiva

former_member184494
Active Contributor
0 Kudos

Meiappan ,

I am not sure if you got my question ,

what happens if the user enters 31st March , what will the previous column be ? 31st february ?? ... the gregorian calendar would turn in its grave!!! and in all likelihood you will get a short dump if you do not provide for this logic.

how do you intend to resolve that ? accordingly any exit / offset / variable logic will have to be written.

My 0.02

Arun Varadarajan

Former Member
0 Kudos

Hi

is the no of previuos months are fixed, then create a variable on date and use the offset.

Hope this helps

Shiva