21
1 File Adapter Author: Dennis Kropp

01 File Adapter.unlocked

  • Upload
    hema

  • View
    16

  • Download
    0

Embed Size (px)

DESCRIPTION

SAP PI material

Citation preview

Page 1: 01 File Adapter.unlocked

1

File Adapter Author: Dennis Kropp

Page 2: 01 File Adapter.unlocked

2

© SAP AG 2004, File Adapter, Dennis Kropp, 2

Objectives

After completing this session, you will be able to:

Understand the basics of J2EE file adapterUnderstand how to configure sender & receiver file adapterUse structure conversion with sender file adapterBe familiar with technical aspects of the file adapter

Page 3: 01 File Adapter.unlocked

3

The file adapter is used to read and write files at the OS level. The OS-level directory must be accessible by the service user of the Adapter engine, with the appropriate read/write permissions.

The file adapter can also act as an FTP client, meaning that it can perform GET and PUT in the sender and receiver case, respectively.

© SAP AG 2004, File Adapter, Dennis Kropp, 3

File Adapter

Type File

Exactly one senderagreement per Communicationchannel

At least interface nameand sender servicemust be qualified in thesender agreement

Page 4: 01 File Adapter.unlocked

4

© SAP AG 2004, File Adapter, Dennis Kropp, 4

File Adapter: Sender

Page 5: 01 File Adapter.unlocked

5

© SAP AG 2004, File Adapter, Dennis Kropp, 5

File Adapter: Sender

File System Access Parameters:

Source Directory and Filename

File Type

Text ( e.g for XML files ) ORBinary

Page 6: 01 File Adapter.unlocked

6

When a queue name is specified, it gets created in XI automatically.

© SAP AG 2004, File Adapter, Dennis Kropp, 6

File Adapter: Sender

File Processing Parameters:

Quality of ServiceBest EffortEOEOIO Specify Queue name in this case

Poll Interval

Processing ModeArchive w.timestamp possibleSet to Read onlyDeleteTest

Processing Sequence

Operating system command

Page 7: 01 File Adapter.unlocked

7

© SAP AG 2004, File Adapter, Dennis Kropp, 7

Specifying File content Conversion

Required to convert non-xml file (flat) to XMB (xml) file or Vice-Versa.

Page 8: 01 File Adapter.unlocked

8

The target directory is created if one does not exist.

Message ID is from XI.

Time stamp has a yyyyMMdd-HHmmss-SSS format.

The quality of service is inherited from the Integration Server (in the case of a file, only QoS EO or EOIO makes sense, since the communication cannot be synchronous).

© SAP AG 2004, File Adapter, Dennis Kropp, 8

File Adapter Receiver

File System Access Parameters:Target DirectoryFile Name SchemaFile Construction Mode

CreateAppendAdd TimestampAdd MessageIDAdd Counter

Page 9: 01 File Adapter.unlocked

9

© SAP AG 2004, File Adapter, Dennis Kropp, 9

File Adapter Receiver

Parameters Continued…

File TypeTextBinary

File Encoding

Page 10: 01 File Adapter.unlocked

10

! Note that due to an “issue” within XI structure creation the execution of a mapping program fails with a runtime exception, even if it seems that source structure is ok. This is caused by missing message type prefix (ns) This should be fixed in SP04 (FeaturePack)

© SAP AG 2004, File Adapter, Dennis Kropp, 10

Example1 – csv file conversion - simple structure

The following screens demonstrate the conversion of a csv (flatfile) file into an XML structure that can be used within XI

File adapter channel picks up csv file and create xml structure as configured in channel

after that all XI operations, e.g. mapping are possible with this structure

for more detailed information on structure conversion see XI30 documentation

Page 11: 01 File Adapter.unlocked

11

Represents source structure that has to be converted into XML

© SAP AG 2004, File Adapter, Dennis Kropp, 11

Source structure

Source structure of csv file:

Adams,James,P,ABC Co.,29 Frankford Rd,Bloomington,IL,60525,708,3525555

Miller,Maria,B,Conrad Corp,1234 Smith St,Buffalo Grove,CA,60089,708,3334567

Smith,Fred,A,Sand Inc.,Beach Street,Pismo Beach,FL,33321,407,8123456

Veldin,Beth,M,Any Co.,697 Berry Road,Highland Park,IL,60012,708,4445987

Jones,Mary,,McCormick Enterprises,777 Lincoln Drive,Maryland,CA,19444,415,6666666

Page 12: 01 File Adapter.unlocked

12

Choose „file content conversion“ as message protocol as shown

Document name represents message type, document namespace is XMLnamespace of document

Recordset name creates „root node“ of document that consists of recordsetstructure

Record set structure defines the structure of record set and number of each substructure. E.g. in this example for each record set “ContactFile” ONE structure named “Contact” is created

Field Separator value defines which character (or space) separates the different fields of source

End separator defines end of one “structure” -> nl = newLine

Optional value defines optional fields of structure. E.g. “middle” field is optional in example

© SAP AG 2004, File Adapter, Dennis Kropp, 12

IB Directory – channel configuration

Page 13: 01 File Adapter.unlocked

13

each recordset “Input” contains one substructure “prefix”, multiple substructures “main” and one substructure

“check”

© SAP AG 2004, File Adapter, Dennis Kropp, 13

XML structure after conversion

<?xml version="1.0" encoding="UTF-8"?><MT_ContactFile xmlns="http://sap.com/xi/Performance"><ContactFile>

<Contact><lastName>Adams</lastName><name>James</name><middle>P</middle><company>ABC Co.</company><street>29 Frankford Rd</street><city>Bloomington</city><BL>IL</BL><zip>60525</zip><dept>708</dept><phone>3525555</phone>

</Contact></ContactFile><ContactFile>

<Contact><lastName>Miller</lastName><name>Maria</name><middle>B</middle><company>Conrad Corp</company><street>1234 Smith St</street><city>Buffalo Grove</city><BL>CA</BL><zip>60089</zip><dept>708</dept><phone>3334567</phone>

</Contact></ContactFile>

.....

Page 14: 01 File Adapter.unlocked

14

Record set structure: Contact,*

Now the record set contains all substructures “Contact” in one record set

© SAP AG 2004, File Adapter, Dennis Kropp, 14

XML structure after conversion

<?xml version="1.0" encoding="utf-8"?><MT_ContactFile xmlns="http://sap.com/xi/Performance"><ContactFile>

<Contact><lastName>Adams</lastName><name>James</name><middle>P</middle><company>ABC Co.</company><street>29 Frankford Rd</street><city>Bloomington</city><BL>IL</BL><zip>60525</zip><dept>708</dept><phone>3525555</phone>

</Contact>

<Contact><lastName>Miller</lastName><name>Maria</name><middle>B</middle><company>Conrad Corp</company><street>1234 Smith St</street><city>Buffalo Grove</city><BL>CA</BL><zip>60089</zip><dept>708</dept><phone>3334567</phone>

</Contact>.........

</ContactFile>

Page 15: 01 File Adapter.unlocked

15

! Note that due to an “issue” within XI structure creation the execution

of a mapping program fails with a runtime exception,

even if it seems that source structure is ok. This is caused by missing message type prefix

(ns) This should be fixed in SP04 (FeaturePack)

© SAP AG 2004, File Adapter, Dennis Kropp, 15

Example2 – csv file conversion - advanced structure

following screens demonstrate conversion of a csv (flatfile) fileinto a XML structure that can be used within XI

File adapter channel picks up csv file and create xml structure as configured in channel

Note that you need a sender agreement to send files by file adapter

each file sender channel can only be used in one sender agreement

all XI operations, e.g. mapping, context based routing etc, are possible with this structure

for more detailed information on structure conversion see XI30 documentation

Page 16: 01 File Adapter.unlocked

16

Represents source structure that has to be converted into XML

© SAP AG 2004, File Adapter, Dennis Kropp, 16

Source structure1London20.04.20042DAR 11000000123456,0012345678901111SalesAcc 2WECHS 13000000123456,0012345678901111Collection 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2WECHS 13000000123456,0012345678901111Collection 2KK 20009999999999,9909876543219999DepositMoney 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2WECHS 13000000123456,0012345678901111Collection 2KK 20009999999999,9909876543219999DepositMoney 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2DAR 11000000123456,0012345678901111SalesAcc 2WECHS 13000000123456,0012345678901111Collection 2KK 20009999999999,9909876543219999DepositMoney ………2KK 20009999999999,9909876543219999DepositMoney 300000000001234565432,2200000000001234565432,33

Page 17: 01 File Adapter.unlocked

17

Choose „file content conversion“ as message protocol as shown

Document name represents message type, document namespace is XMLnamespace of document

Recordset name creates „root node“ of document that consists of recordsetstructure

Recordset structure defines the structure of record set and number of each substructure. E.g. in this example for each record set “Input” a (sub-)structure “prefix”, occurs one time ; “main”, occurs unbounded and “ckeck”, occurs one time , will be

created

1 recordset will be send per message

Key field name defines a field in source file that value identifies each substructure

© SAP AG 2004, File Adapter, Dennis Kropp, 17

IB Directory – channel configuration (1)

Page 18: 01 File Adapter.unlocked

18

In this structure, fields with fixed length are used , the value defines the length of each field

FieldNames defines the name of each field in structure

A keyfield is needed to identify the start of a new substructure, here the keyfield is “KZ”

It means if KZ = 1 then the rules for “prefix” were used, if KZ=2 then “main” etc..

keyFieldInStructure defines whether the keyfield occurs in the target structure or not, “ignore” means it does not appear

© SAP AG 2004, File Adapter, Dennis Kropp, 18

IB Directory – channel configuration (2)

Page 19: 01 File Adapter.unlocked

19

© SAP AG 2004, File Adapter, Dennis Kropp, 19

XML structure after conversion<?xml version="1.0" encoding="utf-8"?><MT_Input xmlns="http://sap.com/xi/Mappingtest"><Input>

<prefix><agency>London</agency><date>20.04.2004</date>

</prefix><main>

<product>DAR</product><contract>1100</contract><total>0000123456,00</total><GPnum>1234567890</GPnum><GPnumAdv>1111</GPnumAdv><description>SalesAcc</description>

</main><main>

<product>WECHS</product><contract>1300</contract><total>0000123456,00</total><GPnum>1234567890</GPnum><GPnumAdv>1111</GPnumAdv><description>Collection</description>

</main>………

<check><checkSum1>00000000001234565432,22</checkSum1><checkSum2>00000000001234565432,33</checkSum2>

</check></Input></MT_Input>

Page 20: 01 File Adapter.unlocked

20

each recordset “Input” contains one substructure “prefix”, multiple substructures “main” and one substructure

“check”

<?xml version="1.0" encoding="utf-8"?>

<MT_Input xmlns="http://sap.com/xi/Mappingtest">

<Input>

<prefix>

<agency>London</agency>

<date>20.04.2004</date>

</prefix>

<main>

<product>DAR</product>

<contract>1100</contract>

<total>0000123456,00</total>

<GPnum>1234567890</GPnum>

<GPnumAdv>1111</GPnumAdv>

<description>SalesAcc</description>

</main>

<main>

<product>WECHS</product>

<contract>1300</contract>

<total>0000123456,00</total>

<GPnum>1234567890</GPnum>

<GPnumAdv>1111</GPnumAdv>

<description>Collection</description>

</main>

………

<main>

<product>KK</product>

<contract>2000</contract>

<total>9999999999,99</total>

<GPnum>0987654321</GPnum>

<GPnumAdv>9999</GPnumAdv>

<description>DepositMoney</description>

</main>

<check>

<checkSum1>00000000001234565432,22</checkSum1>

<checkSum2>00000000001234565432,33</checkSum2>

</check>

</Input>

</MT_Input>

Page 21: 01 File Adapter.unlocked

21

© SAP AG 2004, File Adapter, Dennis Kropp, 21

Summary

Now you should be able to:

Understand the basics of J2EE file adapterUnderstand how to configure sender & receiver file adapterUse structure conversion with sender file adatperBe familiar with technical aspects of the file adapter