More than two years back I wrote a blog, PI/XI: Maintaining Sequence Numbers in File Name scheme? talking about drawbacks of the existing counter functionality in the File adapter and about the workarounds. Today we are still stuck with those workarounds and the majority of times, depend upon lookups to help us with this requirement.
Recently there was a blog by Raja Sekhar Reddy titled How to maintain counter sequence to file name in Receiver File(FTP/NFS) scenarios which talks about building an incremental logic in ECC and exposing it as a RFC and calling it in PI to retrieve the counter value. I am sure many of us use this work around. But I believe that we should utilize standard functionalities as much as possible.
SAP provides a standard out of the box functionality called Number Ranges that can be used for our purpose. In this blog, I will talk about setting up a number range object in PI itself and retrieving the incremental counter by writing a simple wrapper around a standard FM made available to us.
Setting up a Number Range Object:
Login to the ABAP stack of PI and go to the transaction SNRO. Provide the name of the object and create.
Provide the Number Length Domain and a % for the warning.
The you can set the interval i.e the Start and End of your expected Counter/Sequence.
Creating a wrapper for the FM:
Once your number range and the intervals are setup, you can now use this as input to a standard FM available i.e NUMBER_GET_NEXT. The FM will retrive you the counter/sequence value as per the setup of the number range object that was defined by you.
A screenshot of the test execution is shown as below;
Unfortunately this FM is not RFC enabled and hence we will not be able to use it directly in our RFC Lookup. Hence either you can make a copy of the FM and adjust the code or you can write a simple Wrapper and expose it as a RFC enable FM for your lookup.
I have used the option of a wrapper and created a RFC ‘Z_NUMBER_GET_NEXT’.
You can now import this RFC into ESR and use it in your lookup. Use the output in combination with ASMA and Dynamic configuration to create the output file name.
More about Number ranges – Click here
I still believe that SAP should work towards providing a standard feature within the File adapter to provide a flexible solution for us to set counter values. Having additional lookups is an overload on the performance and are also error prone i.e a looup failure potentially results in the mapping failure. Hence in case you believe that we should have a standard feature available, Vote for this IDEA today.