cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic file name!!

Former Member
0 Kudos

Hi ,

I am using UDF for creating dynamic file name.

My requirement is

i have to create n file for n context of a field A

queue= context


String headerField="";
java.util.Map map;


map = container.getTransformationParameters();

for(int i= 0;i<a.length;i++)
{

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

		String s3 = "http:/" + "/sap.com/xi/XI/System/File";
		DynamicConfigurationKey key1 = DynamicConfigurationKey.create(s3,"FileName");
                                                String newFileName =  a<i>.concat(".txt");

		headerField = conf.put(key1,newFileName); 




result.addValue(headerField);

 }

suppose

A has 3 conetex


 UK
 US
 DK

then 3 files should be created with names

UK.txt,US.txt and DK.txt

but unfortunately

only 1 file is creating that is UK.txt

can anyone tell me is possible to create 3 files...

Accepted Solutions (1)

Accepted Solutions (1)

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

Confirm that your scenario is creating 3 file by executing it without Dynamic Filenaming.

If the configuration is correct then try the Variable Substution rather than using the UDF.

My speculation is that since the mapping happens for all the three files first, when the adapter is creting 3 files it can access only a filename. The 3 files are created with the same name overwritting each other and finally you see only one file. May be you can confirm my speculation by selecting the Mode as Append thus you see a single file with all the 3 file contents. Test this and let us know.

Thanks

SaNv...

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sam,

Follow the belwo link for dynamic file name.

Regards,

Leela

Former Member
0 Kudos

Hi,

you could check if your target field is unbounded and use a splitByValue after your UDF.

Regards

Patrick

Former Member
0 Kudos

hi patric,

thanks for ur reply...but i have checked..with that also

my target node is unbounded and i use splitByValue(each value)

still its creating a single file...

to give u more info abt my scenario...

i am using multi mapping...


source message occurence 1
target message occurence 1..unbounded

so depending upon the content of field A message will be created..

according to the example i have given....

it should created 3 message and thus 3 different file.

please have a look @ my previous thread....

Former Member
0 Kudos

yes santhosh,

u r correct !!!

its creating same file 3 times and records are appending.

but i want 3 different file whit their own record.

i MONI also under dynamic configuration its showing only 1 file......

pls help....

i cant use variable sub.. since target structure input value not coming...

santhosh_kumarv
Active Contributor
0 Kudos

>>yes santhosh,

>>u r correct !!!

Ohh.. Good.. So my speculation is the fact.. May be this should be documented that Dynamic File naming using UDF can't be done for multiple file scenario.

>>i cant use variable sub.. since target structure input value not coming...

From your file extension .txt I assume that you are using contenten conversion..

So you can add a addition node to hold the filename, use it in the variable substution and remove it using the content conversion in the receiver adapter....

Thanks

SaNv...

Former Member
0 Kudos

Hi Santosh,

R u sure enough that we it cant be done usin UDF....???

and r u sure its possible using var sub???

if yes please help me

my target structure has more than 50 field....

suppose i add one field in my target structure..(suppose 1 st field)

what FCC parameter i have to use to exclude this field.. please tell

Former Member
0 Kudos

Hi Sam

yes you cant put multiple values using Dynamic configuration. Only thing that you can do is as you pass one of the name as Dynamic conf key. You can clear the value to pass another. But finally you have only one value as the configuration parameter Filename.

Thanks

Gaurav

santhosh_kumarv
Active Contributor
0 Kudos

>>R u sure enough that we it cant be done using UDF....???

I Believe it can't be....

>>and r u sure its possible using var sub???

Yes.. it can be since you are going to have a same root structure...

>>what FCC parameter i have to use to exclude this field.. please tell

Assuming that your root node is MT_TRG add a element filename to it.

Use the following in the Variable substution.

payload:MT_TRG,1,filename,1

Use this in the FCC to remove the filename

filename.fieldFixedLengths = 0

filename.fixedLengthTooShortHandling = Cut

filename.endSeparator = '0'

Thanks

SaNv...