Monday 2 April 2012

Expert Routine - why not?

Is it worth to use Expert Routines? 

In help.sap.com you can find information: "You can use the expert routine if there are not sufficient functions to perform a transformation. 

The expert routine should be used as an interim solution until the necessary functions are available in the standard routine.

You can use this to program the transformation yourself without using the available rule types" When I read it for the first time I was scared of using it. 

Now I am using it every time when the transformation is complex or I need to improve loading performance.

Below you can find some examples when I'm considering using expert routine:
    • When in current data model there is complex ABAP in start/end routines and loading performance is not so good 
       
    • When in transformation rules there are complex ABAPs for 10 or more characteristics and the loading performance is not so good
Every time when I am changing existing data model, firstly I am building a prototype, next to existing flow, to be able to compare transformation result and throughput time. 

It costs me much more time but at the end I am sure that I am delivering the proper solution.

Besides that every time when I am changing standard routine into expert routine I am trying to improve the performance by adjusting a little bit existing logic. 

There are commonly known "mistakes" which slow down speed and increase memory consumption during data loading, for example:

1. Data declaration and "select *"

When you are reading data from other DSO during data load and you need just a few fields from there do not use "select " but select particular fields only.</p><p>Instead of:</p><pre>DATA: internal_table TYPE STANDARD TABLE OF  /BIC/ADSO00100.<br />SELECT INTO CORRESPONDING FIELDS OF TABLE internal_table<----- do something there -


      ENDLOOP.
      ELSE.
        CLEAR: lv_orderi_idx.
      ENDIF.

 Turning to the Expert routines, there are some disadvantages of using it as you cannot have initial values for some characteristics and you cannot do other aggregation than overwrite. To solve this issue I am using Infosource in between, For example:

Initial value for characteristics:


If you would like to replace transformation between Source DSO1 and Target DSO with Expert routine, then "Status field" would be always overwritten with "Empty" value, what means that the proper value from Source DSO2 will disappear. To avoid situation like that, we can simply put infosource in between:

Now between DSO1 and Infosource we can create our expert routine and then by using standard transformation create mapping between infosource and Target DSO.

Aggreagated values for Key Figures:</p><p> Similar solution like for initial value. By putting an infosource in between we can use aggregation features given by standard transformations</p><p>!CLICK HERE!</p><p>One more thing, which can be very useful when you decide using Expert routines in your flow, is displaying messages in case of errors or issues in loading monitor. 

To do that you can use simple code:

</p><pre>          DATA:<br />          MONITOR TYPE rspc_t_msg,
<br />                 monitor_rec TYPE rspc_s_msg.<br />
<br /> CLEAR monitor_rec.<br /> monitor_rec-msgno = '000'.
<br  />          monitor_rec-msgid = 'BW01'.
<br />          monitor_rec-msgty = 'I'.
<br />          monitor_rec-msgv1 = 'Missing Item category group ERLA: '.
<br />          monitor_rec-msgv2 = <result_fields>-material.
<br />          monitor_rec-msgv3 = <result_fields>-salesorg.
<br />          monitor_rec-msgv4 = <result_fields>-distr_chan.
<br />          APPEND monitor_rec TO MONITOR.
<br />          CALL METHOD log->add_t_msg
<br />            EXPORTING<br />          i_t_msg = MONITOR.
<br />          FREE MONITOR.</pre><p>!CLICK HERE!</body>

No comments:

Post a Comment