Flat File Interfaces in SAP: Applies To
Flat File Interfaces in SAP: Applies To
Summary
To implement a flat file interface, the following CLIENT standards are applicable:
each interface needs to have an interface identification
data of the interface is stored in a customer table (interface catalogue)
the directory location is stored in a logical file, the logical file name is stored in the customer table
when running the interface, we record the start and end date and time, status in a history table
there are standards for file names, and these are generated automatically by the interface start function
the middleware system does the file transfer based upon the filename
the security/authorization can be determined on the logical file path
Author(s): Aveek Ghose
Company: IBM India
Created on: 20/11/2006
Author Bio
Aveek has 12 years experience in IT and has worked in SAP projects across the Globe..
Aveek has a MS in Information Systems from George Mason University ( USA ) and a MS in
Economics from Virginia Tech in the USA. Currently he is working in IBM India as a
Consultant.
.
Table of Contents
Applies to: ........................................................................................................................................ 1
Summary.......................................................................................................................................... 1
Author Bio ........................................................................................................................................ 1
The use of Flat File Interfaces in the CLIENT environment ............................................................ 3
Interface identification...................................................................................................................... 3
CLIENT Interface Identification table............................................................................................... 4
Logical file name .......................................................................................................................... 4
Physical file path - name .............................................................................................................. 5
Programming standards for file handling......................................................................................... 6
Error handling .................................................................................................................................. 8
Screen Shots of Interface tables and parameters of Function modules: ........................................ 9
Related Content............................................................................................................................. 12
Disclaimer and Liability Notice....................................................................................................... 12
Interface identification
Each batch interface will be uniquely identified by an interface key. The key consists of 3 parameters and
logically describes the source, destination and content of any interface file.
Organizational Unit : This represents the logical business unit within Client that is responsible for the
interface. This could be the CLIENT center, a region, a market or a subsidiary within a market.
Example :
CH11
0000
Client Suisse SA
The external system / partner needs to be stored in customer table /EUR/XEEXTPAR: CLIENT External
Partner Master (see also appendix).
Interface Identifier : This describes the type of message being sent to/from the external partner. It is
effectively a unique name for a CLIENT standard plug-in.
Example :
CSORD01
CSINV01
FICAR01
D-
MMMMM Message content (ORD - Orders, PRDPL - Product P&L, etc). Essentially 5 bytes to
describe the message.
NN Sequence number. This is used to uniquely identify interface programs with similar content.
Example - Both R/3 core and CRM have orders inbound interfaces.
For each interface the 3 parameters above answer the following questions :
Who is the data from?
: Organizational unit
INTID
: Interface identifier
PARNUM
: Partner number
INPUT_FILENAME
PARALLEL_RUNS_ALLOWED
: Parallel runs allowed = 'X', if the flag is set, the last interface run is
not checked to not have status 'in process'.
NORMAL_RUN
: Run mode normal = 'X', if the flag is not set, the function assumes it is a rerun and
it will get validated with the last sequence number and no new entry will be created in the history table
TEST_RUN
NO_SEQ_CHECK
for inbound files
: Test run = 'X': if set, there is not updating of the history table
: No sequence check = 'X', if set, there is no check on the sequence number
NO_HEAD_FOOTER
: No header nor footer, if set, no checks are performed on the header or
footer, and the header and footer are not removed
Exporting parameters:
XEINTID
PHYSICAL_FILENAME
HEADER
Table parameters:
INPUT_FILE
The header records is now filled using the information from /EUR/XEINTID, the date and time is set to the
current date and time. The sequence number is the current sequence number of the last interface added by
1.
We get the physical path using function FILE_GET_NAME using the logical file name stored in table
/EUR/XEINTID. For inbound interfaces, the physical path is concatenated with the file name. For outbound
interfaces, the same is done if the filename is not empty. If the filename INPUT_FILENAME is empty, the
following filename is built:
physical path + XEINTID-BUKRS + '.' + XEINTID-PARNUM '.' + XEINTID-INTID + '.' + new sequence
number + '.DAT'
If it is inbound interface, some additional checks are done:
The file is opened and completely read into table parameter INPUT_FILE.
If the flag NO_HEAD_FOOTER is not set and NORMAL_RUN is set, the header is read and checked: record
type, sequence number, partner number. The footer records is also read and checked: record type is
checked and also the number of records
The header and the footer are removed from the table parameter INPUT_FILE.
If the TEST_RUN parameter is empty, then the history table /EUR/XEINTHIS is updated with the current
date and time if the status is not 'in process', otherwise the time stamp is not changed.
During Inbound interface processing the HEADER and FOOTER are provided in the file.
During Outbound interface processing
The HEADER will be built by function module /EUR/X_INTERFACE_START_PROC, but will still need to be
written into the file by the interface code
The FOOTER record needs to be built and written into the file by the interface code.
/EUR/X_INTERFACE_END_PROC
This function is to be called at the end of the interface processing.
The function has the following importing parameters:
HEADER
STATUS
: Status
RECCT
TRANS
: Number of transactions
ERRCT
TEST_RUN
: Test run
MEMHOLD
'failure': 3
The function updates the specific record using the HEADER record information in the history table
/EUR/XEINTHIS. If the status is not in process, then the current date and time is set, otherwise the time
stamp is not changed.
Error handling
The /EUR/X_INTERFACE_START_PROC function and the /EUR/X_INTERFACE_END_PROC function
return specific exceptions back to the calling program whenever errors for these functions.
The calling program can decide how to handle this exceptions. However, if an entry is already made in the
history table, the purpose is to set the status to 3:failure. If there were no errors, the status should be set to
2: success. This change is done when you call the /EUR/X_INTERFACE_END_PROC function with the
proper import parameters.
If an interface has the status in process and a new interface run is requested with the option
PARALLEL_RUNS_ALLOWED = space, then an the interface start function will return an exception. In this
situation, the entry in the history table with the status in process has to be checked and if there is not
interface running anymore and all reconciliation activities have taken place, the status should be changed in
the table.
It is possible to code (within the interface program itself) sending the output report via SAPMail to designated
users in the case of error. The fields /EUR/XEINTID-BUS_AGENT_TYPE, /EUR/XEINTID-BUS_AGENT,
/EUR/XEINTID-IS_AGENT_TYPE, /EUR/XEINTID-IS_AGENT are used to determine where the output
should be directed. The EDI Orders interface program /EUR/VGTRB_EDI_ORDERS_INT is a good example
of this functionality.
HEADER RECORD
Regardless of the content of the file, the first record of any interface flat file should always be the HEADER
record. It consists of the following fields :
Field
Description
Type
Size
Valueset / Example
RECTYPE
Record type
CHAR
10
'HEADER'
BUKRS
Organizational Unit
CHAR
PARNUM
CHAR
10
e.g.: 'CARAT'
INTID
Interface Identifier
CHAR
12
e.g.: 'CSINV01'
SEQNO
NUMC
12
e.g.: '000000000005'
BEGDA
DATS
YYYYMMDD
BEGTI
TIMS
HHMMSS
Field
Description
Type
Size
Valueset / Example
RECTYPE
Record type
CHAR
10
'FOOTER'
RECORDS
NUMC
12
e.g.: '000000000100'
TRANS
NUMC
12
e.g.: '000000000025'
CHKSUM
NUMC
25
e.g.: '000000000012586'
Related Content
Please include at least three references to SDN documents or web pages