一步步使用SAP C4C Cloud Application Studio创建一个BO和对应的屏幕
打開SAP C4C Cloud Application Studio,
進入Solution Explorer,右鍵菜單里選擇Add -> New Item:
新建一個Business Object,取名CarPark:
源代碼如下:
import AP.FO.BusinessPartner.Global;import AP.Common.GDT as apCommonGDT;businessobject CarPark // *Further Development*// declare an error message that is called if the BO fails validation// raises Message_Car_Park_Full{// Root node must not be specified, it is created implicitly//// Add elements here.//// To declare an element as alternative key, use the [AlternativeKey] // annotation.//Please note:// - An alternative key of type UUID exists implicitly for each node, enabling// the node to be used as an association target.// - The QueryByElements query is created automatically for each node.// Code completion is available with CTRL + SPACE. // *Further Development*// define an error message to be displayed if the BO fails validation// message Message_Car_Park_Full text "The car park is full - no spaces available"; // Car Park ID - (the company may have multiple car parks)// - therefore we use this ID to identify the individual car parkelement CarParkID : ID; // additional information on the car parkelement CarParkName : LANGUAGEINDEPENDENT_LONG_Text;element CarParkDescription : LANGUAGEINDEPENDENT_LONG_Description;element Number_of_ParkingSpaces : IntegerValue;// *Further Development*// add an element to display how many parking spaces are available// element Number_of_ParkingSpaces_Available : IntegerValue;// declare an action to calculate the available car spaces// action Update_AvailableParkingSpaces;// *Further Development*// add an element to record location information// this field is used with a URL mashup to display the location of the car park// element CarParkLocation : LANGUAGEINDEPENDENT_MEDIUM_Description; // each car park will have multiple parking spaces// we create a node with 0 to n parking spacesnode ParkingSpace [0,n] {// each parking space is assigned a unique identifierelement ParkingSpaceID : ID;// display the ID of the Employee assigned to the parking spaceelement ParkingSpace_AssignedEmployeeID : ID;// a parking space may be designated as a "Disabled Friendly" parking spaceelement ParkingSpace_Disabled : Indicator;// is there an electric charging station for this parking space ?element ParkingSpace_ElectricChargeStation : Indicator;// display the license plate number of the employee's carelement Vehicle_RegistrationNumber : LANGUAGEINDEPENDENT_MEDIUM_Text;// for a multi-level car park, we have the possibility to specify a level numberelement ParkingSpace_Level : NumberValue;// we need to create an association to the SAP BO "Employee"// this allows us to include elements from the Employee BO in our screens// a parking space may be associated to at most one employeeassociation ToEmployee [0,1] to Employee;} }激活該BO,確保Activation Status為Runtime Objects up to date:
BO激活后,右鍵菜單選擇Create Screens:
選擇Screen Scenario with Thing-Based navigation:
會自動生成很多SAP Cloud for Customer 屏幕:
雙擊QA打開自動生成的UI,發現上面已經有一些來自BO抬頭級別的字段了:
點工具欄上這個AddFlexLayoutRow按鈕:
出現一個新的空白行:
將Toolbox里的控件AdvancedListPane拖到新建的FlexLayoutRow里:
選中某一個column,右鍵菜單里添加一個新的column:
現在我們有了一個表格,包含四列:
View菜單里打開:BO Browser / Data Model,使其顯示在屏幕右邊:
把ParkingSpaceID拖拽到第一列上去:
選擇No:
從而建立了UI字段和BO 模型字段的綁定關系:
此處查看綁定關系:
顯示employee ID的字段默認是input field,需要將其改成value help:
改成Object Value Selector:OVS
選擇/SAP_BYD_APPLICATION_UI/publicovs/employeeid/
EmployeeID: 作為OVS Component:
把字段:ToEmployee.CurrentCommon.Person.Name.GivenName拖到第三列:
familyName拖到第四列:
把GivenName的display type設置為Static Text:
右邊properties下拉菜單里,選擇AdvancedListPaneVariant: ListPaneVariant:
useToolbar從false改成true:
設置成true之后,多了兩個按鈕:Add Row和Remove.
選中Add Row按鈕,新建一個Event handler:
新建一個operation,類型為List:
Target List里,從下拉菜單選擇/Root/DataList:
給Remove按鈕也添加一個event handler:
再添加一個save action,確保Row被刪除后自動保存:
選中identificationRegion:
點擊Advanced:
選擇CarParkID:
最終效果:
選中SectionGroup,可以對里面的字段進行位置順序調整:
最后把用戶分配到這個新建好的work center即可:
現在就可以進行測試了:
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的一步步使用SAP C4C Cloud Application Studio创建一个BO和对应的屏幕的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 创建课程表设计
- 下一篇: 如何打印计算机准考证