Exploring the File Adapter

Objective

After completing this lesson, you will be able to use the File Adapter in SAP Application Interface Framework, configure source and destination structures.

File Adapter

With SAP Application Interface Framework, you can import and process files. A file can be uploaded using the report for uploading files. To be able to upload files, the following entities must be in place:

  1. A RAW structure/DDIC structure matching the structure of the file: Create a DDIC structure representing the structure of the file. The structure must contain a structure matching the fields of the file. If the file contains a table of entries, the DDIC structure must contain a table with the structure containing the fields of the file as line type. This structure is used as the raw structure in the SAP Application Interface Framework interface.
  2. An SAP structure defined by the processing functions in the system: Create or reuse an SAP structure. The subsequent processing within the SAP Application Interface Framework determines the creation or reuse of an SAP structure.
  3. An SAP Application Interface Framework interface: Set interface engines. The Application and Persistence Engines are set to XML. The Selection Engine is set to Index Tables, and the Logging Engine uses the Application Log.
  4. Define structure mappings and actions: Map the RAW to the SAP structure, trigger the follow-up process structure, and trigger the follow-up process.
  5. A file adapter configuration: Create the file adapter configuration. There are no default settings for uploading a file. To read a file from the system, the minimum information required is the file type, file content, and text type. To map the file to the interface, the structure name and the field name, where the file content is moved to during the upload, is required.

The imported file results in one or more SAP Application Interface Frameworks messages. The mapping of the file content to one or multiple SAP Application Interface Framework messages relies on the file adapter configuration, interface/structure settings, and upload parameters.

Source Structure

Every SAP Application Interface Framework interface requires source and destination DDIC structures. A file does not have a corresponding DDIC structure. How do you create this structure?

Steps to Create the Source Structure

1. Check the File and the Content

In which form is the data contained in the file? Does the file contain a data table or only a single record? How long are the different fields? In which form is the data contained in the file? Does the file contain a data table or only a single record? How long are the different fields?

2. Create a Corresponding DDIC Structure

If the file contains a data table, the DDIC structure requires a table to store the different entries from the file. The line type is defined by the different fields of the file.

Depending on the raw structure used, SAP Application Interface Framework creates one or multiple messages. If the file contains a data table and the raw structure resamples the table with a corresponding table type, SAP Application Interface Framework only creates one message per file. If the raw structure is a structure that resamples one line of the file, it creates a new message for every line in the selected file.

Example

The file contains a table with IDs, names, and cities. The ID is six characters long. The name can be 30 characters long, and the city can be 60 characters long. In this case, the source structure must contain a table containing the different entries. The table is defined by the different fields of the file.

The line type is a structure with the following fields: ID Char 6, Name Char 30, and City Char 60. This structure is used as a line type for the table. The table is then included into the source structure.

Visual steps to create the source structure, with the details from the example.

How to Create a RAW Structure for the File Adapter

Watch this demonstration for a step-by-step guide on preparing for the file adapter scenario. It covers creating a CSV file, populating it with specific data entries, and setting up raw, table type, and root structures for efficient data processing within the system.

Destination Structure

To determine the correct destination structure, you must have a look at the functions processing the file in the SAP system. To come to a correct destination structure, the processing functions/BAPIs have to be analyzed. The destination structure must contain the tables/structures that the follow-up processing requires.

The destination structure must contain tables/structures that are required in the follow-up processing of the message.

  1. Identify the required parameters to define the correct destination structure.
  2. Create a corresponding DDIC structure. Add all required structures/tables that are used as parameters in the processing functions/BAPIs, to the destination structure.
  3. Add all required structures/tables that are used as parameters in the processing functions/BAPIs, to the destination structure.

Example

BAPI 1 for processing customers requires a table with the customer information. BAPI 2 requires a table with the city information.

Both parameters, the customer table and the city table, must be part of the destination structure. In this example, the destination structure must contain a table for the customers. The line type is defined by the data type of the processing function/BAPI parameter. In addition to the customer table, it must contain a second table for the cities. Again, the line type is defined by the data type of the processing function/BAPI parameter.

Visual steps to create the destination structure, with the details from the example.

How to Create an SAP Structure for a SAP Application Interface Structure Interface

Watch this demo to use the 'BAPI_MATERIAL_SAVEDATA' function for processing material data and creating a new SAP structure with material descriptions and a table of materials.

Options for File Upload

There are two different reports to upload files in the SAP Application Interface Framework:

  1. File Upload: This transaction allows you to upload single files from either the application server or from a local PC. It's targeted at users that must upload files manually. The report provides the option to display the file after upload so that the user can have a look at its content. Furthermore, if you have a flat structure, you can display the result structure before the data is transferred to the SAP Application Interface Framework. This way, you can see how the data was mapped from the file to the structure specified in the file adapter configuration.

    Transaction: /AIF/LFA_UPLOAD_FILE

  2. Mass File Upload from Server: This transaction allows you to upload multiple files from the application server. The report can be scheduled as a regular job to read data from a predefined path and pass it to the SAP Application Interface Framework. Once a file has been read, it's moved to a new folder on the application server to avoid having the same files read again. This folder can also be specified.

    Transaction: /AIF/LFA_CHECK_SEND

Depiction of file upload options, both single and mass as described in the text.

File Adapter Configuration

To upload a file, you must specify:

  • The file adapter configuration, a directory, or logical file from where the file is uploaded.
  • A block size in lines.
  • A runtime configuration group.

File Adapter Configuration:

The file adapter configuration defines which settings are used for uploading files to the SAP Application Interface Framework. For example, it defines the file type and the structure the uploaded file is moved to.

Block Size in Lines:

If your file contains multiple data sets, you can specify how many lines are passed to one message. If you do not specify a block size, the entire file content is sent as one message.

Example: You have a file with 1,000 data sets.

  • You do not maintain a block size: All data sets are passed at once to SAP Application Interface Framework, which results in one single message in SAP Application Interface Framework.
  • You maintain a block size of 100: 100 data sets are passed to the SAP Application Interface Framework, and a message is created for those 100 data sets. Afterward, the next 100 data sets are passed to the SAP Application Interface Framework. This results in 10 messages that are processed in the SAP Application Interface Framework, each message containing 100 data sets.

Note: A block size can only be maintained if you have a flat structure. In a complex structure, the complete file has to be transferred at once.

If your file has multiple data sets but your structure can only handle one at a time, the file upload defaults to an implicit block size of one. In that case, each data set results in one message.

Runtime Configuration Group:

As the XML runtime of SAP Application Interface Framework is used to process the data sets, a runtime configuration group can be specified. This allows you to define if the messages are processed in the same session or if background jobs are created. Furthermore, this defines how many messages are processed within one run or package.

File Adapter Configuration:

After the structures and the SAP Application Interface Framework interface have been defined, the last Customizing step needed to import files into SAP Application Interface Framework is the configuration of the file adapter. There are no default settings for uploading a file. To upload a file, the minimum information required is the file type, file content, and text type. To map the file content to the interface, you must specify the structure name and field name where the file content will be transferred during the upload process.

  1. File Type: Defines whether the file should be read in binary mode or in text mode.
  2. File Content: Defines what the content of the file looks like. Depending on the selection done in the File Content field, different fields are displayed in the Customizing of the field adapter configuration. These are the following file content types:
    • Flat Structure.
    • Complex Structure: The file content can be mapped into a complex structure, which may contain header, substructures, and sub tables. In this case, you have to maintain a substructure determination in Customizing for the SAP Application Interface Framework under Configure File Adapter.
    • User-defined: Customer-specific mapping can be done using a customer-specific function module, the name of which has to be stored in the Mapping Function field.
    • XML: Mapping is done via Extensible Stylesheet Language Transformation (XSLT) or Simple Transformation (ST). The transformation name must be stored in the Transformation field.
  3. Text Type: Defines where the file content should be separated into individual fields during the file upload. The following options are possible:
    • Special Character as Separator: The individual fields are separated by a special character in the file (for example, if there are CSV files). The separator must be maintained in the Field Separator field.
    • Fixed Field Lengths: The length of the individual fields is correctly represented in the file and no special field separator is used.
    • One Field per Line: Each field has exactly one line in the file.
  4. Structure Name: Name of the raw structure used in the SAP Application Interface Framework interface.
  5. Field Name: Defines the component of the structure, maintained in the Structure Name field, to where the file content is moved during upload. This component can also be a table type. In this case, the line type of this table type has to fit to the data that you upload with the file.
File Adapter Configuration showing the file type, content, text type, structure, and field name.

How to Create SAP Application Interface Framework Interface, Utilize Mapping Features, and Implement BAPI Actions

Watch this demo to discover the step-by-step process of creating an interface in SAP Application Interface Framework, leveraging advanced mapping features and implementing BAPI actions for enhanced data integration efficacy.

Log in to track your progress & complete quizzes