Working with Column and Data Pruning using the View Function

Objective

After completing this lesson, you will be able to use the View function for aggregation and projection of data.

The View Function

In the Data enrichment chapter, we have several functions to manipulate the data that is coming into the system. ​The first Enrichment function that we go through is the View Function.

Screenshot of SAP Fiori App - Manage Views

Key Capabilities of the View Function

The View Function in the Universal Model provides various capabilities essential for effective data management. Here’s a brief overview of what you can achieve with it:

  • Projection and Aggregation
  • Data Selection and Filtering
  • Column and Data Pruning
  • Data Mapping

Projection and Aggregation

One of the primary uses of the View Function is to project and aggregate data:

  • Projection: Select and display only the relevant data fields you need for further processing.
  • Aggregation: Perform summary operations such as summations, maximum, minimum, and average values across selected datasets.
  • Practical Example: Suppose you must generate a summary report of sales data. You can use the View Function to project only the sales figures and customer regions. Then, aggregate the data to calculate total sales, average sales per region, and identify the maximum and minimum sales values.

Data Selection and Filtering

Another crucial capability is data selection and filtering:

  • Record Reduction: Apply selections to filter and reduce the number of records for subsequent processing.
  • Conditional Data Selection: Use specific criteria to include or exclude records based on your requirements.

Column and Data Pruning

Column and Data Pruning helps in managing the data fields that you work with:

  • Exclude Unnecessary Columns: Explicitly include only the columns required for processing, in that simplifying data handling and increasing performance.
  • Optimize Data Sets: By reducing the number of columns, you enhance data processing efficiency and clarity.

Aggregation and Projection

The image shows the details of an object called M2U7_DocumentsAggregation in a software application. It includes general information about the object, such as the environment it belongs to and the function it performs. The image also displays a list of items associated with the object, including their type and name.
  1. Create the View Function in the "Manage Functions" tab of your environment.
  2. In the initial Configuration Screen, choose "Edit".
  3. Fill the "General Information" section such as
    1. Type: Projection or Aggregation
    2. Input: The function you'll be using for your input data
  4. In the "Fields" section, choose Create.
  5. A line will be added in the "Fields" section where you can choose the:
    1. Input Fields from your input function
    2. Aggregation or projection Option
  6. Choose "Save".
  7. Activate the function by activating the environment in "Manage Environments.
  8. Optional Steps after objects activation:
    1. Run the function via "Manage Functions" or "Manage Activities."
    2. To show data, see "Show Data."

View – Section ‘Fields’

Input Field coming from the input that can be processed further. It is not mandatory to add the field here, but adding a field means you can further perform aggregation, exclude it from the result, map it to another field or perform a value selection.

Select an aggregation option ("Average", "Count", "Group", "Maximum", "Minimum" or "Summation") from the dropdown list if you want to combine or group data records.

The system maps the field to an output field if you are using Aggregation options, such as "Minimum", "Maximum", "Summation", "Count", or "Average".

If you choose the Aggregation option "Group", mapping is possible even if no output field is selected.

Image explains fields in a table: Input Field (processed further), Selections (filter rows), Aggregation (set aggregation function), Exclude (exclude input columns). The table includes TaxFreeIncome and CapitalGain for summation, Currency for group, Output fields for mapping to other fields, and information on using identical fields from different functions.

Key Capabilities of the Aggregation View

Key Capabilities of Aggregation View

The Aggregation View allows you to group data records and apply various aggregation options. It is essential for generating summarized data outputs that facilitate analysis and reporting. Here’s what you must consider when working with aggregation views:

  • Aggregation Options
  • Explicit Field Selection
  • Output Configuration
  • Aggregation Options

The primary purpose of the Aggregation View is to group data records based on field aggregation options. These options include:

  • Average: Calculate the average value of a set of records.
  • Count: Count the number of records in a group.
  • Group: Organize records based on unique values in the selected fields.
  • Maximum: Identify the highest value in a set of records.
  • Minimum: Identify the lowest value in a set of records.
  • Summation: Calculate the total sum of values in a group.
  • Practical Example: If you are analyzing sales data, you might want to group records by region and then apply summation to get the total sales for each region. Also, you could use the count option to determine the number of transactions in each region.

Explicit Field Selection

When creating an Aggregation View, it is crucial to explicitly add all fields that you need in the output. Fields not included with an aggregation option are excluded.

Key Points to Remember

  • Default Exclusion: By default, any field without an aggregation option applied does not appear in the output.
  • Field Selection: Ensure you explicitly include all necessary fields during the view configuration.
Image shows input data from table M2U7_Documents listing companies, descriptions, year, capital gain, tax free income, dividend, other income, currency, and document type. Below, results of Aggregation View display summarized data for Moonlight Holding, Starlight Holding, Sunshine Holding, and Twilight Holding in 2023, including capital gain, tax free income, dividend, other income, and currency.

Data Pruning

Data pruning involves trimming or massaging your dataset to exclude irrelevant rows and columns, streamlining the data used for analysis or reporting. It is essential for managing large datasets and ensuring that data processing is efficient and focused on the necessary information.

Key Aspects of Data Pruning

  • Column Pruning: Excludes unnecessary columns.
  • Row Pruning: Filters out rows that do not meet specific criteria.
  • Data Selection: Applies conditions to select relevant data.

Column Pruning

Column Pruning is used to exclude columns that are not needed for further processing. It simplifies your dataset and increases performance by reducing the volume of data processed.

Key Characteristics

  • Exclusion of Unnecessary Columns: Remove columns that do not contribute to the current analysis.
  • Data Simplification: Focus on relevant data fields, making datasets more manageable.
  • Practical Example: Suppose you have a dataset with 50 columns, but only 10 of them are relevant for your current task. Column pruning removes the 40 unnecessary columns, simplifying your data and enhancing processing speed.

Row Pruning

Row Pruning filters data to include only the rows that meet specific conditions or criteria. It reduces the dataset size and allows you to focus on relevant records.

Key Characteristics

  • Conditional Filtering: Apply conditions to select specific rows.
  • Data Relevance: Ensure that only pertinent data is processed.
  • Practical Example: If you have a dataset containing records for the past 10 years but only need data from 2020 to 2024, row pruning allows you to filter out records from other years, focusing on the relevant timeframe.
Image shows input data from table M2U7_Documents listing companies, descriptions, year, capital gain, tax free income, dividend, other income, currency, and document type. Below, results of Projection View display filtered data for Moonlight Holding and Twilight Holding, showing tax free income, capital gain, other income, document type, and currency.