There are always questions in the forum about How to stop or do not allow the duplicate files to be processed. In this Blog I would exemplify a way to handle the duplicate files with the RFC functionality.
Approach to the Solution:
1. Create an transparent table in XI to store the filename, date and time of the file processing. This table help us to keep track of the file names, date and time it got processed for our reference.
2. Create an RFC enable function module. This function can either query a filename into the table or insert a filename to the table. It has a import parameter for accepting the filename and an export parameter to respond the called program if the file is a duplicate one.
Function of RFC.
RFC imports the filename and checks if the file name already exist in the transparent table.
i. If there is no entry for the filename which is passed then the filename is added to the table and the export parameter Z_Duplicate is set to N and returned. In the othere case i.e.
ii. If there is a entry in the table for the given filename then the parameter Z_Duplicate is set to Y and returned.
1. Create a transparent table from SE11.
2. Create a RFC enabled function module with the import parameter Z_FILENAME and the export parameter Z_DUPLICATE.
3. Add the following code to the function module.
4. Import the RFC in to XI.
5. Map the filename to the RFC parameter Z_FILENAME.
Note: Retrieve the Filename by enabling the Adapter-Specific Message Attributes in the sender File CC and using the Dynamic Configuration Parameter in the UDF.
6. Send synchronous message to the RFC in the IP.
7. In the switch statement check if the Z_DUPLICATE is Y.
a. If yes transform the file name to the mail content and send a rejection mail.
b. If no then send the IDoc to the R3 system.