Importing Data from SAP: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
No edit summary
Line 10: Line 10:
! '''SQL scripting:<br>--#ImportSapQuery'''
! '''SQL scripting:<br>--#ImportSapQuery'''
|-
|-
||I (integer)
||'''I''' (integer)
||long
||long
||INT
||INT
|-
|-
||F (flowing point number)
||'''F''' (flowing point number)
||double
||double
||FLOAT
||FLOAT
|-
|-
||P (fixed point number, packed number)
||'''P''' (fixed point number, packed number)
||double
||double
||FLOAT
||FLOAT
|-
|-
||C (default) (text)
||'''C''' (default) (text)
||string
||string
||NVARCHAR(length) or<br>NVARCHAR(max) if length is greater than 8000
||NVARCHAR(length) or<br>NVARCHAR(max) if length is greater than 8000
|-
|-
||D (date)
||'''D''' (date)
||datetime
||datetime
||DATETIME2
||DATETIME2
|-
|-
||T (time)
||'''T''' (time)
||timespan
||timespan
||TIME
||TIME
|-
|-
||N (numeric text)
||'''N''' (numeric text)
||string
||string
||NVARCHAR(length) or<br>NVARCHAR(max) if length is greater than 8000
||NVARCHAR(length) or<br>NVARCHAR(max) if length is greater than 8000
|-
|-
||X (binary data)
||'''X''' (binary data)
||byte[]
||byte[]
||VARBINARY(length) or<br>VARBINARY(max) if length is greater than 8000
||VARBINARY(length) or<br>VARBINARY(max) if length is greater than 8000

Revision as of 22:48, 9 January 2021

Data can be extracted from SAP using the RFC interface with --#ImportSapQuery command in SQL scripting and ReadSap function in the expression language. In addition to the RFC interface, data can be fetched from SAP HANA with ODBC using the ImportODBCSecure function and ImportOdbcQuery.

Data conversion in RFC interface

Data extracted from SAP using the RFC interface, contains specific data type information, so data can be converted into respective data types used by the in-memory core and SQL Server as follows:

SAP data type Expression language:
ReadSap function
SQL scripting:
--#ImportSapQuery
I (integer) long INT
F (flowing point number) double FLOAT
P (fixed point number, packed number) double FLOAT
C (default) (text) string NVARCHAR(length) or
NVARCHAR(max) if length is greater than 8000
D (date) datetime DATETIME2
T (time) timespan TIME
N (numeric text) string NVARCHAR(length) or
NVARCHAR(max) if length is greater than 8000
X (binary data) byte[] VARBINARY(length) or
VARBINARY(max) if length is greater than 8000

Conversions are determined by the ConvertDataTypes setting for each data type separately. If no conversions are explicitly set, --#ImportSapQuery (in SQL scripting) does not make conversions (to maintain backwards compatibility), and ReadSap (in expression language) makes all possible conversion. When there is no conversion defined, data is converted to strings as defined by the table above.

Date (D) and time (T) type of fields are usually related to the same timestamp and thus they are bound together as follows: If T type of column is defined directly after the the D type of column, the time part in the T column is added to the D column, and no new column is created for the the T column. This is done only if both D and T types are among the converted types.

Note that in the C datatype, spaces from both side are trimmed away.

More information about SAP data types: https://help.sap.com/saphelp_nwpi71/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/content.htm?no_cache=true.