AIF

Hi guys!!
I need to replicate a record using AIF
I have an XML coming with receipt id. I want ot replicate an existing record filtering by this receipt id on the table RetailSalesTrans
i Have added select statement in the prepareForSaveExtended() and in the select block i have replicated the filtered record. But it is not working out. Any idea how to perform this or any idea how to debug Document Class in AIF
thanks!