Introducing the On-the-Fly Model Function

Objective

After completing this lesson, you will be able to to enrich your data on-the-fly".

On-the-Fly Calculation

In this lesson, we delve into the concept of On-the-Fly data processing using Model Functions. This powerful feature ensures that any changes to your input data automatically and instantaneously update the output without requiring you to reactivate or rerun the function. This seamless recalculation is known as On-the-Fly calculation and it is an essential property applicable to all Model Functions.

Key Features of On-the-Fly Calculation

Automatic Updates: One of the most significant advantages of using Model Functions is their ability to immediately reflect changes in input data. This property eliminates the need for manual reactivation or rerunning of the function. Simply saving the modified data is sufficient to trigger the recalculation and update the output.

For example, suppose you're managing a financial model that forecasts quarterly revenue based on various input parameters such as sales data, marketing spend, and operating costs. If there is an update in the sales data, the Model Function immediately adjusts the revenue forecast accordingly, ensuring that your financial projections are always up-to-date.

Consistency Across Functions: The On-the-Fly feature is applicable to all Model Functions. Whether you're working with financial models, operational optimizations, or complex data transformations, you can rely on this feature to maintain the accuracy and currency of your outputs.

Practical Insight

Consider a scenario where a sales manager must generate reports based on real-time sales data. With the On-the-Fly calculation property, any new sales figures entered into the system instantaneously update the related Model Functions. This immediate reflection ensures that the sales manager always has access to the most current and accurate data, facilitating timely decision-making.

Practical Example

Let's look at a practical example to demonstrate the dynamic capabilities of Model Calculations. This example will illustrate how changes to input formulas are automatically reflected in the calculated fields within your environment, showcasing the efficiency and immediacy of on-the-fly calculations.

Example Scenario: Updating a Financial Model

Scenario: Suppose we have a financial model where we calculate TotalIncome (*) using a formula (sum) that includes various income components such as: Tax Free Income + CapitalGains + Dividends + Other Income.

Requirement: Now, the requirement changes, and we need to recalculate the TotalIncome to include only Tax Free Income + Capital Gain + Dividends, excluding Other Income.

Updated Formula: Total Income = Tax Free Income + Capital Gains + Dividends

Automatic Update: Upon reactivation of the environment, the calculated field for "Total Income" will automatically update based on the new formula (check the TotalIncome numbers for Sunshine Holding (Sunshine) row).

Immediate Effect: You will see the updated calculated field instantly, reflecting the new total income of 1400 instead of the previous 1800.

This exemplifies how changes are seamlessly and automatically applied within the system, enhancing efficiency and accuracy.

The image displays a table with financial information for several companies, including details on tax-free income, capital gain, dividend, other income, currency, and document type. The table can be updated by changing the input data, reactivating the environment, and recalculating the fields.

Building on our previous example, let's explore how changes in input data, in addition to changes in formulas, can impact the results in real-time using Model Calculations. This ensures a dynamic and responsive environment where both the formula and input data can drive updates to calculated fields.

Initial Input Data

FieldValue
Tax Free Income500
Capital Gains500
Dividend400
Other Income400

New Input Data

FieldValue
Tax Free Income1000
Capital Gain1000
Dividend400
Other Income400
  

Immediate Reflection: Upon reactivation, the calculated field for "Total Income" will automatically update to reflect the new input data.

Business Scenario: Picture an investment advisor who needs to provide clients with up-to-the-minute portfolio valuations. If any input data, such as market movements or income updates, changes, Model Calculations immediately update the total portfolio value. For instance, if capital gains and tax-free income values double, the total portfolio valuation adjusts in real-time, ensuring clients always see the most current information.

The image displays a table with financial information for several companies, including details on tax-free income, capital gain, dividend, other income, currency, and document type. The table can be updated by changing the input data, reactivating the environment, and recalculating the fields. The calculated fields will automatically update based on the changes.

The Differences between Model Calculation and Calculation Functions

In this lesson, we explore the nuances between Model Calculation and Calculation functions within the SAP e-learning platform. Although both functions aim to process data, they operate differently based on their intended use cases and underlying mechanisms. Understanding these differences helps you use each function effectively according to your specific needs.

The image shows two sections, one titled Model Calculation - creates a view and the other Calculation - creates a table. The Model Calculation - creates a view section displays SQL code for creating a view, while the Calculation - creates a table section displays SQL code for creating a column table.

Key Differences Between Model Calculation and Calculation Functions

Model Calculation:

  • Information Function: Model Calculation primarily acts as an information function. Upon successful activation, it generates a SQL view in the underlying database schema of the tenant.
  • Simple and Complex Calculations: It performs both simple and complex calculations using information functions such as Model, Entity, and Model View.
  • Input Restrictions: Model Calculation can only accept other model functions as inputs. This means you cannot use regular joins or views; instead, you must use model-specific functions like Model View, Model Join, and Model Entity.
  • Real Time Updates: The results are updated in real-time as input data changes, using On-the-Fly calculations for instantaneous updates.

Calculation (Processing Function):

  • Processing Function: On the other hand, the Calculation function acts as a processing function. It generates SAP HANA procedures that execute to populate temporary data records.
  • Modifiable Data: These temporary data records can be modified or edited during runtime via the Show screen, providing a level of flexibility that is not available in Model Calculations.
  • Data Handling: This function is more suited for scenarios where data must be processed and then potentially altered during runtime.

Key Points to Remember

Model Calculations:

  • Generate SQL views upon activation.
  • Perform calculations using model-specific information functions.
  • Accept only other model functions as inputs (for example, Model View, Model Join).
  • Suitable for real-time, up-to-date calculations without needing procedural modifications.

Calculation Functions:

  • Generate SAP HANA procedures that populate temporary data records.
  • Allow modification and editing of these records during runtime.
  • Suitable for scenarios requiring complex data processing and runtime adjustments.

The Advantages of Using Model Functions

One of the standout advantages of using Model Functions is their superior performance. This effectiveness stems from how they handle data in the background, avoiding the creation of extensive procedures and temporary tables, known as Y tables, which are typical in other methods.

Key Features

Efficient Data Handling:

  • No Y Tables: Unlike some other processing functions that generate temporary Y tables in the background, Model Functions create SQL views instead. This approach significantly reduces the overhead associated with handling large datasets.
  • Improved Performance: By creating a projection and view on top of the input data, Model Functions optimize performance. Views are generally more efficient because they do not require extensive background procedures to execute.

Advantages of Using Views:

  • Resource Efficiency: Views consume fewer resources compared to procedures that generate temporary tables. This efficiency can lead to faster execution times and reduced system load.
  • Simplified Management: Since views merely represent the data rather than duplicating it, they simplify data management. It can be particularly beneficial in complex models where data consistency and integrity are paramount.

The Model View

In this lesson, we explore the concept of Model View, an important information function at SAP that allows for the projection or aggregation of input data. We also compare it with the View function, which serves as a data enrichment tool. Understanding these distinctions help you effectively use these functions based on your specific needs for data projection, aggregation, and enrichment.

Key Features of Model View

Model View as an Information Function:

  • Projection and Aggregation: Model View is primarily used to project or aggregate data from an input function. This means you can create different perspectives or summarizations of your data without modifying the original dataset.
  • SQL View Generation: Upon successful activation of a Model View, an SQL view is created in the underlying database schema of the tenant. This view acts purely as an informational projection or aggregation based on the input, without generating any procedural overhead.
  • Performance Efficiency: Since Model View generates SQL views rather than procedures, it offers better performance by reducing the computational overhead and system load.

Example Functionalities:

  • Projection: You can create a focused view of your dataset by selecting specific columns or data points, simplifying data analysis.
  • Aggregation: Summarize data to provide aggregate results such as totals, averages, and counts, which are useful for reporting and analysis.

View as a Data Enrichment Function:

  • Procedure Generation: Unlike Model View, the View function generates SAP HANA procedures that execute to populate temporary data records. These records can be modified or edited during runtime via the Show Screen.
  • Data Modification: View is better suited for scenarios where data must be enriched and then potentially altered during runtime, offering a higher degree of flexibility.

Key Points to Remember

Model View:

  • Generates SQL views upon activation.
  • Used for data projection and aggregation.
  • Offers performance efficiency by reducing procedural overhead.

View:

  • Generates SAP HANA procedures.
  • Used for data enrichment and modification.
  • Allows runtime editing of temporary data records.

Detailed Explanation of Model View

Model View as an Information Function:

  • Projection and Aggregation: The primary role of Model View is to project or aggregate data from an input function. Unlike data enrichment functions, which often involve complex processing, Model View simplifies the data into more accessible formats.
  • SQL View Generation: Upon successful activation of a Model View, an SQL view is generated in the underlying database schema of the tenant. This SQL view operates as an information function, representing a transformed or summarized version of the input data without creating extra procedural overhead.
  • Technical Behavior:
  • No Procedure Creation: When you activate a Model View, no SAP HANA procedures are created. It is crucial because it means that Model View operations are generally less resource-intensive and perform better under heavy data loads.
  • Efficient Data Representation: By generating a SQL view, Model View effectively provides a projection or aggregation layer over the input data. It makes it highly efficient for read-heavy operations where real-time data modification is not required.