cancel
Showing results for 
Search instead for 
Did you mean: 

file name generation in file adpater

0 Kudos

Hi PI Experts

I am using File adapter at reciever end. My requirement is to generate file name as "x_mmddyyyy_y.csv". Means, I need to include current system date in between x and y. Please suggest how can get this. will variable substitution helps?

Regards

Siva

Accepted Solutions (0)

Answers (8)

Answers (8)

former_member191435
Contributor
0 Kudos

Hi Siva,

If ur using fixedlength then go for variablesubstitution otherwise go for dynamic configuration

Thanks,

Enivas

former_member191435
Contributor
0 Kudos

Hi Siva,

If ur using fixedlength then go for variablesubstitution otherwise go for dynamic configuration

Thanks,

Enivas

Former Member
0 Kudos

hi ,

"x_mmddyyyy_y.csv". Means, I need to include current system date in between x and y

that is very simple by using "Dynamic Configuration" .

1.Constant(X_) + 2.currentDate(Date)+3.concat 4.Concat5.Constant(_Y)6.Conact7.constant(.csv)+dyn.conf(UDF) -> target rootnode

udf:

String DynamicConfig(String a, Container container) throws StreamTransformationException{

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

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

conf.put(key,a);

return "";

}

further info:

http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot

thyanks,

anupam_ghosh2
Active Contributor
0 Kudos

Hi Siva,

You can achieve this using adapter specific message attributes scheme.

Use this UDF in any of the mappings in your scenario (which gets executed during runtime)


public String setFileName(Container container){
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
 
 
final String DATE_FORMAT_NOW = "MMddyyyy"; 
String s; 
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT_NOW); 
java.util.Calendar cal = java.util.Calendar.getInstance(); 
s=sdf.format(cal.getTime()); 
filename="x_"+s+"_y.csv"; 
 
conf.put(key,filename); 
 
 
return " "; 

}

Please ensure you carry out these steps

1. Receiver communication channel has ASMA and file name ticked

2. "fail if ASMA missing" tick this.

3. UDF has no input as variable.

4. in receiver communication channel -> File access parameters-> File name scheme -


> you can leave this blank.

5. Map this UDF to any dummy element or root element of target XML, just to ensure that the UDF executes during runtime.

You cannot test its working during design time. Once you run the scenario file with desired filename will be generated.

Regards

Anupam

Former Member
0 Kudos

u can refer this also:

http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might want to look at the code of this wiki.

http://wiki.sdn.sap.com/wiki/display/Snippets/DynamicfilenameinaFiletoFilepassthroughscenario

Former Member
0 Kudos

Hi.

Read the below blog.

Regards.

Luis

prateek
Active Contributor
0 Kudos

Use Dynamic Configuration and take date from currentDate function. You may search SCN for information about Dynamic Configuration.

Regards,

Prateek Raj Srivastava