cancel
Showing results for 
Search instead for 
Did you mean: 

How can we write Remove impex with data to remove is from flexible search query?

bibinkuriyan
Explorer
0 Kudos
815

% impex.enableCodeExecution(true);

remove SystemSetupAudit;PK[unique = true] * PK to remove is from a flexibleserach query.

can anyone help on this ???

Accepted Solutions (1)

Accepted Solutions (1)

former_member620692
Active Contributor
0 Kudos

By importing the following ImpEx script, I was able to remove the product with code, 12345 :

 $dburl=jdbc:mysql://localhost/hybris67
 $dbusername=hybris67
 $dbpassword=hybris67
 $dbdriver=com.mysql.jdbc.Driver
 
 REMOVE Product[batchmode=true];pk[unique=true];
 #% impex.initDatabase("$dburl", "$dbusername","$dbpassword","$dbdriver");
  "#%
  impex.includeSQLData( 
      ""SELECT PK FROM products WHERE p_code ='12345'""
  );
 "

Please note that I have used an SQL Query instead of an FS Query.

bibinkuriyan
Explorer
0 Kudos

Can we use Flexible search query, instead of SQL..... ?

former_member620692
Active Contributor
0 Kudos

I will check that and get back to you. However, for now, you can proceed with your work with the SQL. As you already know, under the hood, the FS Query gets converted to SQL and it is the SQL which is executed by the database. Of course, FS Query abstracts the complexities of SQL and we should always strive to use FS Query instead of SQL; not just for simplicity but also for restrictions, caching etc.

bibinkuriyan
Explorer
0 Kudos

Thank you so much.If we can do by FS query we can avoid the inputs like DB details .If you can share me if you are able be do with FS query. The query below query but i am getting a warke below Script: #% impex.enableCodeExecution(true); remove SystemSetupAudit[impex.legacy.scripting = false];PK[unique = true] "#%impex.exportItemsFlexibleSearch(""SELECT {pk} FROM {SystemSetupAudit} where {className}= 'class1"");" # PK

Logger (000001WY) [ImpExImportJob] Starting ImpEx cronjob "ImpEx-Import" (000001WY) [ImpExReader] line 1 at main script: skipped code line line 1 at main script:impex.enableCodeExecution(true) since bean shell is not enabled (000001WY) [ImpExReader] line 3 at main script: skipped code line line 3 at main script:impex.exportItemsFlexibleSearch("SELECT {pk} FROM {SystemSetupAudit} where {className}= 'class1'"); since bean shell is not enabled (000001WY) [Importer] Finished 1 pass in 0d 00h:00m:00s:001ms - processed: 0, no lines dumped (last pass 0)

former_member620692
Active Contributor
0 Kudos

I will try my best to find a way to execute the FS Query in it. It's just a matter of getting time as I am quite busy for a couple of days 🙂

Please remove impex.enableCodeExecution(true) and import the ImpEx in hAC with Enable code execution checked. Let me find out if it can work without Enable code execution checked in hAC.

former_member620692
Active Contributor
0 Kudos

So far I haven't been able to find a way to import my ImpEx without Enable code execution checked. I doubt if it will work without it. While trying to find a way, I also came across https://answers.sap.com/questions/12750761/view.html where a member has mentioned the problem of enabling bean shell.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Bibin,

You cannot remove items directly using the impex import, as the impex importer does not support code execution, the solution I have found is to run the impex remove query as an impex export from HAC. Download the generated zip file, goto your backoffice or HMC and create a new impex import cronjob. Upload the zip file generated earlier as the impex import media, in Backoffice I believe it comes under the Admin tab of the cronjob and in HMC it will be present in the first tab of the cronjob. Run the cronjob after this and you should see the items getting deleted.

Former Member
0 Kudos

Please do note that the generated zip file should not be extracted and should be uploaded as is.