The special MDR subroutine mdr_interval_processing is called once for each interval to be processed. It is passed a data dictionary structure of type /BTR/ST_INTERVAL_VALUES that has a number of fields defined. The most important of these fields is “LOW” and “HIGH”. At the start of the interval processing, you should typecast these two values to your own local variables.
The next step is to retrieve the data you require in your application specific program. However, you need to ensure that your program only retrieves the data relevant for that particular interval. This means your SELECT statements (if appropriate) must use the LOW and the HIGH values in the restriction of data retrieved.
This differs only slightly from a standard ABAP report. Put simply, the selection of the master/transactional data must be extended to include a further WHERE clause.
Once all data in the interval has been retrieved and processed appropriately, you need to save off the results of the processing. This is done using the MDR macro mdr_interval_result_put. It expects two parameters (1) a label identifying the data and (2) the data to be saved. The data to be saved can take any form whether it is a locally declared type or a data type defined in the data dictionary. The data can also be an internal table or even a complex type containing both structures and internal tables.
An example Interval Processing subroutine is shown below:

*----------------------------------------------------------------*
* FORM mdr_interval_processing
*----------------------------------------------------------------*
* This form is called by the MDR architecture to process each    * 
* interval range. Results for each interval should be calculated *  
* within this subroutine and be saved for later collation        * 
*----------------------------------------------------------------*  
FORM mdr_interval_processing 
  USING x_interval TYPE /btr/st_interval_values. 

 DATA: 
  lt_vbak       LIKE vbak OCCURS 0 WITH HEADER LINE,   
  lv_belnr_low  TYPE vbak-belnr,   
  lv_belnr_high TYPE vbak-belnr. 

* Type cast the interval low and high values 
  lv_belnr_low  = x_interval-low.   lv_belnr_high = x_interval-high. 

* Retrieve data 
  SELECT * 
    FROM vbak 
    INTO TABLE lt_vbak 
   WHERE belnr BETWEEN lv_belnr_low AND lv_belnr_high      
     AND bukrs = p_bukrs. 

* Process data 
  PERFORM process_data TABLES lt_vbak. 

* Save results of interval   
  mdr_interval_result_put 'RESULTS' gt_results. 

ENDFORM. 

Once the data has been retrieved, a subroutine is called to process the data. This subroutine uses the Sales Order data and accumulates a global internal table called GT_RESULTS. It is not important what logic this subroutine performs, or the structure of this data, but rather that once this internal table is built, it is then saved using the MDR statement mdr_interval_result_put.
Note that you can save multiple results for a particular interval. For example:

* Save results of interval   
  mdr_interval_result_put 'RESULTS' gt_results. 
  mdr_interval_result_put 'OTHERRESULTS' gt_other_results. 

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment