The intent of this blog post, is to provide a FM to fetch older profile version interval values.
Issue:
Calculation of total consumption for each version is not directly retrievable in SAP.
This total consumption for each version is even though available in transaction EEDM02 when versions are displayed, the same value cannot be retrieved directly from any table.
Only the changed values are stored in tables EPROFVERSHEAD and EPROFVERSVALUE tables.
If there was a new import for some of the intervals of a profile as part of a version then those values will not be stored in these tables.
Hence total consumption retrieval is not straight forward.
Solution:
To get all interval details of a older profile version in a particular period, we will be creating and FM which will take input as Profile Number, Profile version, Start date/time to End date/time along with time-zone and will give us back older profile version intervals values.
Create the FM with following import & export parameters as shown below.
Add the following source code
##NEEDED
DATA: lo_object TYPE REF TO cl_isu_edm_profile,
lv_profile TYPE e_profile,
lv_version TYPE cversno,
lt_prof TYPE teprofvalues_diff,
lv_valid_daterange TYPE eedm_date_time_from_to_utc.
CLEAR: et_prof_values, lo_object, lv_profile, lv_version, lt_prof, lv_valid_daterange.
* Internal conversions
lv_profile = |{ iv_profile ALPHA = IN }|.
lv_version = |{ iv_version ALPHA = IN }|.
CALL METHOD cl_isu_edm_profile=>get_valid_profile_timerange
EXPORTING
profile_number = lv_profile
timezone = iv_timezone
IMPORTING
timeslice = lv_valid_daterange
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
* IF profile is valid create object of class cl_isu_edm_profile
* Create Object
CREATE OBJECT lo_object.
* call open method to read the profile.
lo_object->open(
EXPORTING
profilenr = lv_profile
date_from = iv_date_from
time_from = iv_time_from
date_to = iv_date_to
time_to = iv_time_to
timezone = iv_timezone
read_values = abap_true
read_versions = abap_true
im_dialog = space "background mode
EXCEPTIONS
not_found = 1
OTHERS = 2 ).
IF sy-subrc = 0.
* by default profile is opened in display mode
* call method rebuild revision to get older version intervals.
lo_object->rebuild_version(
EXPORTING
version_number = lv_version
IMPORTING
version_value_tab = lt_prof
EXCEPTIONS
version_not_available = 1
not_allowed = 2
OTHERS = 3 ).
IF sy-subrc = 0.
et_prof_values = lt_prof.
ENDIF.
* close the processing
lo_object->close(
EXCEPTIONS
not_allowed = 1
OTHERS = 2 ).
ENDIF.
ENDIF.
Now Execute, the FM and pass the input values we will get the older version all interval profile values.
we can cross validate the entries from FM with T-Code EEDM02 against the Profile.
Conclusion:
Using the above FM we can fetch older profile version interval values and the calculate total consumption.
Hope you guys liked this blog post.
Feel free to comment, like and share.