算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
cpi-iflow-development【设计与创意】SAP CPI iFlow development — integration flow design, Groovy scripting, XSLT/Message mappings, content modifier, router, ZIP packaging, deploy via MCP. Use when creating CPI iFlows, writing Groovy scripts for CPI, packaging iFlows as ZIP, deploying to SAP CPI tenant, or debugging CPI message processing failures.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: cpi-iflow-development description: >- SAP CPI iFlow development — integration flow design, Groovy scripting, XSLT/Message mappings, content modifier, router, ZIP packaging, deploy via MCP. Use when creating CPI iFlows, writing Groovy scripts for CPI, packaging iFlows as ZIP, deploying to SAP CPI tenant, or debugging CPI message processing failures. trigger:
Full development lifecycle for SAP Cloud Integration (CPI) iFlows — from source code to deployed integration.
CPI_BASE_URL, CPI_OAUTH_TOKEN_URL, CPI_OAUTH_CLIENT_ID, CPI_OAUTH_CLIENT_SECRETRoute CPI API operations to the reviewed local sap-cpi-mcp first. Use
integration-suite-ui-mcp only when API/background access is blocked and a logged-in
browser session is available. Never route to disabled community candidates.
Read CPI MCP tool contracts before invoking tenant or local tooling operations. Consult CPI tooling catalog when selecting an optional external adapter.
my-iflow.zip/
├── META-INF/MANIFEST.MF
└── src/main/resources/
├── flow.xml ← Main integration flow definition
├── script/*.groovy ← Groovy scripts
├── mapping/*.xslt ← XSLT transformations
├── mapping/*.mmap ← Message mappings
├── resources/*.xsd ← EDI/XML schemas
└── parameters.prop ← Externalized parameters
Create the project directory and core files:
mkdir -p iflows/my-integration-flow/{src/main/resources/script,src/main/resources/mapping}
Write the MANIFEST.MF:
Manifest-Version: 1.0
Bundle-SymbolicName: my_integration_flow
Bundle-Version: 1.0.0
Bundle-Name: My Integration Flow
Define sender channel, integration process steps, and receiver channel:
<IntegrationFlow id="my_integration_flow" version="1.0">
<Sender id="sender_1" type="HTTPS" direction="Inbound">
<Address>/process/order</Address>
<Authentication>Basic</Authentication>
</Sender>
<IntegrationProcess id="process_1" name="Process Order">
<ContentModifier id="cm_1" name="Set Headers">
<Property name="OrderId" source="body" sourceField="orderId"/>
</ContentModifier>
<GroovyScript id="script_1" name="Transform Payload"
scriptPath="script/process-data.groovy"/>
<RequestReply id="rr_1" name="Call S/4HANA">
<Receiver ref="receiver_1"/>
<Timeout>60000</Timeout>
</RequestReply>
<Router id="router_1" name="Route by Status">
<Condition expression="${property.Status} = 'OK'" targetStep="end_ok"/>
<Condition expression="${property.Status} = 'ERROR'" targetStep="end_error"/>
</Router>
</IntegrationProcess>
<Receiver id="receiver_1" type="ODataV2" direction="Outbound">
<Address>${destination.S4HANA}/sap/opu/odata/sap/Z_ORDER_SRV</Address>
</Receiver>
</IntegrationFlow>
XML-to-JSON transform with error handling:
import com.sap.gateway.ip.core.customdev.util.Message
import com.sap.it.api.ITApiFactory
import com.sap.it.api.msglog.MessageLog
def Message processData(Message message) {
def log = message.getMessageLog()
try {
def body = message.getBody(java.lang.String)
if (!body?.trim()) throw new IllegalArgumentException("Empty body")
def xml = new XmlSlurper().parseText(body)
message.setBody("""{"orderId":"${xml.orderId.text()}","customer":"${xml.customer.text()}"}""")
message.setHeader("Content-Type", "application/json")
log.setStringProperty("Status", "COMPLETED")
} catch (Exception e) {
log.setStringProperty("Status", "FAILED")
log.addAttachmentAsString("error.txt", e.getMessage(), "text/plain")
throw e
}
return message
}
Value mapping lookup: ITApiFactory.getApi(ValueMappingApi).getMappedValue('COUNTRY_CODES', 'SAP_Internal', 'ISO', countryCode)
python scripts/cpi_iflow_packager.py create \
--name my-integration-flow \
--flow iflows/my-integration-flow/src/main/resources/flow.xml \
--scripts iflows/my-integration-flow/src/main/resources/script/process-data.groovy \
--output iflows/my-iflow.zip
Validate the ZIP structure:
python scripts/cpi_iflow_packager.py validate --input iflows/my-iflow.zip
Validate the packaged iFlow ZIP (structure, MANIFEST.MF, required files):
npm run cpi:validate -- --input <iflow>.zip
Run the canonical read-only quality workflow:
python scripts/cpi_client.py quality --input <iflow>.zip --engine auto
# MCP equivalent: cpi_quality_check
The built-in structural validator always runs. cpilint runs only when
CPILINT_CMD resolves to an installed executable; no download is attempted.
Also review Groovy against these rules:
new File() in Groovy → errorprintln() → info (use MessageLog instead)Use canonical MCP tools:
cpi_packages -> cpi_artifacts -> cpi_runtime_artifacts
cpi_logs -> cpi_message_details
cpi_deploy_plan -> independent human approval -> cpi_deploy_commit
Treat cpi_deploy_plan as read-only planning. Execute cpi_deploy_commit only with
the approved action_id, plan_hash, argument_hash, and precondition_hash.
Apply the same sequence to undeploy, iFlow generation, plotting, and Git sync.
groovy.xml.XmlSlurper; see
SAP's runtime compatibility guidelines.${in.body} not ${message.body}; use ${property.X} for properties.message.getBody(java.lang.String).Content-Type header AFTER calling message.setBody().cpi_quality_check; structural validation passes and configured cpilint reports no errorsvalidate command exits 0cpi_deploy_plan, obtain independent approval, then call cpi_deploy_commit; cpi_runtime_artifacts shows "Started"