ITPub博客

首页 > 应用开发 > IT综合 > SAP Cloud for Customer Oberon视图里的Ruby Script

SAP Cloud for Customer Oberon视图里的Ruby Script

原创 IT综合 作者:i042416 时间:2020-09-03 11:08:42 0 删除 编辑

In C4C Oberon views developed by UI Designer it is allowed to write Ruby script at some given position. Once you activate the Oberon view in UI Designer, corresponding JavaScript code will automatically be created and visible in XRepository. Here below are some typical positions where Ruby Script could be inserted:

Where could Ruby Script be inserted in UI Designer

(1) In Event operation with type “Script”



Ruby Script:

if ($data.UIState.ViewSwitchSelectedItem == "Collections")
       $controller.HandleEvent("OnRefreshCollection");end

The corresponding JavaScript code is then visible in view’s source code in XRepository:



(2) In Operation configure tab:



The automatically generated JavaScript code:



(3) Dynamical manipulation on the value of control attribute via Script Take “Visible” for example:



Then you can write script here:



How to debug Script in the runtime

Set a breakpoint in function _executeScript in file resources/sap/client/evt/ClientOperation.js. In the runtime, a new JavaScript function will be dynamically created based on the source code stored in XRepository in line 292, and immediately gets called in subsequent line 293.



Still take the Script above as example, if you just would like to know the actual value of $System.ClientType in the runtime, it is not necessary to figure it out via debugging. Instead, append the url fragment “debugMode=true”, and then launch application again.



Press control key and click page, the client Inspector will be opened. Switch to tab “Data Model”, search by keyword “ClientType”, and then you can get its runtime value “NEW_HTML”.




来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24475491/viewspace-2716786/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
SAP成都研究院开发专家,SAP社区导师,SAP中国技术大使。

注册时间:2018-01-20

  • 博文量
    1914
  • 访问量
    882250