Loading Data using APIs

Objective

After completing this lesson, you will be able to understand data loads and dependencies

Data Load through APIs in SAP Intelligent Agriculture

Loading Data in SAP Intelligent Agriculture

Before loading data into SAP Intelligent Agriculture, the same prerequisites that were mentioned in the previous unit apply.

From our experience, it's important to understand the interdependencies across data entities, especially when first loading data in the system.

As mentioned in the previous unit, we have developed a simple tool (API Shell Suite) that supports customers from the beginning of their project by providing:

  • A step-by-step guide on how to consume the APIs (described in the previous unit)
  • Entity-Dependency diagrams to help you understand the sequence in which the data entities must be created
  • Automated scripts for the support of a data load

Disclaimer: The API Shell Suite aims to provide guidance and support for you during testing and trying out of the APIs. While it may be enhanced over time, it's not an official tool delivered with the solution and there is no commitment from SAP that the information reflects the latest development. It should not be used within your productive environments.

Understanding the Dependencies across Entities

Let's explore the dependencies across data entities using the following Entity-Dependency Diagram, Dependencies Across Entities, provided in the API Shell Suite: GitHub: API Shell Suite for SAP Intelligent Agriculture.

Flowchart titled Data Entities to consider before creating a Field. It includes multiple interconnected boxes representing different data entities and relationships. The top section, highlighted in blue, contains entities like CropZone, Farm, and Condition. Additional entities such as Zone are connected throughout the diagram. Important nodes include Zone and EntitiesData linked in the flow, with several intermediary steps and decision points shown with lines and arrows. The chart visually maps out the consideration process for data entities.

This is a living diagram that will evolve over time, please refer to the above link for the latest version.

The Entity-Dependency Diagram was created using BPMN (Business Process Model and Notation) to showcase the relationships among the SAP Intelligent Agriculture data entities. It provides a clear, visual representation of how they interact with each other, the flow of data, and their interdependencies.

Example: What are the Entities that Must be Considered before Creating a Field?

There are mandatory entities:

  • Area Types (required for Areas)
  • Areas
  • Farms
  • Destinations

There are also optional entities:

  • Unit of Measure
  • Field Groups
  • Climate Zone
  • Locations

The same concept applies for Varieties, Materials, Crop Systems, Crop Zones, and so on. Any entity with a preceding box indicates a dependency and the need to create (unless optional) such entity. Entities without preceding boxes do not have dependencies before they can be created.

Loading Data in the System

For technical audiences, in order to understand how to upload a minimum dataset to test the application, you can review the QuickStart section (GitHub - Quickstart: API Shell Suite for SAP Intelligent Agriculture) of the API Shell Suite.

  • Requirements and Configuration: Explains the requirements and necessary programs to be installed, as well as basic configurations related to setting tenant and user information, before you can use the API Shell Suite.
  • The tool can be executed in 3 different contexts to perform the following tasks:
    1. load-data: Use the POST method to create a new data structure for the APIs available. This could be used to load data in a new/empty system for instance.
    2. test-api: Execute the POST, GET, PATCH, PUT, and DELETE verbs for the APIs available. This could be used as a stress test for the APIs and to understand how they work.
    3. load-scenario: Execute a script to create the necessary data for a defined scenario. A scenario could be for instance to create irrigation tasks for sugarcane crop.
  • There are different ways to execute the tool:
    1. Using Shell: Run the script to load data (./app/run.sh --load-data) or optionally, run the command in the background and redirect the output to a log file (./app/run.sh --load-data > output.log &).
    2. Using Docker: If you have a Windows machine and you don't have CURL, you can just install Docker to isolate the execution (./app/run-with-docker.sh --load-data)
    3. Using Docker-Compose: Similarly, you can simulate the execution of multiple instances in parallel for the image consuming the application. This can be used for stress-test or load testing the application.

So let's say you have a new/empty system and you need to load data. Here are the high-level steps to be followed:

  1. Authentication: Make sure to have completed the configurations and entered your user and tenant details in the set-user.sh and set-tenant.sh files.
  2. Run the Data Load Script using Shell: Copy the execution script* and then paste it in the tool. (*from https://github.com/sap-contributions/api-shell-suite#using-shell)
  3. Execution: You will see the script being executed and new data being created. In this case, up to the field entity (as per the flow in the Entity-Dependency Diagram presented before).

Log in to track your progress & complete quizzes