Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
neilaspin
Explorer
381

1 – Setting the Scene

I spun up a new CAP project in SAP Business Application Studio and thought:
“How hard can it be to show a list of incidents from a SQLite database?”

IncidentManagementCAP/
├─ db/schema.cds
├─ srv/incidentsrv.cds
└─ package.json

schema.cds defined the usual suspects — Incidents, Customers, Status, Urgency.
incidentsrv.cds exposed them through an IncidentService.
SQLite was configured as persistence.

2 – CAP’s Circle of Errors

Act 1:

[ERROR] Mismatched ‹Identifier›, expecting ‹String›

BAS had “helpfully” converted my straight quotes into curly ones. Replacing them with normal ASCII quotes fixed it.

Act 2:

no such table: IncidentService_Incidents

I’d only deployed the db model, not the srv one, so the projection view didn’t exist. Adding this to package.json fixed it:

{
  "cds": {
    "requires": {
      "db": {
        "kind": "sqlite",
        "credentials": { "database": "db.sqlite" },
        "model": [ "db", "srv" ]
      }
    }
  }
}
cds deploy --to sqlite

Act 3: BAS uses an in-memory SQLite DB by default, so every restart wiped my tables. Pointing to a real file finally made data persist.

3 – Success (Sort of)

/> successfully deployed to db.sqlite

and:

IncidentService_Incidents
sap_capire_incidents_Incidents

Progress! I opened the preview app expecting rows of data … and got a pristine white screen reading:

Add columns to see the content

Nothing wrong with my code; Fiori Elements was just hiding every field until I manually selected them.

4 – The Real Fix

  1. In the Data Preview, click the ⚙️ gear icon.
  2. Choose Table Settings → Columns.
  3. Tick ID, title, status_code, urgency_code.
  4. Click Apply.

Suddenly the data appeared — the record I’d seeded in sap.capire.incidents-Incidents.csv.
After days of chasing ghosts, it all came down to a UI checkbox.

5 – Lessons Learned

  • Curly quotes and BOMs: BAS sneaks them in; CAP chokes on them. Type the using ... from "../db/schema"; line manually.
  • Deploy both models (db, srv), not just the schema.
  • Use a real SQLite file in package.json; in-memory DBs reset on each run.
  • That “Add Columns” message isn’t an error. It’s Fiori Elements politely saying “I’m empty until you tell me what to show.”

6 – Takeaway

Sometimes CAP isn’t broken — it’s just very literal. Between invisible characters, hidden tables, and silent checkboxes, getting to that first visible row can feel absurd. But once you’ve fought through it, you understand how the layers fit together:

Layer Purpose

db/Entities and persistence
srv/OData service / projections
app/Fiori Elements UI
package.jsonThe glue holding it together

So when someone in the forums says “My CAP service returns nothing,” you’ll smile knowingly and reply: “Check your quotes. Then click Add Columns.”