Wednesday, July 5, 2017

Handling KF behavior in Expert Routine in case of DSO as target

I came across following issue while dealing with expert routine. There was a DSO object as target of TRFN.  Key figures within the TRFN were updated but they weren’t aggregated. Basically values of KFs from last row that was processed were updated into the DSO but not values form previously processed records. So at the end the KFs were not summed up – no aggregation took place and what was going on was that there was just a move operation executed.

After checking with SAP documentation I realized that that this behavior is as designed:
“If the target of the transformation is a DataStore object, key figures are updated by default with the aggregation behavior Overwrite (MOVE).”

If one wouldn’t need this behavior then it must be overcome in custom coding within the expert routine. Data in result package must be collected instead just appended. Below is example of how to do it.

TYPE: t_ty_t_TG_1 TYPE SORTED TABLE OF _ty_s_TG_1 WITH NON-UNIQUE DEFAULT KEY.

DATA: ls_record_no TYPE rsarecord VALUE 0,
lt_result_pack TYPE t_ty_t_TG_1,
ls_result_str TYPE _ty_s_TG_1.
.
.
.

COLLECT ls_result_str INTO lt_result_pack.

No comments: