Skip to Content

Business Scenario:

1) We have been asked to create a Report where the Input Ready variable on FISCPER; such that it will have default values from January of the current year till previous month of current year. If the Report is being executed on January of current year, the variable will have default values from January of last year till December of last year.

Users may also provide their desired range of values for viewing the data.

2) In the Report display, users want to see a field Average Headcount which should give the average of number of people present in each organization between the selected time period.

For e.g, if we execute the Report a son today, as pe rthe selection variable design, data from Jnauary 2015 to Mrach 2015 will be displayed.

In this case Average Headcount = ((Numbe rof Employees present in the organization on 01.2015) + (Number of Employees present in the organization on 03.2015) / 2)

Solution:

To acheive the first scenario, where we have to populate default values in the entry variable, we will write the small piece of ABAP code in CMOD.

First a variable say ZTIME_INTERVAL, should be created on FISCPER info object at query level.

In the first part of the code, we use the below code to populate the default values in the selection screen.

In the code, we take the system date and change it to firstd ay of current month.

We then substract it by one so that we can get the last month.

The lower value of the variable is set as January of current month and higher value as last month.

To acheive the second scenario, we first need to create two variables say ZTIME_INTERVAL1 and ZTIME_INTERVAL2 to get the first and last selection from Input variable used in the query.

The lower value of the input variable is being derived using the below piece of code in ZTIME_INTERVAL1

Here, we check if the input varible has been populated(i_step =2).

The ZTIME_INTERVAL1 variable data is populated from the lower value of the input variable after taking it in a range.

The upper value of the input variable is being derived using the below piece of code in ZTIME_INTERVAL2

Here, we check if the input varible has been populated(i_step =2).

The ZTIME-INTERVAL2 variable data is populated from the upper value of the input variable after taking it in a range.

Additonally, we also have error message populated if the user enters the higher value for input variable for a future month.

This can/cannot be used as per your requirement.

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply