IMPORT SAP command

Creates an Analytics table by importing data from an SAP system using Direct Link.

Note

The IMPORT SAP command is only supported if Direct Link is installed and configured on your local computer and on your organization's SAP system.

Syntax

IMPORT SAP PASSWORD num TO table_name SAP SOURCE "SAP AGENT" import_details

Parameters

Name Description
PASSWORD num

The password definition to use.

You do not use PASSWORD num to prompt for, or specify, an actual password. The password definition refers to a password previously supplied or set using the PASSWORD command, the SET PASSWORD command, or the PASSWORD analytic tag.

num is the number of the password definition. For example, if two passwords have been previously supplied or set in a script, or when scheduling an analytic, PASSWORD 2 specifies that password #2 is used.

For more information about supplying or setting passwords, see:

Note

The password is used to access the SAP system.

TO table_name

The name of the Analytics table to import the data into.

Note

Table names are limited to 64 alphanumeric characters. The name can include the underscore character ( _ ), but no other special characters, or any spaces. The name cannot start with a number.

SAP SOURCE "SAP AGENT"

Required for importing SAP data. "SAP AGENT" is the only available option.

import_details

The details of the query. Must be enclosed by the <q></q> tags, and uses the tags listed in Direct Link query tags to define the query.

The physical size of this value can be up to 16 KB.

Examples

Performing a multi-table query

This example performs a multi-table query using the IMPORT SAP command.

Correct order and nesting of the tags is necessary to create a valid query string. The tags in the example are ordered and nested correctly. Use this example to determine the required order and nesting of IMPORT SAP query tags.

Note

To assist readability, this example is formatted using multiple lines. In your script, the command and the query string must be entered without any line breaks.

Tip

The syntax of an IMPORT SAP query string is typically complex. The best way to add IMPORT SAP commands with query strings to your scripts is to copy an existing IMPORT SAP command from the Log tab in Analytics, then edit the query tags as necessary.

IMPORT SAP PASSWORD 1 TO Purchasing_doc SAP SOURCE "SAP AGENT"
<q version="6.0">
  <s>0</s>
  <d>IDES</d>
  <u>mzunini</u>
  <c>800</c>
  <lg>en</lg>
  <cf>C:\ACL Data\Purchasing_doc.fil</cf>
  <sf>E:\Data\DL_JSMITH111107.DAT</sf>
  <jcount>11110701</jcount>
  <jname>DL_JSMITH111107.DAT</jname>
  <dl>75</dl>
  <m>2</m>
  <dt>20140321</dt>
  <tm>033000</tm>
  <r>500</r>
  <ar>0</ar>
  <e>500</e>
  <ts>
    <t>
      <n>EKKO</n>
      <a>T00001</a>
      <td>Purchasing Document Header</td>
      <fs>
        <f>EBELN</f>
        <f>BUKRS</f>
        <f>BSTYP</f>
        <f>BSART</f>
        <f>STATU</f>
        <f>WKURS</f>
      </fs>
      <wc>
        <w>
           <f>BUKRS</f>
           <o>0</o>
           <l>1000</l>
           <h></h>
        </w>
      </wc>
    </t>
    <t>
      <n>EKPO</n>
      <a>T00002</a>
      <td>Purchasing Document Item</td>
      <fs>
        <f>EBELP</f>
        <f>WERKS</f>
        <f>MENGE</f>
        <f>BRTWR</f>
      </fs>
      <wc></wc>
    </t>
  </ts>
  <js>
    <jc>
      <pt>
        <pa>T00001</pa>
        <pf>EBELN</pf>
      </pt>
      <ct>
        <ca>T00002</ca>
        <cf>EBELN</cf>
      </ct>
    </jc>
  </js>
</q>

Remarks

The table in Direct Link query tags lists the tags that can be included in the import_details parameter. The Required column uses the following values to indicate when tags must be present:

  • Y Required
  • N Optional
  • M Required for multi-table queries only
  • B Required, but no value should be passed
  • W Optional when filters are used
  • S Required when scheduled mode is specified

Direct Link query tags

Name

Tag

Required

Description

Table Alias

<a>

M

The alias that uniquely identifies the table within the query. This allows the same table to be used more than once.

The maximum length is 6 characters.

All Rows

<ar>

Y

Indicates that all matching rows should be returned as part of the query's result set.

Valid values are:

1 Overrides the number of records specified in the <r> tag (Maximum Rows)

0 Returns the number of records specified in the <r> tag (Maximum Rows)

This tag always appears after the <r></r> tag.

Client

<c>

N

The client within the SAP system.

Child Table Alias

<ca>

M

The alias of the child table.

Child Table Field

<cf>

M

The field in the child table that the join condition is based on.

Client Filename

<cf>

Y

Identifies the target file on the client system where the results of the query will be stored.

Child Table

<ct>

M

The child table in the join condition.

Destination

<d>

N

Identifies a destination in the SAP RFC library file (sapnwrfc.ini) that is used to locate an SAP system.

Data Length

<dl>

B

The number of characters in each row, including carriage return and line feed characters indicating the end of the record (CR+LF, or the hexadecimal characters 0D+0A).

Date <dt> S

Required when using scheduled mode. Specifies the time to run the SAP job.

Must be formatted as YYYYMMDD. For example, December 31, 2014 must be specified as 20141231.

Expected Rows

<e>

B

The expected number of rows the query will return.

Field Name

<f>

Y

The native field name.

Filter Field

<f>

W

The native field name that the filter applies to.

Fields

<fs>

Y

The list of fields in the table that will be returned as part of the query results.

High Value

<h>

W

Contains the high value when using the Between operator. Ignored when using any other operator.

Join Condition

<jc>

M

The join condition.

Job Count

<jcount>

B

Used internally by SAP to identify a Background mode query.

Job Name

<jname>

B

Used internally by SAP to identify a Background mode query.

Join Relationships

<js>

Y

The list of join conditions that link tables within the query.

Join Switch <jw> N

Numeric equivalent of the join switch enumerated type.

Valid values are:

0 Inner Join

1 Left Outer Join

Low Value

<l>

W

Contains either the lowest value when using the Between operator or the value when using any other operator.

Language

<lg>

Y

Language identifier used to determine the locale of fields in the SAP database.

Mode

<m>

Y

Numeric equivalent of the submission mode enumerated type.

Valid values are:

0 Extract Now

1 Background

2 Scheduled

Table Name

<n>

Y

The native table name.

Operator

<o>

W

Numeric equivalent of the operator enumerated type.

Valid values are:

0 Equal to (=)

1 Not equal to (<>)

2 Less than (<)

3 Less than or equal to (<=)

4 Greater than (>)

5 Greater than or equal to (>=)

6 Between

7 Contains

Parent Table Alias

<pa>

M

The alias of the parent table.

Parent Table Field

<pf>

M

The field in the parent table the join condition is based on.

Parent Table

<pt>

M

The parent table in the join condition.

Query

<q>

Y

Encloses a query.

Maximum Rows

<r>

Y

The maximum number of rows the query should return.

Selected

<s>

Y

If the <s> tag appears below the <f> tag, it indicates whether the field will be returned as part of the query's result set.

System

<s>

Y

If the <s> tag appears below the <q> tag, it identifies the type of system this query is used against (currently only SAP is supported).

Server Filename

<sf>

B

Identifies the file on the server that holds the results of a Background mode query.

Server Group Name <sg> N The name of the server group. Maximum 20 characters.
Server Name <sn> N The name of the server. Maximum 20 characters.

Table

<t>

Y

The table.

Table Description

<td>

Y

The table description from the SAP data dictionary. It should always appear below the <a> tag.

Time <tm> S

Required when using scheduled mode. Specifies the time to run the SAP job.

Must be formatted as hhmmss. For example, 2:30 pm must be specified as 143000.

Tables

<ts>

Y

The list of tables from which the query will extract data.

Table Type <tt> Y

The type of SAP table.

Valid values are:

0 clustered

1 transparent

2 pooled

3 view

Username

<u>

N

The user's logon name.

Filter

<w>

W

The filter applied to the table's data.

Filters

<wc>

W

The list of filters that will be applied to the data contained within the table.

Filter Switch <ws> N

Numeric equivalent of the filter switch enumerated type.

Valid values are:

0 (Or) And (Or)

1 (And) Or (And)