cancel
Showing results for 
Search instead for 
Did you mean: 

Sequence number/counter in File name using FTP

former_member203627
Participant
0 Kudos

Hi

I have to add sequence number in the file name. How can i do that? everytime file generates it should pick up the latest file number.

Example File1 File2 File3. 1,2 and 3 are the sequnce number.

Regards

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hey

If you want counters in FTP then you need to store all the filenames in some ABAP table and then do a RFC look up in message mapping and assign the highest+1 number to the top node of receiver file structure,then in receiver file adapter use variable substitution/dynamic configuration and name the file with this number.

On a second note,why not use "Add message ID" option,it will not generate a counter but will uniquely identify the file(if thats what you want).

Thanx

Aamir

bhavesh_kantilal
Active Contributor
0 Kudos

use option add counter in the receiver file adapter's write mode.

Use help.sap or sdn search for such questions.

Regards,

Bhavesh

former_member203627
Participant
0 Kudos

Hi Bhavesh,

I couldn't find the answer in help thats why i posted in here.

This is option is only applicable for NFS not for FTP (From Help A new file is created for each document. The file name is extended with a counter, which is inserted before the file name extension (for example, default002.file). This selection is only available for the File System (NFS) transport protocol.)

Regards

bhavesh_kantilal
Active Contributor
0 Kudos

ha, you are right and you got me there.With FTP adapter this is not possible.

Unless you want to write a custom class that stores and increments this counter and then sets the filename dynamically using the dynamic configuration you would need to use some other option on the ftp adapter.

Regards,

Bhavesh

Former Member
0 Kudos

Hi ria,

You can do this by dynamic file creation. Use this following code and cretate an UDF. The map the required file format to the target header structure as below;

UDF

sequence number:

IDENTIFIER is the parameter

Import com.bp.xi.util.*;

Code:

return ServiceUtil.getSequenceValue( IDENTIFIER, container, false );

Dynamic file:

Key & Value is the parameter

Code:

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get( StreamTransformationConstants.DYNAMIC_CONFIGURATION );

DynamicConfigurationKey confkey = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", Key );

conf.put( confkey, Value );

return "";

Input parameter "Key" is given a constant value"FileName"

Second parameter "Value" is the file pattern

Mapping

Constant(File)concat function sequence numberUDF ==> Dynami File udf ==>target header record.

In the receiver communication channel check the adapter specific function, filename

points if useful

regards,

Murugavel