Writing Data (Outbound) using Model Reference

Objective

After completing this lesson, you will be able to write the data in the desired external database.

Outbound Data Processes

Here, we explore the outbound data processes, focusing on writing data from one environment to another within the SAP system, and writing data to external systems. We discuss the use of Model Reference, Model HANA, and the different protocols and functions required for these operations.

The image depicts a complex system architecture diagram. It shows various components and their relationships, including Fields, Characteristic, Keyfigure, Currency, Unit, In-Data, Comment, Association, Folder, Environment, Connection, Function, Inbound, Enrichment, Processing, On-the-Fly Enrichment and Processing, Outbound, Model Reference, Model HANA, Model Entity, Reader, Writer, Allocation, Calculation, HANA, ODATA, SAC, and SOAP. The note explains that upon activation, a runtime environment will be created from the design-time environment event without configured fields, functions, and so on.

Key Concepts of Outbound Data Processes

Outbound Data Writing

Within SAP Environments:

Model Reference: This function allows you to write data from one environment to another within the SAP landscape. By using model reference, you can transfer data seamlessly between environments, ensuring data consistency and integrity.​

Example Use Case:

Cross-Departmental Data Sharing: Suppose you must write financial data from an accounting environment (Environment A1) to a reporting environment (Environment A2). Using Model Reference, the data can be written to the target environment without any loss, enabling consistent and accurate cross-departmental data sharing.

To External Systems:

Model HANA: If you must write data to an external HANA table, you can use the Model HANA function along with a writer function to facilitate this process. It is essential for scenarios where data must be integrated with external HANA databases.

Example Use Case:

Enterprise Data Warehouse Integration: Consider a situation where SAP operational data must be written to an external HANA-based enterprise data warehouse. Using Model HANA with a writer function, the data can be seamlessly transferred, enabling comprehensive enterprise-wide analytics.

Reader and Writer Functions:

  • Reader: Used to read data from other environments or external systems. For example, reading data from Environment A by using a model reference with the reader function.
  • Writer: Used to write data to other environments or external systems. For example, writing data to an external HANA table by using a model reference with the writer function.

Protocols for External System Integration:

SOAP Protocol: When writing data to an external SAP S/4HANA system, you can use the SOP (SAP OData Protocol) to ensure proper data transfer and integration.

Example Use Case:

SAP S/4HANA System Integration: If operational data from your SAP environment must be updated in an SAP S/4HANA system, using the SOP protocol ensures that data is correctly written and integrated into the external system.

SAP Analytics Cloud (SAC): To write data in the SAC environment, you can use the SAC protocol or direct data integration methods provided by SAP.

Key Points to Remember

  • Outbound Writing: Involves writing data either within different SAP environments or to external systems.
  • Model Reference: Facilitates data transfer between environments within the SAP ecosystem.
  • Model HANA: Used for writing data to external HANA tables.
  • Protocols: SOAP protocol is used for SAP S/4HANA system integration, while SAC is used for writing data to SAP Analytics Cloud.

The Writer Function

Here, we explore the functionality of the Writer function within SAP, specifically focusing on its role in writing data to external sources. It includes writing data from standalone model entities to external HANA tables, views, other environments, or external data services. We also discuss the constraints and alternatives to nested joins in the universal model, and how deep nested compositions can be used effectively.

The image titled WR2HANA - Write to Document2 Table displays a configuration interface for writing data to a table. It includes sections for General Information, Fields, and Documentation. The General Information panel shows the environment (DEMOOBHC), function (WR2HANA), type (Insert), connection options, input (INT2), result model function (UMDEMO_TABLE2), and reversal field settings. A table listing ID, Description, and Connection Target Type displays connections DJDEMO and DJSAC01, with target types HANA Schema and SAC Model, respectively. The interface also includes validation options and timestamp of changes, showing Jul 10, 2024, 10:07:17 AM.

Key Features of the Writer Function

Data Writing to External Sources:

Standalone Model Entities: The Writer function is primarily used to write data from standalone model entities to various external sources. These external sources can include HANA Cloud databases, tables, views, other environments, and external data services.

Deep Nested Compositions:

Compositions: The Writer function allows you to write deep nested compositions, meaning that the output fields can include fields from related tables. This capability is important for composing comprehensive datasets that reflect relationships and associations between different data elements.

Example of Writing Data to External Sources:

Business Scenario: Suppose you operate a multichannel retail business and must export transactional data from your SAP environment to an external HANA Cloud database for omnichannel analytics. The Writer function enables this by facilitating the transfer of detailed sales transactions, including nested compositions that might link transactions with customer and product data, ensuring a holistic view of the data.

Key Points to Remember

  • Writer Function: Writes data from standalone model entities to external sources, such as HANA tables, views, other environments, and external data services.
  • Deep Nested Compositions: Allows output fields to include fields from related tables, creating comprehensive and relational datasets.
  • No Nested Joins: The Universal model doesn’t support nested joins. Use simple joins one at a time, or rely on master data, associations, and relationships to link data entities.
The image titled Outbound – Writer function shows a table detailing how input data transforms through the writer function. The top table represents the initial input with columns PRODUCT, CUSTOMER, and QUANTITY. The middle section displays the fields of the writer, detailing selections and resulting fields for PRODUCT, CUSTOMER, and QUANTITY. The bottom table shows the final output model with columns PRODUCTA, CUSTOMERA, and QUANTITYA, indicating transformed values of PROD01, CUST01, and 10.

The Different Operations Available in the Writer Function

Here, we break down the different operations available within the Writer function, which include: Delete and Insert, Insert, and Update and Insert. We also explore the various parameters and fields integral to these operations, ensuring you can effectively use the Writer function to manage data within SAP environments.

Operations of the Writer Function

Delete and Insert:

Function: This operation deletes data from the output table and appends new data from the input function.

Example Use Case:

Periodic Data Refresh: In scenarios where you must periodically refresh a dataset (for example, daily transactional data), this operation ensures that outdated data is removed and replaced with the latest entries.

Insert:

Function: This operation appends data to the output function without deleting existing entries.

Example Use Case:

Incremental Data Addition: If you must continuously add new records to a dataset (for example, new customer registrations), this operation allows for the seamless addition of data without affecting existing records.

Update and Insert:

Function: This operation updates saved records in the output function based on key values and also appends new data without deletion.

Example Use Case:

Data Synchronization: In scenarios where you must update existing records (for example, modifying user profiles) and simultaneously add new entries (for example, new users), this operation ensures that both actions are handled in one step, maintaining data integrity and consistency.

PLACEHOLDER FOR IMAGE?

Here, we have one example of selective Writer functionality.

We want to write the data from the Input of Writer table to the Result Model Function of Writer table. The second one is empty and ready to be populated.

In the Fields of Writer section, we see the configuration of this Writer function. There is only one applicable selection, for PROD01, which means all rows with the PROD01 value in the PRDODUCT column are written in theResult Model Function of Writer table.

In this simple example, one out of two rows from the input table fulfill the previously mentioned condition and that’s why we have PROD01 CUST 01 and 10 in the final result.