Performing Basic Extensions

Objective

After completing this lesson, you will be able to create a Custom Project

Extending an SAM MDK Project

1 - Create a custom component. 2 - Copy the .service files into the custom component and refresh objects. 3 - In the custom component make necessary changes to pages, rule, and so on. 4 - Create/Update SAM CIM file with Integration point. 5 - SAM MDK Deploy to Mobile Service. 6 - Sync client and test

The diagram shows the sequence of the steps to be performed to extend/enhance the MDK Project.

It consists of the following six steps:

  1. Create a custom component.
  2. Copy the .service files into the custom component and refresh objects.
  3. In the custom component make necessary changes to pages, rule, and so on.
  4. Create/Update SAM CIM file with Integration point.
  5. SAM MDK Deploy to Mobile Service.
  6. Sync client and test.

Create and Customize a Custom Component

Note

The steps below are giving a guide so that you can perform this exercise in your own system landscape.

Task 1: Establish a Connection Between BAS Workspace and Your Mobile App in Cloud Foundry

If you have not already completed this step in the exercise Setup of the Development Environment in Business Application Studio, then complete this now before you proceed with creating a custom project for extending the Mobile App.

Note

Refer to the exercise Setup Development Environment in SAP Business Application Studio in Unit 3.Your trainer provides the URL to the Business Application Studio.

Steps

  1. Log in to Cloud Foundry.

    1. Use Menu ViewFind Command.

    2. Choose command or type CF: Login to Cloud Foundry.

      The Cloud Foundry Sign In and Targets page displays.

    3. Enter your credentials (email_address/Password) or select Sign In or select SSO Passcode.

    4. Choose the link and authenticate in the new tab.

    5. Copy the code and close the tab to return.

    6. Paste the code and choose Sign In.

      The page refreshes.

    7. Select the correct Cloud Foundry Organization. For the training, there is only one Organization, so this will default.

    8. Select the Cloud Foundry Space. Based on the group number assigned choose the Space with the range. For example: If your group is 07 choose the space 06_10.

    9. Choose Apply.

      Once you establish the connection to the Mobile App, the BAS workspace will then use this for:

      1. MDK Deploy: Deployment of MDK Metadata to the appropriate app.
      2. Sync Service: Mobile Connections/Destinations created within the App are used for Sync the Metadata changes from the back end.

      Note

      At the time of the MDK Deploy or Sync Service you are prompted to choose the Mobile App. Make sure to choose your own app based on the group assigned to you.

Task 2: Create a Custom Component (New MDK Project)

Steps

  1. Create a ZSAMComponent project for the custom component.

    1. Log in to SAP Business Application Studio.

    2. Once within the BAS, create a new project via Menu FileNew Project from Template.

      Note

      By default the new project is created in /home/user/projects same as the AssetManager Project.

    3. On the next page of Wizard, choose MDK Project.

    4. Choose the Start button.

      Choose Start.
    5. In the next page, enter the basic information of the project and choose the Finish button.

      Use the following data:

      MDK Template TypeEmpty
      MDK Template Type<Empty>
      Your Project NameZSAMComponent
      Your Application NameZSAMComponent (auto populated based on Project Name)
      Target MDK Client VersionMDK 6.0+ (For use with 6.0 or later clients)
      Choose a target folder./home/user/projects (auto populated based on preferences)

      Note

      For additional information on the MDK Project Creation, refer https://developers.sap.com/tutorials/cp-mobile-dev-kit-offline-app.html

      Hint

      After the creating the new project, you can view both projects in the workspace. However, if you only see one project, from the menu choose FileClose Folder. Then, choose Files and folders. Enter /home/user/projects. Choose OK. Choose Open Workspace and choose the default projects workspace.

      Choose projects.

    6. Once the new project is created in the workspace you see files and folders within.

      Screenshot of the workspace showing the files and folders.
  2. Add a reference to the standard application.

    1. Choose Application.app

    2. Right click, and from the menu choose Open WithSelect Text Editor.

    3. Add the following code:

      The code is added to the Application.app tab.
    4. Maintain the Localization and ReferenceApplications fields as shown in the following image.

      Screenshot highlighting Localization and ReferenceApplications.

      Note

      When there are no options in the Localization field, yo can skip this entry.

Task 3: Copy the Service Files

The component project uses the same back-end oData service as the SAP Service and Asset Manager project. So, copy the AssetManager.service and OnlineAssetManager.service service files from project SAPAssetManager.

Steps

  1. Copy the AssetManager.service from the SAPAssetManager project to your custom ZSAMComponent.

    1. Expand the SAPAssetManager project.

    2. Locate and open the Services folder.

    3. Right-click the AssetManager.service and choose Copy... or use (Ctrl+C).

      Righ-click AssetManagerService and select Copy.
  2. Paste (Ctrl+V) the AssetManager.service file into the ZSAMComponent project. Then Sync the Service to download the updated Metadata (Objects).

    1. In the ZSAMComponent project, right-click Services and choose Paste (or Ctrl+V).

      Note

      If the "right click copy and paste" does not work in your browser, choose Ctrl+C and Ctrl+V.

    2. In the Services folder under the ZSAMComponent project, double-click AssetManager.service.

      Note

      When you copy the Service, you may be prompted to log in to Cloud Foundry. This information is used by the service to connect to SAP back end to Sync the Metadata (refresh the Object).

    3. Enter the credentials provided by your Trainer (email_address/password).

    4. Choose the Cloud Foundry Target Organization and CF Space. Choose the space based on the group assigned to your ID.

    5. Select the mobile application from the Mobile Services.

    6. Choose Sync Objects to refresh the objects from the service.

      Choose Sync Objects.
    7. In the Refresh Objects pop-up, choose OK.

      Note

      When you choose Sync Service, the corresponding xml file (with the same name as .service file) is updated. This xml file is the metadata and fetched from the back end.

      If for any reason you cannot perform the sync service (connectivity to backend is broken and so on) as a workaround, you can get the metadata file and upload it manually, so that the latest OData Model changes in the back end get reflected in your project.

  3. Copy the OnlineAssetManager.service from the SAPAssetManager project to your custom project ZSAMComponent.

    1. Repeat the steps that you have performed for the AssetManager.service file for the OnlineAssetManager.service file.

      Note

      The online service has a reference to a Rule /SAPAssetManager/Rules/Common/Passport/GetSAPPassportHeaderValue.js

      The Rule in-turn has a reference to a Global /SAPAssetManager/Globals/Passport/ComponentName.global.

      Copy both these files into the corresponding folders of the ZSAMComponent project. You have to create a Passport folder. Once you copy the files, change the reference to the current project (ZSAMComponent).

    2. In ZSamComponent, find the created passport folder under the Rules folder.

    3. Paste a copy of the GetSAPPassportHeaderValue.js from the SAP AssetManager project.

    4. In the code, change the reference to the current project (ZSAMComponent).

      The reference code is updated to the current project.
    5. In ZSamComponent, find the created passport folder under the Globals folder.

    6. Paste a copy of the ComponentName.global from the SAP AssetManager project.

      In the screenshot ComponentName.global is highlighted.
    7. In the AssetManager.service and OnlineAssetManager.service files, change the reference to the current project (ZSAMComponent).

      In the Headers section, the Value field is highlighted.

Task 4: Customize the Overview Page

Steps

  1. Copy the overview page from the SAPAssetManager Component into the ZSAMComponent.

    1. In the SAPAssetManager project, navigate to the Pages folder.

    2. Right-click the Overview page and select Copy.

    3. Navigate to the ZSAMComponent project.

    4. Right-click Services and choose Paste.

  2. Open the Overview.page in the ZSAMComponent project for editing.

    1. To open the layout editor in the Business Application Studio, in the ZSAMComponent project double-click the Overview.page.

    2. Ensure both the left and right pane of the layout editor are enabled.

    3. Choose the Outline tab to switch to the Outline view.

    4. In the layout, use the scrollbar to navigate down to choose the section high_wokrorders. Select the corresponding SectionObjectCollection in the outline.

      In the Overview page, in the Outline tab, select SectionObjectCollection.
  3. In the Outline, choose Section Header to change the caption of the High Priority Work Orders section to Active Work Orders.

    1. Choose High_Workorders in the section header.

      In the section header, choose High_Workorders.

      Note the Syntax of the caption $(L,high_workorders). This syntax is used to display a string from the i18n.properties file. The i18n.properties file is used by translators to convert strings to other languages. During runtime, this string displays the caption in the appropriate language that has been set for the device. As a result, it is good practice to use this file to maintain all strings displayed to the user.

    2. In the Properties tab, change the caption to Active Work Orders.

      Change the caption to Active Work Orders.
  4. Edit the Active Work Orders section only to display the workorders that have Started or are On Hold.

    1. In the Outline view of the Overview.page, choose SectionObjectCollection.

    2. In the Properties tab in the Target section, to bring up the Query Options Express Editor, choose the link option next to the QueryOptions field.

      Choose the Query Options link.The Query Options Express Editor window displays with the default query criteria.

    3. Choose Clear to remove the existing query criteria.

      $expand=OrderMobileStatus_Nav&$filter=Priority eq '1' or Priority eq '2'&$orderby=Priority,DueDate,OrderId
    4. Enter the following expression in the Expression Value box:$filter=OrderMobileStatus_Nav/MobileStatus eq 'STARTED' or OrderMobileStatus_Nav/MobileStatus eq 'HOLD'

      In the Expression Value, enter the expression.
    5. Choose OK.

      The Active Work Orders sections now only display the workorders that are Started or On Hold.

  5. Update the count in the Active Work Orders section as it is still showing the count of the number of the High Priority Work orders.

    1. Right-click the Rules folder and choose New Folder and enter the name WorkOrders.

    2. Right-click the WorkOrders folder and choose New File.

      Choose New Folder>New File.
    3. Enter WorkOrdersActiveCount.js in the File Name field.

    4. Double-click WorkOrdersActiveCount.js to edit it.

    5. Create a function as shown in the screenshot and use this code to get the number of Active Work Orders:

      Code Snippet
      12345
      export default function WorkOrderActiveCount(context){ return context.count('/SAPAssetManager/Services/AssetManager.service', 'MyWorkOrderHeaders', "$filter=OrderMobileStatus_Nav/MobileStatus eq ‘STARTED’ or OrderMobileStatus_Nav/MobileStatus eq ‘HOLD’"); }
      Screenshot of the WorkOrdersActiveCount.js tab.
    6. Save the file and close it.

    7. In the Outline.page view, choose sap.mde.SectionFooter (under SectionObjectCollection choose content, and then choose SectionFooter).

    8. In the Properties tab, in the Appearance section, choose the link option next to the AttributeLabel field.

      In the Apperance section, choose the AttributeLabel link.
    9. In the Object Browser, double-click the newly created rule.

      /ZSAMComponent/Rules/WorkOrders/WorkOrdersActiveCount.jsIn the Object Browser popup, the Expression field is highlighted.
    10. Choose OK.

    11. Choose FileSave.

      The count now shows the number of work orders that are Started or On Hold.

  6. The count has been updated. However, when we choose the See All navigation link, the Work Order List still shows all of the High Priority Work Orders. Change this so that it shows all Work Orders. For this we overwrite one of the existing standard rules.

    Note

    In this exercise, we overwrite one of the existing standard rules.
    1. In the SAPAssetManager workspace, navigate to RulesWorkOrderListViewWorkOrdersHighPriorityListView.js

      In the SAPAssetManager workspace, the WorkOrdersHighPriorityListView.js tab is highlighted.
    2. Right-click the file and choose Copy(Ctrl+C).

    3. Navigate to ZAMComponentRulesWorkOrders. Right-click WorkOrders, and choose Paste (Ctrl+V).

    4. Double-click the newly added file to open it.

    5. On line 7, change the value of the isHighPriorityList property to be false: isHighPriorityList: false,

    6. Hover the mouse over the import statement (Line 1) and verify that it is pointing to the correct path. If necessary, update the logger path ../../../SAPAssetManager/Rules/Log/Logger and this related path refers to "/home/user/projects/SAPAssetManager/Rules/Log/Logger".

    7. From the menu, choose FileSave.

      Note the import statement on Line 1. The path to the Logger file is a relative path. ../../log/logger indicates that the Logger file can be found by going two levels above the current directory and then going into the Log directory. This path must change based on the relative path from the current location because the file has been overwritten in the custom project.

      So, in this exercise, from the Rules directory in the ZAMComponent project, we must go two levels up and then go into the SAPAssetManager project and get the full path to the logger file. So, the logger path looks like this: ../../../SAPAssetManager/Rules/Log/Logger.

      Screenshot of the logger path.

Task 5: Create and Update the SAP CIM File with the Integration Point

You can use the scripts from the ZSAPComponent zip file (ZSAPComponent folder) to perform the steps that require code; or use the following steps.

Steps

  1. Create a new CIM (component integration metadata) file for ZSAMComponent in SAPAssetManager project.

    Note

    The CIM file is created in the SAPAssetManager project. The file contains the overrides. When you Deploy and Activate, the MDKWebpackFactory project is ether created (first time) or updated.
    1. Right-click SAPAssetManagerApplication.app file and choose MDK: New CIM File.

    2. In the CIM Creation page, make selections.

      Use the following information:

      • Project Name: Choose ZSAMComponent from the Project Name dropdown.
      • Application Name: Choose ZSAMComponent from the drop-down menu.
      • CIM File Name: ZSAMComponent_ZSAMComponent
      • Component Version: nnnn (where nnnn is the product release For Ex: 2205.)

    3. On the Confirmation page, choose Finish.

    4. In the SAPAssetManager, verify that ZSAMComponent_ZSAMComponent.cim has been created.

      The Project Name and Application Name are completed.
  2. Create an integration point (page) for the Overview.page.

    Use the following information:

    FieldValue
    Source/ZSAMComponent/Pages/Overview.page
    Target/SAPAssetManager/Pages/Overview.page

    1. Double-click the ZSAMComponent_ZSAMComponent.cim file.

    2. In the Integration Points section, choose the + icon.

    3. Choose Page.

      Choose the plus icon, then choose Page.
    4. In the Page Integration Point section, choose the Link icon next to the Source field to open the Object browser.

    5. The Object Category shows Page. Enter Overview in the search field.

      Screenshot of the Object Browser. Overview.page is highlighted.
    6. From the search results, choose ZSAMComponent(/ZSAMComponent)PagesOverview.page.

    7. Choose the Insert button to Inset the result into the Expression box.

    8. Choose OK.

    9. To save the integration point setting, choose the 'Blue Check.'

    10. Similarly, for the Target, locate the /SAPAssetManager/Pages/Overview.page.

    11. From the search results, choose SAPAssetManager(/SAPAssetManager)PagesOverview.page.

    12. Choose the Insert button to Inset the result into the Expression box.

    13. Choose OK.

    14. To save the integration point setting, choose the blue Check button.

      To save, choose the blue check icon.
  3. Create an integration point (rules) for WorkOrdersHighPriorityListView.js.

    Use the following information:

    FieldValue
    Source/ZSAMComponent/Rules/WorkOrders/WorkOrdersHighPriorityListView.js
    Target/SAPAssetManager/Rules/WorkOrders/ListView/WorkOrdersHighPriorityListView.js

    1. In the Integration Points section, choose the + icon.

    2. Choose Rule.

    3. Repeating the steps for each page, search for WorkOrdersHighPriorityListView choose the Source from ZSAMComponent Project and the Target from SAPAssetManager Project.

    4. Choose FileSave All.

      Screenshot of the Integration Points section.

      Note

      • We didn’t have to create an Integration Point for the new file WorkOrdersActiveCount.js that was created in the ZSAMComponent project. The integration point is only necessary when the component is overwriting any files in the SAP Service and Asset Manager project.
      • The Crew Component also has an Overview page that overrides the Overview page of the SAPAssetManager project. The ZComponent also has the Overview page so this causes a conflict. However, the CIM files are processed in alphabetical order and the last one wins. Therefore, the CIM file of the ZComponent will win and the Overview page of the ZComponent will be displayed in the Mobile Client (that is, you will no longer see the Crew information).

Task 6: MDK Deploy to Mobile Services

Steps

  1. Deploy the Metadata changes to the SAP Business Technology Platform Mobile Services mobile app.

    1. Right-click the SAPAssetManagerApplication.app file in the workspace. From the context menu, choose MDK Deploy to Mobile Services.

    2. Accept the default destination (CF_DEST_IAM150_##) and Application Id (com.sap.iam150_##) values entered from the previous deployment.

      Result

      Once the MDK App is deployed successfully (that is, /MDKWebpackFactory is rebuild and you get the message "(MDK Webpack) Application deployed successfully. Current Revision:<xx>").

    3. On your mobile device, close and relaunch the mobile app.

    4. A pop-up displays with the message: Update (via re-launching the app).Check for Updates. Choose the OK Confirm button to download new version of the app.

      After the App definition update, verify that your changes are displayed in the Overview page.In the screenshot, you see that there are no high priority work orders available.

      Note

      The Active Work Orders shows the number of work orders that are in STARTED or HOLD status.

Task 7: Start a Work Order

Steps

  1. Start a Work Order.

    1. Choose the Work Orders tile in the Overview page.

      This opens the work order list page.

    2. In the work order list page, choose a work order you want to start. This opens the work order details page.

    3. Choose the Start Work Order button.

    4. Choose Start. You will notice that the work order status has changed to STARTED.

    5. Navigate back to the Overview page. You now see the work order that you have started under the Active Work Orders.

      Result

      This feature enables users to quickly launch the active work orders from the overview page without navigating into the work orders list page.

      In the Active Work Orders section, you see that the work order has started.

Extend SSAM by Adding a new Field to Work Order, Part 1 Back-end

Business Scenario

As part of this exercise, we extend the Mobile App to download and display the Systems Conditions field. The field is part of the Work Order Data and therefore we extend the Work Order Entity.

To view the System Conditions field:

  1. In SAP GUI, launch the Transaction Code: IW33 to display work order display.
  2. Enter Work Order Number.
  3. System Conditions is available on the Header Data tab.

Note

You can use Transaction IW32 to change the System Conditions.

Screenshot of the HeaderData tab. The SystCond checkbox is highlighted.

Solution Overview

In this exercise, we learn how to extend the SAP Service and Asset Manager by downloading and displaying a field currently not on the Mobile App. The exercise is divided into two parts.

  1. Part-1 covers the back end development/configuration changes.
  2. Part-2 will cover the MDK Metadata changes.

Note

The steps below are giving a guide so that you can perform this exercise in your own system landscape.

Task 1: Perform Changes in the Back End of SAP Development and Configuration

1 - oMDO Object Configuration: Configure Filter & Field selection. 2 - oData Model Configuration: Add Property to Entity. 3 - Test Service via /IWFND/GW_CLIENT

Steps

  1. Perform the oData Mobile Data Object (oMDO) Configuration.

    1. Launch the Mobile Application Framework (MAIF) configuration panel using transaction /SYCLO/CONFIGPANEL.

      Note that you have to use /n or /o to launch transactions in the namespace (/N /SYCLO/CONFIGPANEL).

    2. The transaction launches a Web Dynpro App (Refer the following screenshot):

      Screenshot highlighting oData Mobile Data Object Configuration and oData Model Configuration.
    3. In the configuration panel, open the oData Mobile Data Object Configuration.

    4. On the next screen, use the Mobile Application Filter to restrict the app or use the navigation tree on the left to choose your app ZIAM150_SAP_ASSET_MANAGER_##.

      Select an option from the Mobile Application Filter dropdown or use the navigation tree.
  2. Search for oMDO using the keyword work and choose ZIAM_##_WORK_ORDER_GENERIC from the list.

    1. Choose Change.

    2. Navigate to the Field Selection.

    3. Search or scroll to find the field ANLZU (System Conditions) field.

    4. Set the Active checkbox for the field ANLZU.

    5. Choose Save to save your changes.

      Screenshot of the Mobile Application Integration Framework Configuration. The UI controls mentioned in the preceding steps are highlighted.

Task 2: Perform the oData Mobile Data Object (oMDO) Configuration

Steps

  1. Add a field to Model Properties.

    Use the following data:

    FieldValue
    Property NameSystemConditions
    Configuration Nullable= TRUE
    Configuration Extension= TRUE
    Custom LabelSystem Conditions
    Visible in List Screen= TRUE
    Visible in Details Screen= TRUE
    Searchable= TRUE

    1. In the config panel home, navigate to the oData Model Configuration.

      Screenshot highlighting oData Mobile Data Object Configuration and oData Model Configuration.
    2. Use the Mobile Application Filter (No. 1) to restrict the selection to your app.

      Screenshot of the Configuration Home tab. The UI controls mentioned in the following steps are highlighted.
    3. Use the search bar to filter the Entities. Use the keyword work (No. 2).

    4. For the list of Entities choose MyWorkOrderHeader (No. 3).

    5. Navigate to the Properties List tab.

    6. To add another property, choose Change (No. 4).

    7. Choose Add Property and use the oMD Field Name drop down to choose ANLZU (System Conditions).

    8. As Property Name enter SystemConditions (see table above).

    9. As Configuration Nullable set = TRUE (see table above).

    10. Enter the remaining values from the table above.

    11. Save your changes (capture changes into transport).

Task 3: Test Changes via Gateway Client

Steps

  1. Test Changes via Gateway Client.

    Use the following data:

    FieldValue
    HTTP MethodGET (Radio button)
    Request URI/sap/opu/odata/sap/ZIAM_##_SAP_ASSET_MANAGER/?$format=xml
    ProtocolHTTP

    1. Log in to the SAP GUI and launch transaction /N/IWFND/GW_CLIENT.

      Note

      You must use /n to start the transaction.
    2. In the Gateway client, enter the data from the preceding table.

      Note

      Alternatively, you can launch the same via /IWFND/MAINT_SERVICE - Activate and Maintain Services.

    3. Choose Enter to ensure your service returns the metadata.

    4. Choose the EntitySets button (Shift + F1) to open the EntitySets and choose MyWorkOrderHeaders.

      Note

      The RequestURI is /sap/opu/odata/sap/ZIAM_##_SAP_ASSET_MANAGER/MyWorkOrderHeaders.

    5. Choose Execute (F8) and verify that the System Conditions is part of the output data.

      Note

      Proceed to MDK Development only after successfully verifying the test results in SAP.

Extend SSAM by Adding a new Field to Work Order, Part 2 MDK Metadata

Business Scenario

As part of this exercise, we extend the Mobile App to download and display the "Systems Conditions" field. The field is part of the Work Order Data and therefore we extend the Work Order Entity.

Solution Overview

This is the second part of the exercise to extend the SAP Service and Asset Manager by downloading and displaying a field currently not on the Mobile App.

Prerequisite

You have completely and successfully done the exercise: Extend SSAM by Adding a new Field to Work Order, Part 1 Back End.

Note

The steps below are giving a guide so that you can perform this exercise in your own system landscape.

Task 1: Sync the Objects to Update OData Model in MDK

Steps

  1. Once you have confirmed that the SystemCondition is part of the Gateway payload, you sync the service to update the objects in the MDK Project.

    1. Log in to the SAP Business Application Studio.

    2. Open ProjectZSAMComponent.

    3. Navigate ServicesAssetManager.service.

    4. Once within the AssetManager.service, choose the Sync Service button to update the model.

      Screenshot of the SAP Business Application Studio. The UI elements mentioned in the steps are highlighted.
    5. After completing the sync service, check either the AssetManager.xml or the Objects to see if the property was downloaded. In the XML it is the entitytype name = MyWorkOrderHeader. Under Objects, you find: MyWorkOrderHeader.object.

  2. Optional: You can deploy the changes so far and check if the SystemConditions is downloaded to the device.

    1. Navigate to the Application.app and right-click and choose MDK: Deploy from the context menu to deploy the app to your mobile app in SAP Business Technology Platform Mobile Services.

    2. Once the App deployment is successful, you can perform a sync from the mobile device and then download the .udb files from the device and using ILOData, check the database to confirm that there is one WorkOrder that has a SystemCondition value of ‘1’.

      Note

      ILOData is covered Unit-6. If you are not familiar with ILOData, you can skip these steps for now.

Task 2: Add the SystemConditions Property to the Work Order Details Page

Steps

  1. Add the SystemConditions property to the Work Order Details Page.

    Use the following data:

    FieldValue
    Folder nameWorkOrders

    1. In the Asset Manager repository, locate the WorkOrderDetails.page and right click copy (Ctrl+C).

    2. In the ZSAMComponent project navigate to the page, create a folder WorkOrders.

    3. Paste the WorkOrderDetails.page to the ZSAMComponentWorkOrders folder.

      In the SAP Business Application Studio. The WorkOrderDetails.page is selected.
    4. To open the file in the code editor, right-click the file and select Open With…Text Editor.

      Single clicking on the file in the explorer opens the file in the MDK Page Editor. Right-click the file and select Open with...

    5. Choose Text Editor Default.

      Choose Text Editor Default.
    6. Find the Section.Type.KeyValue section named WorkOrderOperationDetailsSection and choose the QueryOptions lines.

      Alternatively search for the field PlannerGroup which is part of the QueryOptions.

      Screenshot of the code in the text editor.
    7. The {@odata.readLink} property means that we are pointing to the current entity that the page is bound to which in this case is the current WorkOrder.

    8. Add the new property SystemCondition to the $select query in the QueryOptions in the WorkOrderOperationDetailsSection.

      This means that we are now fetching this new property from the offline database.Screenshot of the code in the text editor.

  2. Add a new KeyAndValues object like the existing one.

    Use the following data:

    FieldValue
    Value/ZSAMComponent/Rules/WorkOrders/Details/WorkOrderDetailsSystemCondition.js
    _NameKeyValue106
    KeyName"$(L,systemCondition)"

    1. Add the following code:

      Code Snippet
      123456
      { "Value": "/ZSAMComponent/Rules/WorkOrders/Details/WorkOrderDetailsSystemCondition.js", "_Name": "KeyValue106", "KeyName": "$(L,systemCondition)" }
      In the text editor, the code is added.
  3. For the KeyName, add a new translation string in i18n.properties.

    Note

    Use Ctrl + Hover mouse over the field name to navigate directly to the i18n file. You can use the PlannerGroup field to enter a new value for SystemCondition so that the field name strings are together.

    1. Copy the i18n_en.properties from the SAPAssetManager->i18n folder to the ZSAMComponent -> i18n folder.

    2. Open the Application.app with a text editor and change the i18n.properties to i18n_en.properties.

    3. Open the i18_en.properties as well and add the new string, which looks like this: systemCondition=System Condition

      Note

      If required change the Application.app Localization to i18n.

      Screenshot of the SAP Business Application Studio. The Misc field is highlighted.Select i18n>i18n_en_properties.In the text editor, i18n_en_properties is open.
    4. Add context for the new string. Find the section called Context Information for Translators.

    5. Check that line 10 reads:

      "Localization": "/ZSAMComponent/i18n/i18n_en.properties",

  4. For the Value, add a new rule. This rule checks to see if the value is ‘1’ or not. If the value is ‘1’ then we display that the System is In Operation. Otherwise, we show that the System is not in operation.

    Use the following data:

    FieldValue
    File nameWorkOrderDetailsSystemCondition.js

    1. Create a new folder in RulesWorkOrdersDetails.

    2. Create a new file with the name WorkOrderDetailsSystemCondition.js

    3. Enter the following code:

      Code Snippet
      12345678910111213141516
      /** * Display the system condition * @param {IClientAPI} clientAPI */ export default function WorkOrderDetailsSystemCondition(clientAPI) { let binding = clientAPI.binding; //The binding object is the MyWorkOrderHeader object from the WorkOrderDetails.page if (binding.SystemCondition && binding.SystemCondition === '1') { //First check if SystemCondition exists and then whether it is equal to '1' return clientAPI.localizeText('in_operation'); //Use the MDK's localizeText API to refer to an i18n string } else { return clientAPI.localizeText('not_in_operation'); } }
      In SAP Business Application Studio, the code is added.In SAP Business Application Studio, the code is added.
    4. Add the new strings to the i18n_en.properties.

      The new strings are added to i18n_en.properties.

      Note

      For additional information on the MDK API, check the API Reference: https://github.wdf.sap.corp/pages/snowblind/api-reference/.

  5. Update the CIM file.

    Use the following data:

    SourceTarget

    /ZSAMComponent/Pages/Overview.page

    /SAPAssetManager/Pages/Overview.page

    /ZSAMComponent/i18n/i18n_en.properties/SAPAssetManager/i18n/i18n_en.properties
    /ZSAMComponent/Pages/WorkOrders/WorkOrderDetails.page/SAPAssetManager/Pages/WorkOrders/WorkOrderDetails.page
    /ZSAMComponent/Rules/WorkOrders/WorkOrdersHighPriorityListView.js/SAPAssetManager/Rules/WorkOrders/ListView/WorkOrdersHighPriorityListView.js
    The data from the preceding table is added.
    1. Update the CIM file.

    2. Deploy the changes from BAS to Mobile App in CF.

  6. Update the App definitions.

    1. Log in to the mobile app on your mobile device and relaunch the app.

    2. When the app is minimized and launched, you are prompted to update the app definitions.

    3. Click on Ok to download the App definitions deployed to BTP.

  7. Verify that your changes are reflected on the mobile app.

    1. From the Overview Page, choose the work order with values in the System Conditions as tested in the SAP Gateway.

    2. In the mobile device, from the Overview Page, open the work order and navigate to the Details Page.

    3. Check if the System Conditions field is displayed and has a value reflected from the back end.

    4. Go to another WorkOrder that has the SystemCondition property value set to 0. Verify that the Not in Operation text is displayed instead.

      Sample workorders, one with the System Condition, In Operation, the other with the System Condition, Not in Operation.

Log in to track your progress & complete quizzes