cancel
Showing results for 
Search instead for 
Did you mean: 

Rename file in file adapter after processing

Former Member
0 Kudos

Hi All,

My requirement is, i need to rename the file in receiver file adapter after the file is written to the folder. and this file should have a counter attached to its name. For eg. If i had a file created with name Material, i want to change it to Order001, Order002, Order003.... so on and counter should reset after 999. how can i achecive it?

thanks a lot in advance.

Regards,

Rashmi

Edited by: Rashmi H S on Jul 15, 2009 12:15 PM

Accepted Solutions (0)

Answers (4)

Answers (4)

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Rshmi,

use this UDF i hope it will work fine,

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String a=conf.get(key);

int inc = 1;

Integer seqNo = (Integer) container.getParameter("seqNo");

if(seqNo == null || seqNo ==999){

seqNo = new Integer(inc);

}

else{

int num = seqNo.intValue() + inc;

seqNo = new Integer(num);

}

container.setParameter("seqNo", seqNo);

return var1+seqNo.toString();

Regards,

Raj

former_member187339
Active Contributor
0 Kudos

Hi,

One approach could be to use a batch program in receiver folder which will rename the file and reset the counter when it reaches 999.

If you dont want to reset the counter use the counter mode in XI with your file name

Regards

Suraj

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi use Dynamic configuration bean to chnage the file name dynamically..

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String a=conf.get(key);

return a;

Regards,

Raj

former_member185881
Active Participant
0 Kudos

Hi Rashmi

I believe for this you have to use UDF, i dont know how to use this but this will be achieved through UDF.

Regards

Dheeraj Kumar

Former Member
0 Kudos

Hi All,

Thanks for the responses. But i'm not using mapping in my interface.

To give you more info, my scneario is like this. we have two files, Material and item file coming to XI as soap attachments. we are reading Material into one file called Material.txt and later item also will be appended to same file. after that i want to rename Header.txt to Order.txt

any help?

Regards,

Rashmi

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Rashmi,

Add one message mapping ,write one UDF what i have provided to you and map this to root element.

do some smal chnage in UDF append ORDER .

it will work fine.

Regards,

Raj