Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
rajasekhar_reddy14
Active Contributor
0 Kudos

Recently I worked on one requirement where my customer wants file naming convention should start with 1 and increment by 1 every time(SECnet1.xml,SECnet2.xml………..).I have seen many people posted similar kind of requirement in SCN.

 

I want to share my approach with fellow SCN memebers ,it could help to achieve similar kind of requirement easily.

 

 

To handle this kind of requirements we have different approches

 

 

1) If target file system is NFS then File Receiver adapter have prebuilt feature to add counter value.

   

 

Add Counter

 A new file is created for each document. A counter, which is inserted before the file name    extension, is added to the file name (for example, default002.file).

 

Specify the following for Counter Definition:

  •  Prefix

Specify one or more characters that you want to add before the counter in the file name.

  •  Format

Specify the first counter to be used. It must be a valid integer number. Leading zeros are permitted.

  •  Step

Specify the counter increment.

  • Mode

Specify when the counter is to be added.

If you select After First File, the counter is added when the file name is first used unchanged.

If you select Immediately, the counter is added with the first inbound document

 

Limitations:

1) This feature is not available for transport protocol FTP.

2) After restring JAVA stack or PI system counter value will reset to initial.

By considering above limitations I decided to achieve this requirement with different design

 

Design Approach:

1)Created one function module in ECC  and written logic like below ,BAPI has one request and response parameters and request parameter value to BAPI is ‘PI’ and it returns value as 1 in first call ,next execution it increments by  1 to previous value like someway next execution.. .

 

This logic written in Function module

 

 

2) Perform RFC Lookup to get counter increment value.

 

Refer below blog which explains how to perform RFC look up in PI 7.1

 

SAP PI 7.1 Mapping Enhancements Series: Graphical Support for JDBC and RFC Lookups

 

 

 

3) Write Dynamic configuration UDF to assign file name with counter value.

 

RFC lookup response value is input parameter to udf.

 

 

Select ASMA paramter in File receive channel for File name.

PS:

1)      Instead of RFC lookup we can use JDBC lookup also but you required one table and logic to be implemented in data base end.

2)      The only limitation with this design is if RFC lookup fails with some reason then sequence would miss.

3)     We can achieve this requirement using FileLook up  also.

5 Comments