Friday, December 31, 2010

BW 7.x: How to design start/end/expert routine within transformations?

There are several points that you need to recon while coding start, end or expert routines. 

Basically you need to be aware which data are you processing either it is source_package in case of start routine; result_package in case of end routine or even both tables in case of expert routine. Basically you do LOOP ABAP statement over one of those internal tables and you modify it or add new rows. There are available corresponding work areas (source_field, result_field) and field symbols (, ) that make you looping easier. 

Another point to be considered is creating new records within routines in one of its data_package internal tables. Here’s field called RECORD which needs special treatments. In case of end routine you need to populate value of this field by calling standard method new_record__end_routine.

In case of error handling you can populate called MONITOR. By this you can send messages to the Data Transfer Process (DTP) monitor. This makes maintenance of BW application easier. BW administrator sees error in monitor and can recognize its root cause directly by analyzing message instead of digging in coding or in ABAP dumps. Coding can be maintained like following:

IF sy-subrc <> 0.
  monitor_rec-msgty = 'msgty'. "e.g. W
  monitor_rec-msgid = 'msgcls'. "e.g. RS
  monitor_rec-msgno = '100'.
  monitor_rec-msgv1 = lv_par1. "Parameter 1
  monitor_rec-msgv1 = lv_par2. "Parameter 2
  monitor_rec-msgv1 = lv_par3. "Parameter 3
  monitor_rec-msgv1 = lv_par4. "Parameter 4
  APPEND monitor_rec TO MONITOR.
  RAISE EXCEPTION TYPE CX_RSROUT_ABORT. "aborts whole processing
*  RAISE EXCEPTION TYPE CX_RSROUT_SKIP_RECORD. "skips this particular record

For  further reference see following SAP Notes:
1227667 - Guidelines for expert routine: Design rules
1223532 - Design rules: Adding records to end routine
1258089 - Design rule: Adding records to the start routine

- update 21.01.2011 - 
In case of expert routine, breaking processing of load via raising of exception doesn't work (CX_RSROUT_ABORT). You have to use method send_message of class cl_rstran_expert_rout_srv.

- update 19.05.2011 - 
Some more SAP Notes on this topic:
1349820 - Expert routine: Technical enhancements

No comments: