import_impex
Import data into SAP Commerce Cloud using ImpEx format to manage products, orders, and system configurations through structured content.
Instructions
Import data using ImpEx format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| impexContent | Yes | ImpEx content to import |
Implementation Reference
- src/hybris-client.ts:498-568 (handler)Core implementation of the importImpex tool. Escapes the provided impexContent, generates and executes a Groovy script that uses Hybris ImportService to perform the import, parses the output to determine success and extract errors.async importImpex(impexContent: string): Promise<ImpexResult> { // Use Groovy script for ImpEx import with ImportService const escapedContent = this.escapeGroovyString(impexContent); const script = ` import de.hybris.platform.servicelayer.impex.ImportService import de.hybris.platform.servicelayer.impex.ImportConfig import de.hybris.platform.servicelayer.impex.impl.StreamBasedImpExResource try { def impexContent = "${escapedContent}" def importService = spring.getBean("importService") def config = new ImportConfig() def resource = new StreamBasedImpExResource( new ByteArrayInputStream(impexContent.getBytes("UTF-8")), "UTF-8" ) config.setScript(resource) config.setEnableCodeExecution(true) def importResult = importService.importData(config) if (importResult.hasUnresolvedLines()) { println "WARNING: Import completed with unresolved lines" importResult.unresolvedLines.allLines.each { line -> println " Unresolved: " + line } } if (importResult.isError()) { println "ERROR: Import failed" if (importResult.unresolvedLines?.allLines) { importResult.unresolvedLines.allLines.each { line -> println " Error: " + line } } return "ERROR" } println "SUCCESS: ImpEx import completed" return "SUCCESS" } catch (Exception e) { println "ERROR: " + e.getMessage() e.printStackTrace() return "ERROR: " + e.getMessage() } `; const result = await this.executeGroovyScript(script, true); // commit=true for imports const output = result.output || ''; const execResult = String(result.result || ''); const success = output.includes('SUCCESS:') || execResult === 'SUCCESS'; const errors: string[] = []; // Extract unresolved lines as errors const unresolvedMatch = output.match(/Unresolved: (.+)/g); if (unresolvedMatch) { errors.push(...unresolvedMatch); } const errorMatch = output.match(/ERROR: (.+)/); if (errorMatch) { errors.push(errorMatch[1]); } return { success, message: output || execResult, errors: errors.length > 0 ? errors : undefined, }; }
- src/index.ts:422-426 (handler)MCP server request handler for 'import_impex' tool call. Validates the input arguments and delegates to the HybrisClient.importImpex method.case 'import_impex': result = await hybrisClient.importImpex( validateString(args, 'impexContent', true) ); break;
- src/index.ts:233-241 (schema)Input schema for the import_impex tool, requiring a single 'impexContent' string parameter.inputSchema: { type: 'object', properties: { impexContent: { type: 'string', description: 'ImpEx content to import', }, }, required: ['impexContent'],
- src/index.ts:230-242 (registration)Registration of the 'import_impex' tool in the MCP tools list, including name, description, and input schema.{ name: 'import_impex', description: 'Import data using ImpEx format', inputSchema: { type: 'object', properties: { impexContent: { type: 'string', description: 'ImpEx content to import', }, }, required: ['impexContent'], },