Configuring the Receiver File Adapter

Objective

After completing this lesson, you will be able to configure the receiver File/FTP adapter

File Adapter Architecture

Many external or legacy systems cannot exchange data using HTTP, but they might be able to exchange files using file interfaces or FTP.

The file/FTP adapter is part of the AAE. The receiver adapter receives messages from SAP Process Integration (PI) message processing and saves them as a file in a directory or sends them to a server using FTP. The sender adapter reads messages from the file system (or from an FTP server), converting them to the SAP PI XML format and transferring them to SAP PI message processing. The file can be in text format or in XML format.

To enable message exchange with the business system, the file adapter and the business system must be able to access the same directory (in the case of the file system transport protocol).

File Structure in the ESR

You define the data structure of the inbound interface using data types in the Enterprise Services Repository (ESR).

The exact structure of the objects in the ESR depends on the interface. In the case of XML files, the inbound interface determines not only the message structure, but also the field names (by using XML tags).

Hint

The name of the data type does not appear in the target file. The message type determines the name of the root element and all other names are assigned using the names in the data type definition.

Receiver File/FTP Adapter Configuration

The receiver file/FTP adapter is part of an AAE and you configure it using a communication channel in the ID.

Hint

Because the data structure, possibly the names you want to use, or the file and the directory can differ for each inbound interface, you should configure a separate communication channel for each interface.

The configured communication channel is referenced in an outbound processing of the integrated configuration, which represents the connection between the interface and the receiver system.

When you create a communication channel for the receiver system (business system or component), choose File from the input help as the adapter type and specify Receiver as the type.

Parameters Tab Page

On the Parameters tab page, you can choose between the following values:

Options on the Parameters Tab Page

Field NameValue
Transport ProtocolNFS or FTP
Message ProtocolFile or File Content Conversion
Adapter EngineCentral or Non-Central

Parameters to be Specified for the Transfer File

After choosing the values on the Parameters tab page, you then specify the following parameters for the transfer file:

File name schema
Name of the file (for additional parameters).
File construction mode
Create file, append to existing file, or specify additional parameters for the file.
File type
Binary or text file (in the case of a text file, also specify the file encoding as a code page).
Operating system command
To be executed before or after successful processing (you can use placeholders for the file name).

When the operating system command is called, the file name currently being processed can be specified with the %f (file name) and %F (absolute file name including path) placeholders.

If you are creating a new file, specify whether any existing file is to be overwritten. Alternatively, you can add a parameter, such as the message ID, a time stamp, or a consecutive counter to the file name (there are additional parameters for the counter).

These specifications are independent of whether you have selected FTP or the Network File System (NFS).

If you specify NFS as the transport protocol, the only other specification you need to make is the target directory in which the file is to be generated.

The file/FTP adapter expects directories in the configuration parameters to be in a format usual in Java programs. Therefore, you need to enter paths in the form D:/path, even if you are using the Microsoft Windows operating system.

Plain Text File Format Through Message Protocol File Content Conversion

If you have selected Message Protocol-File content conversion, you can convert an XML-compatible table into plain text format. The expected XML structure contains the structure as nodes filled with any number of elements without additional subnodes.

For example, you have an XML document with the following structure at runtime, and want to save it as a plain text file.

Example of a Simple XML Structure

Code Snippet
12345678910
<ns:DemoMsgType1 xmlns:ns="urn:educationsap.com/bit/demo"> <Struc1> <field1>value1</field1> <field2>value2</field2> </Struc1> <Struc1> <field1>value3</field1> <field2>value4</field2> </Struc1> </ns:DemoMsgType1>

The expected structure (Struc1) with elements (field1, field2, and so on) is referred to as an XML-compatible table. This structure corresponds to a line type in the target file and cannot contain any further subnodes. The Struc1 structure can, however, be contained in another structure, SuperStrucA.

Example of a Hierarchical XML Structure

Code Snippet
12345678
<ns:DemoMsgTypeSuper xmlns:ns="urn:educationsap.com/bit/demo"> <SuperStrucA> <Struc1> <field1>value1</field1> <field2>value2</field2> </Struc1> </SuperStrucA> </ns:DemoMsgTypeSuper>

However, you do not have to take into account this higher hierarchy level of SuperStrucA in the configuration and the general file does not reflect this.

Design Time

Create a message type that references a complex data type in the ESR.

Simple Message Type demonsgtype1

NameCategoryTypeOccurrence
DemoMsgType1N/ADT_Demo1N/A
–Struc1ElementDT_Simple11...unbounded
–––field1Elementxsd:string1
–––field2Elementxsd:string1

The simple data type DT_Simple1 has two fields. It is referenced by a data type DT_Demo1, which is then referenced in message type DemoMsgType1.

Configuration Time

To ensure that the fields of the structure are separate from one another each time when structure Struc1 occurs, you must first list the Struc1 structure in the recordset structure in the communication channel and then specify the fieldSeparator parameter in the Struc1.fieldSeparator form. This is the parameter for the character that is to be inserted between the fields.

Content Conversion Parameters

NameValue
Struc1.fieldSeparator,
Recordset Structure:Struc1, Struc2

Hint

If you want a parameter, for example, .fieldSeparator to be initial (that is, without content), specify the value '0' (including the quotation marks).

Result for a Simple XML Structure

Code Snippet
123
value1, value2 value3, value4 ...

Different Structures

If several different structures appear in the XML document, you must define each structure as a recordset and configure it so that it is possible to generate a plain text file with lines using these structures.

For example, you have an XML document with the following structure at runtime and want to save it as a plain text file.

Example for Multiple Structures

Code Snippet
1234567891011
<ns:DemoMsgType2 xmlns:ns="urn:educationsap.com/bit/demo"> <Struc1> <field1>value1</field1> <field2>value2</field2> </Struc1> <Struc2> <fieldA>value3</fieldA> <fieldB>value4</fieldB> <fieldC>value5</fieldC> </Struc2> </ns:DemoMsgType2>

Hint

There are two different structures, Struc1 and Struc2. The following statements also apply if there are more structures, Struc3, Struc4, and so on.

Design Time for Two Complex Data Types

Create a message type that references the two complex data types in the ESR.

Complex Message Type demomsgtype2

NameCategoryTypeOccurrence
DemoMsgType2N/ADT_Demo2N/A
– Struc1ElementDT_Simple11...unbounded
–– field1Elementxsd:string1
–– field2Elementxsd:string1
– Struc2ElementDT_Simple21...unbounded
–– fieldAElementxsd:string1
–– fieldBElementxsd:string1
–– fieldCElementxsd:string1

There is a complex data type DT_Demo2 that references the simple data type DT_Simple1, which has two fields, and DT_Simple2, which has three fields.

Configuration Time – Two Structures

List both structures, that is, Struc1 and Struc2 as recordset structures and configure them.

Content Conversion Parameters

NameValue
Recordset Structure: Struc1, Struc2
Struc1.fieldSeparator,
Struc2.fieldSeparator:

Result for Multiple Structures

Code Snippet
12
value1, value2 value3 : value4 : value5

Configure the File/FTP Adapter for a Sequential File

Business Scenario

You want to generate a file in sequential format (without XML tags).

Configure the receiver file/FTP adapter for a sequential file.

Note

This exercise requires you to use the business system, BS_BIT500_##_B that you created in the exercise Create a Business System in the System Landscape Directory.

Exercise Information

Note

In this exercise, when the values include ##, replace the character with a two-digit number (01–30).

Exercise Options

You can perform this exercise in two ways:

  1. Live Environment: choose Start Exercise, and from the entry page choose Open PDF Document. Follow the steps described in this pdf in your own system landscape.
  2. Simulation: choose Start Exercise, and from the entry page choose Start Tutorial. Watch the step-by-step instructions within the simulation.

Note

We recommend running the simulation first.

Task 1: Configure the File/FTP Adapter for a Sequential File

Steps

  1. Open NWDS 7.5 and open SAP Process Integration Designer Perspective. Log on with your user ID and password if required.

  2. Create a communication channel File_Receiver_##_B_seq for your business system BS_BIT500_##_B. You want this communication channel to generate a sequential file in directory /usr/sap/trans/tmp/group##.

    1. Choose FileNewChannel.

    2. Enter the following data:

      FieldEntry
      Communication ChannelFile_Receiver_##_B_seq
      Communication ComponentBS_BIT500_##_B
    3. Choose the Finish button.

    4. On the File_Receiver_##_B_seq screen, maintain the following data on the General tab:

      Field NameEntry

      Direction

      Receiver

      Adapter Type

      File (SAP BASIS 7.50)

      Transport Protocol

      File System (NFS)

      Message Protocol

      File Content Conversion

    5. Switch to the Adapter-Specific tab.

    6. On the Target tab page, enter the following data:

      Field NameEntry
      Target Directory/usr/sap/trans/tmp/group##
      File Name Schemaxi_output.txt
    7. On the Processing tab page, enter the following data:

      Field NameEntry
      File Construction ModeAdd Counter
      File TypeText
      PrefixN/A
      Format00000
      Step1
      ModeImmediately
    8. On the Content Conversion tab page, enter Material, Description in the Recordset Structure field.

    9. Choose the 2x Add button.

    10. Enter the following data:

      NameValue
      Material.fieldSeparator;
      Description.fieldSeparator,
    11. Save and activate the communication channel.

  3. Change your iFlow called iFlow_MaterialA_MaterialsB_## so that the File_Receiver_##_B_seq is used as a receiver communication channel instead of the File_Receiver_##_B.

    1. Double-click your iFlow called iFlow_MaterialA_MaterialsB_## to open it.

    2. Click the line which points to your Receiver BS_BIT500_##_B, until the color changes to orange.

    3. Right-click and choose Assign Referenced Channel.

    4. Select the File_Receiver_##_B_seq channel and choose OK.

    5. Save, activate, and deploy your iFlow.

  4. Open the SOAP client form, specify the parameters including the payload, and send a message.

    1. In the browser address bar, enter http://nwktdc00.wdf.sap.corp:50000/dir

    2. On the Additional Information area, choose SOAP Client.

    3. On the SOAP Client form web page, choose Guess to expand the URL to include the host and HTTP port of the central Adapter Engine, on which you set up your SOAP sender adapter.

    4. Specify the necessary entries as the URL suffix for your communication channel:

      channel=:BS_BIT500_##_A:SOAP_Sender_##(Replace ## with your group number)

    5. Generate the contents by choosing Guess in the payload section. Customize the contents as required.

      <ns:MT_Material xmlns:ns="http://education.sap.com/sca##"> (Replace ## with your group number)

    6. Choose Send.

  5. Check the Message Monitor in the Configuration and Monitoring Home.

    1. Navigate to http://nwktdc00.wdf.sap.corp:50000/dir and choose Configuration and Monitoring Home. Alternatively, go to http://nwktdc00.wdf.sap.corp:50000/pimon.

    2. Go to MonitoringAdapter EngineMessage MonitorPI Messages and check the Message List.

    3. Your message should be delivered; select it and check the Message Log tab to understand how the message got process.

  6. Display the file created in your directory.

    1. On your PI tools page, http://nwktdc00.wdf.sap.corp:50000/dir, click on the How to open share for file adapter files.

    2. Follow the instructions to connect to the Y: drive.

    3. In theFile Download-Security Warning dialog box, choose the Open button.

    4. In the Internet Explorer-Security Warning dialog box, choose the Run button. This opens the tmp directory.

    5. In the tmp directory, choose the folder for your group.

    6. In the group-folder, open the text file and check the result. Your file should no longer be XML.

Log in to track your progress & complete quizzes