How to resolve ASSERTION_FAILED error when you register the odata service expose
Description
When you try to register an Odata service exposed by a CDS view in tcode /IWFND/MAINT_SERVICE, you meet with runtime error ASSERTION_FAILED as displayed in picture below.
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-5VKQEIZA-1628157766961)(https://user-images.githubusercontent.com/5669954/57507475-8399d780-7331-11e9-86e6-2a8396b4eb0e.png)]
Keywords
ASSERTION_FAILED, @OData.publish
Root cause
If you debug in the backend, you can find the exception is raised in line 9.
The field causing this exception, “STAT”, does not come from the consumption view itself but from the foreign view zorder_sys_status.
When we comment out line 22~24, the service registration could successfully be done.
Solution
在當前view上重新創建一個新的consumption view.
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-pwUve00I-1628157766963)(https://user-images.githubusercontent.com/5669954/57507473-83014100-7331-11e9-8454-4379762ed409.png)]
這樣做的目的是確保最后用于生成odata service的consumption view A, 其字段全部來自 view B.
比較correction之前的實現: consumption view A,其字段部分來自view B, 部分來自view C, 這種scenario并不被SADL 框架支持。
original view:
new created consumption view:
@AbapCatalog.sqlViewName: 'zcorderview' @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'service order consumption view'@OData.publish: true @ObjectModel: {type: #CONSUMPTION,compositionRoot,createEnabled, deleteEnabled,updateEnabled }define view Z_C_Service_Order_View as select from Z_i_Order_View {key Z_i_Order_View.order_guid as order_guid,Z_i_Order_View.object_id,Z_i_Order_View.description,Z_i_Order_View.stat,Z_i_Order_View.txt04,Z_i_Order_View.txt30,@ObjectModel.association.type: [#TO_COMPOSITION_CHILD]Z_i_Order_View._Item}After correction it works with the following url:
https://jerry44354/sap/opu/odata/sap/Z_C_SERVICE_ORDER_VIEW_CDS/Z_C_Service_Order_View(order_guid=guid’00163EA7-2000-1ED2-85EF-EFADF195A1B2’)
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的How to resolve ASSERTION_FAILED error when you register the odata service expose的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 打造中国版OpenAI!王小川创立百川智
- 下一篇: 诺贝尔经济学奖得主:AI 聊天机器人可以