Hi Emiliyan,
Yes, WHEN/ENDWHEN has to keep all resulting data in memory in case records from separate batches produce record with same key - then it adds them up. Therefore *XDIM_MEMBRSET is useful when you have a big source set and a small resulting set of records.
You can also try *XDIM_PACKAGEBY. Similarly to RUNLOGIC it writes back each batch of data independently.
Regards,
Gersh