Let me clarify the complete approach covering all three critical aspects.
For CDS view extension, your current approach is partially correct but incomplete. I_ProjectWBSElement is a consumption view. You need to extend at the interface level (C_ProjectWBSElementTP) and the root level (I_ProjectWBSElementTP). Create a second extension:
extend view I_ProjectWBSElementTP with Z_ProjectTP_Ext {
@EndUserText.label: 'External Ref 1'
WBSElement.zz_ext_ref1
}
For OData metadata refresh, this is crucial but often missed. After extending CDS views and behavior definitions, the OData service metadata is cached. You must clear the cache and regenerate. In transaction /IWFND/MAINT_SERVICE, find your project service, click ‘SAP Gateway Client’, and execute an $metadata request. Then go to transaction /IWFND/GW_CLIENT and clear the model cache. Finally, in your Fiori launchpad designer, republish the app catalog. Without this sequence, the OData layer won’t recognize write capabilities even if backend is configured correctly.
For Fiori app republish, after metadata refresh, you need to update the app descriptor. Open your Fiori project in Web IDE or Business Application Studio. In manifest.json, verify that the model configuration includes the extended fields in the entity type definition. Then increment the app version and redeploy. Clear browser cache on client side - this is often forgotten and causes stale metadata issues.
Now for the write-back implementation: extend the behavior definition C_ProjectWBSElementTP:
extend behavior definition C_ProjectWBSElementTP {
field ( readonly:update ) zz_ext_ref1;
field ( readonly:update ) zz_ext_ref2;
}
Create behavior implementation class ZCL_BP_PROJECTWBS_EXT implementing interface IF_ABAP_BEHAVIOR_HANDLER. Implement method MODIFY to handle the custom field updates. Inside modify method, read the changed fields from the modify structure and update the database table using UPDATE statement or through standard BAPI BAPI_BUS2054_CHANGE_MULTI.
Alternatively, if your S/4HANA version supports it, use the embedded extensibility approach: transaction AET_EXT_UI to define the fields at business context level. This auto-generates all required CDS extensions, behavior modifications, and OData bindings. Much cleaner than manual coding.
After implementation, test the complete flow: update a field in Fiori app, check browser network tab to verify the PATCH request includes your fields, then query the database table directly to confirm persistence. If PATCH request doesn’t include the fields, the issue is in Fiori app binding. If PATCH succeeds but data doesn’t persist, the issue is in behavior implementation.