‎2025 Mar 15 11:33 AM - edited ‎2025 Mar 16 11:52 AM
We have a CAP application in which we are trying to connect to a Delta table using Virtual Table (via HANA SoF). Following is our setup:
We have defined a virtual table "OpenGoodsReceipts.hdbvirtualtable" under package "db/src".
VIRTUAL TABLE "SAP_IC_PRP_OPENGOODSRECEIPTS" ( product NVARCHAR(128), documents_documentId NVARCHAR(100), documents_documentUuid NVARCHAR(128), documents_openQty DOUBLE, documents_qtyUomUuid NVARCHAR(128), documents_qtyUom NVARCHAR(10), documents_plannedDeliveryDatetime SECONDDATE, replenishmentRunId NVARCHAR(50), location NVARCHAR(128), segmentId NVARCHAR(128) ) AT SOF_REMOTE."<NULL>"."<NULL>"."/prp-op-traceability-results/out/crp-order-quantity-kpi-service/ogr" AS DELTA;
On top of this we have created a Facade CDS "OpenGoodsReceipts.cds" under package "db/di".
namespace sap.ic.prp;
@cds.persistence.exists
entity OpenGoodsReceipts {
product : String(128);
documents_documentId : String(100);
documents_documentUuid : String(128);
documents_openQty : Double;
documents_qtyUomUuid : String(128);
documents_qtyUom : String(10);
documents_plannedDeliveryDatetime : DateTime;
replenishmentRunId : String(50) @filterable;
location : String(128) @filterable;
segmentId : String(128);
}We are then consuming the above Facade CDS in our Service CDS to expose an OData endpoint for the same, under the package "srv".
using sap.ic.prp.OpenGoodsReceipts as ogr from '../db/di/OpenGoodsReceipts';
service PrpOpTraceabilityService {
@readonly
entity OpenGoodsReceipts as
projection on ogr {
key documents_documentId as orderId,
documents_plannedDeliveryDatetime as deliveryDatetime,
documents_openQty as openQuantity,
documents_qtyUom as openQuantityUom,
replenishmentRunId,
product,
location
};
}Now when we build the application, we get the corresponding .hdbview generated (under package "db/src/gen" for the above Service CDS entity - "PrpOpTraceabilityService.OpenGoodsReceipts.hdbview"
VIEW PrpOpTraceabilityService_OpenGoodsReceipts AS SELECT ogr_0.documents_documentId AS orderId, ogr_0.documents_plannedDeliveryDatetime AS deliveryDatetime, ogr_0.documents_openQty AS openQuantity, ogr_0.documents_qtyUom AS openQuantityUom, ogr_0.replenishmentRunId, ogr_0."PRODUCT", ogr_0.location FROM sap_ic_prp_OpenGoodsReceipts AS ogr_0
Here if you look closely, only the column product has been converted into a quoted column name "PRODUCT". I find this happening consistently in other views as well in my application, only and only if the column name is exactly 'product'. If we now change the column name to say productId it will work generate correctly without any quotes.
Can anyone help to understand why such a behavior is being observed?
Complete application code - https://github.tools.sap/crp/prp-data-browser
Request clarification before answering.
Found the answer in the StackOverflow thread - https://sap.stackenterprise.co/questions/69328/69329#69329
The CDS compiler and CAP runtimes provide automatic quotation for reserved words so that they can still be used in most situations. Automatic quotation is available for SQLite, SAP HANA, postgres and H2.
product is in the list of reserved words (you can find it in the HANA grammar) and hence is quoted by the cds-compiler.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.