Load SAP Data

The module "Load SAP Data" reads rows from an SAP table via an RFC function module and writes them into a target database table. The fields to be read are derived from the columns of the target table. An optional SQL statement in the transformation action can supply SAP selection conditions.

Name Meaning
Module Load SAP Data
Module Class DsModSAP
Type Java
Purpose Load data from SAP into a database table
Transformation Code SQL statement that returns SAP selection conditions (optional)
Sources Exactly one SAP table (object type SAP Table)
Targets Exactly one database table

Description

The module connects to an SAP system using SAP JCo and calls an RFC function module (typically RFC_READ_TABLE or ZRFC_READ_TABLE). The SAP table name and function module are configured in the SAP source object. The column names of the target table determine which SAP fields are requested.

If an action (SQL statement) is configured, it is executed in the target database. The value of the first column of each result row is passed to SAP as a selection condition in the OPTIONS table of the function module. The target database does not filter SAP data — it only provides the selection text.

Without an action, all rows of the configured SAP table are read (subject to SAP authorization and function module limits).

SAP Connection

The SAP connection is configured in the keyfile as a database connection of type SAP System. The connection URL has the following format:

host:system-number:client:language

Example:

sap.example.com:00:100:DE

User and password are stored in the usual connection fields. If the URL is set to dummy, the module performs no SAP access (useful for validation without a live SAP system).

SAP Source Object

The source is an object of type SAP Table (object type id 10):

Object field Meaning
Connection SAP connection (database id)
Funktionsbaustein (Owner) RFC function module name, e.g. RFC_READ_TABLE, ZRFC_READ_TABLE, ZRFC_READ_TABLE_TEXT
Table (Name) SAP table name, e.g. NAST, VBAK

Exactly one SAP source object may be connected to the module.

Supported Function Modules

The module is designed for function modules based on RFC_READ_TABLE. Commonly used modules include:

Function Module Notes
RFC_READ_TABLE Standard SAP function module
ZRFC_READ_TABLE Customer-specific variant; uses compression
ZRFC_READ_TABLE_TEXT Variant for text tables
ZRFC_READ_TABLE_BSAD Uses OPTIONS_BKPF for selection
ZRFC_READ_TABLE_BSEG Uses OPTIONS_BKPF for selection

The function module must exist in the connected SAP system and the SAP user must have authorization to read the table.

Target Table

The target is a single database table. Its column names (in uppercase) are sent to SAP as field names in the FIELDS parameter. The column data types of the target table should match the SAP field types as closely as possible.

The module reads the target table structure at runtime (SELECT * FROM schema.table WHERE 1=0) and uses the resulting column list for the SAP request and for inserting data.

Data Type Conversion

SAP type Target column type Conversion
Character (C) VARCHAR, VARCHAR2, CHAR Trimmed string; empty values become NULL if nullable
Date (D), 8 characters DATE Parsed as YYYYMMDD; 00000000 becomes NULL
Date/time, 14 characters DATE Parsed as YYYYMMDDHHMMSS
Number (N) with trailing - NUMBER SAP negative format converted (e.g. 123--123)
NOT NULL column, empty SAP value any Single space ' '

Action (SAP Selection Condition)

The action field contains a SQL statement that is executed in the target database. Each row of the result set triggers one SAP read. The first column must contain the SAP selection condition as plain text.

The text is written line by line into the OPTIONS table of the function module. Each line may contain at most 72 characters (SAP limitation). Use line breaks (CHR(10) in Oracle, newline in PostgreSQL) for longer conditions.

SAP Selection Syntax

The selection condition uses SAP Open SQL syntax as required by RFC_READ_TABLE, for example:

DATVR GE '20260301'

Multiple conditions:

DATVR GE '20260301'
AND KSCHL EQ 'Z001'

Comparison operators include EQ, NE, GT, GE, LT, LE, CP, NP, and logical operators AND, OR.

Important: Filter fields do not need to be present in the target table. They only need to exist in the SAP source table.

Fixed Selection Condition (Oracle)

SELECT 'DATVR GE ''20260301''' FROM dual

The SQL string 'DATVR GE ''20260301''' evaluates to the SAP text DATVR GE '20260301'.

Fixed Selection Condition (PostgreSQL)

SELECT 'DATVR GE ''20260301'''

Dynamic Selection Condition

SELECT 'DATVR GE ''' || TO_CHAR(SYSDATE - 7, 'YYYYMMDD') || '''' FROM dual

Multiple SAP Reads

Each result row triggers a separate SAP call:

SELECT 'DATVR GE ''20260101''' FROM dual
UNION ALL
SELECT 'DATVR GE ''20260201''' FROM dual

Schema Variable

If the target connection defines a schema, ${schema} in the action is replaced before execution.

Debug Modes

Special action values can be used to inspect SAP metadata without loading data:

Action Effect
SELECT '1=0' FROM dual Logs the SAP field list (name, type, length, key flag, description)
SELECT '1=3' FROM dual Logs a CREATE TABLE DDL script for the SAP table (useful for creating the target table)

For debug modes, logging level FINE must be enabled.

Attributes

Name Type Default Meaning
Truncate Before Boolean Y Empty the target table before loading (uses TRUNCATE trigger if available, otherwise DELETE)
Delete Before Boolean N Delete rows before loading (only evaluated if Truncate Before is off)
Delete Condition Text WHERE clause for partial delete (only with Delete Before)
Write Size Number 10000 Number of rows per batch when writing to the target database

Statistics

The module reports the following runtime statistics:

Name Meaning
rows_processed Number of rows read from SAP
read_duration SAP read time (µs)
write_duration Database write time (µs)
convert_duration Data conversion time (µs)
delete_duration Delete/truncate time (µs)
row_width Maximum row width returned by SAP (SAP limit is 1000 characters)
java_memory Maximum heap usage (MB)
write_mode 1 = batch insert, 2 = Oracle bulk types
rows_upd_non_increment Retry count on SAP connection errors
module_duration Total module runtime (µs)

On SAP connection errors, the module retries up to four times with increasing wait intervals (5, 30, 60 seconds).

Examples

Load SAP table NAST with date filter

SAP source object:

Field Value
Funktionsbaustein RFC_READ_TABLE
Table NAST

Target table (example):

CREATE TABLE staging.nast (
    mandt   VARCHAR2(3 CHAR) NOT NULL,
    objky   VARCHAR2(50 CHAR),
    kschl   VARCHAR2(4 CHAR),
    datvr   DATE,
    uhrvr   VARCHAR2(6 CHAR)
);

Action:

SELECT 'DATVR GE ''20260301''' FROM dual

Load without filter

Leave the action empty. All accessible rows of the SAP table are read.

Determine available SAP fields

Action:

SELECT '1=0' FROM dual

Inspect the log output for the field list before defining the target table.

Limitations

  • Exactly one SAP source and one database target are supported.
  • At most 9999 fields can be requested per call.
  • Each line in the SAP selection condition is limited to 72 characters.
  • SAP returns a maximum row width of approximately 1000 characters; very wide field selections may require fewer columns or a custom function module.
  • The special table DAUERBELEG_POSTEN does not use automatic field selection.
  • Selection conditions must use valid SAP field names for the configured table.