Ripping out your ECC monolith in one epic weekend is the fastest path to CFO heartburn. A safer route is progressive carve-out: lift one business capability at a time into a Cloud Application Programming (CAP) microservice running on SAP BTP, connect it back to ECC with Event Mesh, and retire legacy code sprint by sprint. We share the exact playbook our Micro-GCC squad used to extract “Sales Pricing” from 300 000 lines of Z-code—with zero plant downtime and a 43 % latency improvement. All CDS, mta.yaml, and Terraform snippets included.
Typical big-bang plan: clone ECC database, refactor Z-code in S/4 sandbox, schedule 48-hour outage.
Reality: transports collide, IDoc queues pile up, month-end close panics.
Key blockers:
Progressive carve-out solves this by:
sql
CopyEdit
ECC (Blue) Event Mesh BTP (Green)
+—————-+ +—————+ +——————+
| SD Z_PRICING |–>| SD.PRICING.* |–>| CAP Service v1 |
| (ABAP Module) | +—————+ | /pricing/* OData|
+—————-+ +——————+
↑ | ↑
| | SAP SLT (real-time) |
| +————————————-+
|
Legacy UI5 App New UI5/Fiori
Step-switch: gateway route toggles /pricing/* to CAP when E2E tests green.
Rule of thumb: choose a business capability with ≤ 3 BAPIs and ≤ 5 tables.
For Sales Pricing we touched VBAK, VBAP, KONV and three custom Z-tables.
db/schema.cds
cds
CopyEdit
namespace sd.pricing;
entity SalesOrder {
key SalesOrderID : String(10);
NetValue : Decimal(15,2);
Currency : String(5);
}
entity PricingCondition {
key CondID : Integer;
SalesOrderID : Association to SalesOrder;
Amount : Decimal(15,2);
CondType : String(4);
}
Run:
bash
CopyEdit
cds deploy –to hana
srv/pricing-service.js
js
CopyEdit
module.exports = srv => {
const { SalesOrder, PricingCondition } = srv.entities
srv.before(‘CREATE’, PricingCondition, validateAmounts)
srv.on(‘reprice’, async req => {
const so = await SELECT.one.from(SalesOrder).where({ SalesOrderID: req.data.id })
// call external pricing engine, update NetValue …
return so
})
}
mta.yaml adds requires: [ hana, eventmesh ].
event-mesh.json
json
CopyEdit
{
“source”: “ECC”,
“events”: [
{ “name”: “SD.PRICING.UPDATED”, “namespace”: “sap.s4”, “version”: “v1” }
]
}
CAP srv/pricing-sub.js
js
CopyEdit
module.exports = srv => {
const { PricingCondition } = srv.entities
srv.on(‘sap.s4/SD.PRICING.UPDATED’, async msg => {
await UPDATE(PricingCondition).where({CondID: msg.data.id}).set(msg.data)
})
}
Latency ECC → CAP cache: ≤ 300 ms (tested 95th percentile).
jenkinsfile
groovy
CopyEdit
stage(‘Build’) { sh ‘mbt build’ }
stage(‘Deploy’) {
withCredentials([file(credentialsId: ‘btp.json’, variable: ‘BTPCRED’)]) {
sh ‘cf deploy mta_archives/pricing_1.0.0.mtar –json’
}
}
stage(‘Smoke’) { sh ‘npm run smoke’ }
Smoke tests hit /pricing/$metadata plus /reprice.
In SAP APIM:
yaml
CopyEdit
routes:
– match: /pricing/**
target: cap-green
weight: 20
– match: /pricing/**
target: ecc-blue
weight: 80
After 24 h of green logs, flip weights to 100/0. Rollback = YAML revert.
| Metric | ECC Z-RFC | CAP Microservice |
| p95 Read Latency | 520 ms | 297 ms |
| p95 Write Latency | 640 ms | 335 ms |
| Monthly Infra € | N/A (on-prem) | €420 (BTP, 2 GB HANA Cloud) |
Savings: dev hours (fewer OSS notes), faster user response, and clear path to mobile APIs.
Industrial OEM needed real-time price quotes in a dealer portal.
Z-code reduction: 48 000 lines deleted; ATC critical findings –100 %.
| Pitfall | Fix |
| CDS enum mismatch | Use @cds.odata.valuelist for domain values; sync with DDIC check table. |
| Event duplicates | De-duplicate by message ID; CAP persists last processed offset. |
| HANA Cloud memory spike | Partition KONV by fiscal year; purge archive years. |
| Fiori app calls old RFC | Use UI5 cache buster; adjust destination to CAP SACF. |
| Devs fear CAP learning curve | Scaffold service with yeoman-generator-cap-project—5 min ramp. |
| Sprint | Milestone |
| 1 | Enable abapGit, export domain package |
| 2 | Define CDS & deploy to HANA Cloud |
| 3 | Build CAP service & Event Mesh subscription |
| 4 | 20 % canary traffic via APIM |
| 5 | Full cut-over; retire old Z-code package |
Repeat domain by domain until ECC monolith collapses into modular CAP landscape.