Show TOC

FileLocate this document in the navigation structure

Use

The node Read Data from File enables you to use data from a file in an analysis process.

Features

The file can either be found on an application server or on the presentation server. Only data from the application server can be used in background processing. Für größere Datenmengen sollten Sie deshalb den Applikationsserver nutzen.

The file can be available in csv or xls format.

File in CSV Format

The technical name of the InfoObject has to be in the first line of the file, for example, 0BPARTNER for the business partner. The data is in the following lines. The values are separated from one another with semicolons (;). Each line in the file becomes a data record. The data are transferred with ABAP MOVE logic into type-related fields. The data is expected in internal data format.

Example

Internal date format for displaying date: YYYYMMDD

Example: 02. January 2004 = 20040102

Internal date format for numeric entries: leading zeros are added until the field length is filled.

Example for an eight digit field: 1234 = 00001234 1234 = 00001234

If you require several columns with the same InfoObject, you can add a field name prefix when specifying the InfoObejct: <field name>:<InfoObject>. Separate the field name from the name of the InfoObject with a colon (:).

Example

You want to read a file that contains the answers of a questionnaire in each line. The first line of the file can contain the following information:

0BPARTNER ; ANSWER1:0WS_ANSWER ; ANSWER2:0WS_ANSWER ; ANSWER3:0WS_ANSWER

File in XLS Format

Specify the data to be read in. To do this, enter the worksheet as well as the file name and the data area. The Excel columns (for example A, B, C) are used as field names in the analysis process. In the first rows to be read in, column headers are expected. If the data area contains just one row, the column names (A, B, C etc.) are used as column headers.

The data format of the various columns is recognized automatically, with a distinction made between the categories Date, Time, Numeric and String. The data format of the second row in the data range is decisive. This is the first row with the actual values. The system expects the rest of each column to correspond to the same data format category. This means for example that varying data formats are allowed in a column (27.01.1983 and 1983 January 27 for example). Switching from a date to a string can cause exceptions though if the content of the cell cannot be interpreted as a date. This does not apply to columns with category String. Switching date formats does not pose a problem for these.

While loading the data, the system uses your PC's clipboard. You should therefore avoid using the clipboard functions at this time, especially the copy function. After loading, the content of the clipboard is deleted.

If a column in the worksheet is defined as "Hidden", it is ignored during loading.

Reading the Data

  • String: The cell content is always read as displayed (region-specific) in the Excel application. Internal ABAP Type: CHAR255.

  • Date: The date is standardized. The value entered is therefore loaded instead of the displayed formated cell content. If for example value "27.01.1983" has been entered, but the formatting excludes the day, it will be displayed as just "01.1983". The complete value "27.01.1983" will be loaded however. If the cell is empty, the initial date is transferred. Internal ABAP Type: DATS8.

  • Time: The time is also standardized, meaning that the entered value is loaded rather than the displayed formatted value (see Date). If the cell is empty, "00:00:00" is transferred. Internal ABAP Type: TIMS6.

  • Numeric: The number is standardized, meaning that the entered value is loaded rather than the displayed cell content. This means in particular that all decimal places entered are included. If the cell is formatted as "Percentage", the value entered is divided by 100. "4 %" is carried over as "0,04" for example. If the cell is empty, "0" is transferred. Internal ABAP Type: DECFLOAT34.

Cell Formatting

If the column is formatted as Standard, the content of the first cell is used for division into categories. The system then only distinguishes between String and Numeric.

The following is a list of the criteria by which a column is assigned to a category using the cell formatting. These criteria are applied in cascading form, meaning that the next criterion is only applied if the previous one was not met. If the formatting meets the criteria for Date and Time for example, the column is interpreted as a date.

  • String: The formatting does contains formatting symbols not reserved by Excel. These are flagged in the formatting for a cell with ' \ ' or ' " '. Not only user-specific formatting contains these symbols. The Chinese date formatting integrated in Excel contains Chinese symbols as strings for example. In this example the column is therefore interpreted as a string. Example: ' "I am" 0 "years old" '

  • Date: The formatting contains the formatting symbols for Year, Month and/or Day reserved by Excel. If the formatting only contains the formatting symbol for Month, the column is interpreted as a string. Example: ' YYYY.MM.DD '

  • Time: The formatting contains the formatting symbols for Hour, Minute and/or Second reserved by Excel. If the formatting only contains the formatting symbol for Minute, the column is interpreted as a string. Example: ' HH:MM:SS '

  • Numeric: The formatting contains the formatting symbols for Currency, Fraction, Percentage and/or exponential display reserved by Excel. Examples: ' [$$-1009]#.##0,00 ', ' # ?/? ', ' 0,00% ', ' 0,00E+00 '

If the formatting does not meet any of the criteria, the column is interpreted as a string in the standard setting.

Entering InfoObjects

To format a column using an InfoObject, enter the name of the InfoObject after the column name in the first row. These must be separated by the separator specified under Data Properties, <Field Name>:<InfoObject> for example. If no field name is specified, the InfoObject's long text is taken as the field name. If the InfoObject does not exist, the separator is ignored and seen as part of the field name.

You then have to make sure that the data type in the Excel column is compatible with the InfoObject data type (see Cell Formatting).

Entering an InfoObject has no effect on how the data is saved internally. Instead, it serves to propagate a data type for transformation operations (joins for example). The data from the worksheet is saved with the greatest possible precision (see Reading the Data). If you define a join to numeric fields for example and forward the result, the target objects still receive the data with floating commas with the greatest possible precision, regardless of the InfoObject entered.

Example

You load data from a worksheet and want to create a join with an InfoProvider. The InfoProvider contains the Customer Number (0D_CUSTOMER). The worksheet contains a column with the MyCustomers field name. The MyCustomers is normally saved as CHAR255. 0D_CUSTOMER is of type CHAR10, meaning that a join in the APD is not possible. If you now add ':0D_CUSTOMER' to the MyCustomers field name, a join is possible.

Example

A CSV file should contain the following data:

Business Partner

Revenue

Currency

1000

1200

EUR

1002

1500

EUR

1080

1100

EUR

The file in csv format must also have the following content:

0BPARTNER;0REVENUE;0CURRENCY

1000;1200;EUR

1002;1500;EUR

1080;1100;EUR