Hi Frederic,
QUERY = ON helps to populate the CT_DATA table so that the logic can be executed on the records populated as per the scope file.
Source link -
Kindly go through the below link may be helpful ...
ABAP Code (BPC 10 NW) to read an application's transaction data within the BAdI
when QUERY = OFF ct_data structure is different and getting run time error when posting data
Shrikant