on 07-19-2007 8:26 PM
In the ODS there is a date which is a user entry on my report. I need to write a customer exit which goes to previous date.
In other words let's say user entered 07/07/07 at the user entry, and there is no activity for the entered date. The previous activity date in ODS data is 07/05/07. The report should run based on the previous date. ( Date is the key by the way )
I will appreciate any help with points,
Regards,
Mike
I just wrote this quickly and I limited to 10 loops because something is wrong if it is further back than that and I think another solution should be done. This is also assuming the volume of data is not too large. If so you may want to take the year off the date and add that to the select statement.
Can the previous date be any date? So lets say the user entered 07/07/07 and the last activity was 01/01/07? Is date the only key?
If so you can do something like this.
date_ 1 like <date_ field in ODS>
date_ 2 like <date_ field in ODS>
counter(2) type n
DATA: BEGIN OF data_all OCCURS 0,
Date_ 3 like date_ 1
END OF data_all
date_ 1 = user enter
counter = 10
Select <date_ field> from <ods backend table> into data_all
Sort ascending
While counter > 0
Read data all where data_all-date_3 = date_1
If sy-subrc <> 0
Date_ 1 = date_ 1 1
Counter = counter - 1
Continue.
Else
date_2 = date_1
Exit.
Endif
End loop
Return date_2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi MG,
There are two keys. One is the date the other one is the user ID. Thanks for the code but the problem is I need to use I_T_VAR_RANGE table which contains the current values of the variables when you run the report. And also note that there is no calendar date available in the ODS, there is only activity date. That is why the current report brings nothing if there is no activity on the entered date.
Thanks
Let us say, you read the user entered date in a local field w_date.
select max(act_date) into w_actdate from <ODS_ACTIVE_TABLE_> where act_date le w_date.
This should get you the max date less or equal to user specified date. You can then use it to populate the selection.
If you want it to be user based as well, you can add user-id as additional selection in the WHERE clause.
For generic user-exit code, search the forum.
How many records exist? Also is the report using user ID at all? Last, to use the I_T_VAR_RANGE I'm pretty sure you will just use the -low value in this table. SO where i put I_T_Var_range-low and for the return you will set it equal <export table>-low = date_2. You will also add a case statement based on variable technical name
Just my opinion, but I would not use a customer exit. There is no way to do it with user IDs dependant. IF you create a giant structure with all the user IDs in it and restrict each of those on the date then I would do it.
Here is what I would do. Assuming your daily volume is under 30,000. I would create an ODS with the user iD as the key. SO that is overwrites. On a daily basis I would do a full load into a cube setting a new date field = system date. This way it will update all the old fields with today's date. I would then have my users input the value for that date field. This way you are keeping the "running balance" of each user. That is just my opinion.
Also here is a link to a previous thread that may help you to write it. The code I wrote will work, but you have to add the "When <variable name> and I_step =...
I have actually done this in the past. The exit variable was complex, and if you try to do it using ABAP the load will become too large and fail. This was the solution we applied. It had the least easier to maintain. We were going to the do the structure, but it became complex due to the volume and structures are limited to 999.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.