Importing the query-
REMOVE ProductReference;pk[unique=true]
"#% impex.exportItemsFlexibleSearch(""select {pk} from {ProductReference as pr} where {pr.referenceType}=( {{select {pk} from {ProductReferenceTypeEnum as prte} where {prte.code} = 'CROSSELLING'}})"");"
is not working because you have not selected the Enable code execution checkbox.
Also, as suggested by @B.M replacing the script with impex.includeSQLData()
and #% impex.initDatabase()
would not have any effect if the checkbox is not selected.
However, selecting the checkbox and running the above script will give error, because there is no method by the name, exportItemsFlexibleSearch
in the class MyImpExImportReader
(which is called on running import).
The method exportItemsFlexibleSearch
is available in DeprecatedExporter
(which is called on running export not import).
Now, running this impex script in export will execute successfully without any error, but it won't remove anything. Instead, it will create a zip file with an impex and a script file. This script file will have the impex header for removing the items returned by the query. Using this zip file we can delete the items, conditionally.
Go to HMC -> Cronjobs -> Create a new cronjob of type Impex import job
-> Upload the zip file in media attribute -> Create -> Run the impex.
This would delete the items returned by the query.
There is another way of deleting the items selected by the query.