Customer Relationship Management Blogs by SAP
Stay up-to-date on the latest developments and product news about intelligent customer experience and CRM technologies through blog posts from SAP experts.
Showing results for 
Search instead for 
Did you mean: 
0 Kudos


When doing the data extraction with datasource 0CRM_OPPT_H, I find that the value of field "duration" is different if we do the extraction on different time. Then I assume that the value of this field is calculated by the current date minus starting date. And then, with my assumption, I debugged the extraction process and find out how the value of Duration is calculated.

For opportunities with status "won" or "lost", the value of Duration is the difference between "Closing date" and "stage since". ("Duration" = "Closing date" - "stage since") Thus for this kind of opportunities, the value of Duration won't be changed no matter when you do the extraction.

But for opportunities with status "open", the value of Duration is the difference between "current system time" and "stage since". ("Duration" = "current time" - "stage since"). Thus for this kind of opportunities, the value of Duration is the difference between "changed at" and "stage since" when we do a delta load. And when we do the full load, the value of Duration is the difference between "current system time" and "stage since". That is also the reason why the extraction result of delta load and full load is consistent.

The coding used to calculate the value of duration is the following

(function module CRM_BW_OPPT_H_MAP)

249  PERFORM duration_determine







form duration_determine

IF status_ip = gc_status-won OR status_ip = gc_status-lost.                << for the opportunity with status won or lost, the duration won't be changed no                                                                                                                      matter when you do the extraction

    duration_op = exp_end_ip - phase_since_ip.


     duration_op = sy-datum - phase_since_ip.                                              <<  for the opportunity with status "in process", the duration is calculated                                                                                                                                by current time minus "stage since".


Where the value of "phase_since_ip" comes from ??

(function module CRM_BW_OPPT_H_MAP)

162   IF sy-subrc EQ 0.

       extract_data-startdate = ls_opport_h-startdate.

       extract_data-expect_end = ls_opport_h-expect_end.

       extract_data-curr_phase = ls_opport_h-curr_phase.

       extract_data-phase_since = ls_opport_h-phase_since.    <<   extract_data - phase_since is filled by ls_opport_h - phase_since

       extract_data-importance =  ls_opport_h-importance.

       extract_data-salescycle = ls_opport_h-salescycle.

       extract_data-type = ls_opport_h-type.

       extract_data-exp_revenue =  ls_opport_h-exp_revenue.

       extract_data-budget_bp = ls_opport_h-budget_bp.

       extract_data-probability = ls_opport_h-probability.

       extract_data-sys_probability = ls_opport_h-sys_probability.

       extract_data-status_since = ls_opport_h-status_since.

       extract_data-number_of_h = 1.

       extract_data-source = ls_opport_h-source.

       extract_data-forecast_rel = ls_opport_h-forecast_rel.

       extract_data-description_opp = ls_opport_h-description_opp.


Also, when do the calculation, just the working days are taken into account.

For example, the "stage since" time of a document is 2016.5.19, and the document is still open, then the duration should be 6.

This is the logic of extracting field "duration".