on 08-23-2016 6:20 AM
Hi All,
Need to config the fill name at runtime from server
for ex: on server there is file i.e ABC.txt nd in output it would be ABC(data till .)
i/p: ABC.txt
o/p: ABC
if anyone know about it then let me know
Thanks in advance.!!
Thanks to all for providing possbile solutions,
I have wrote the UDF for it and in channel in ASMA property i copy the file directory,
used UDF as below,
String SourceFileName = new String("");
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System","FileName");
SourceFileName = conf.get(key);
return SourceFileName;
Thanks,
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ajay,
Please use this java mapping in ESR after all graphical mappings in the same Operation mapping.
package com.javaMapping;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class DynamicFileName_JavaMapping extends AbstractTransformation {
private static final DynamicConfigurationKey KEY_FILENAME =
DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
@Override
public void transform(TransformationInput in, TransformationOutput out)
throws StreamTransformationException {
// TODO Auto-generated method stub
String newFileName = null;
DynamicConfiguration conf = in.getDynamicConfiguration();
String oldFileName = conf.get(KEY_FILENAME);
newFileName = oldFileName.replaceAll(".txt", "");
String inData = convertStreamToString(in.getInputPayload().getInputStream());
String outData = inData;
try {
out.getOutputPayload().getOutputStream().write(outData.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
conf.put(KEY_FILENAME,newFileName);
}
public String convertStreamToString(InputStream in){
StringBuffer sb = new StringBuffer();
try
{
InputStreamReader isr = new InputStreamReader(in);
Reader reader =
new BufferedReader(isr);
int ch;
while((ch = in.read()) > -1) {
sb.append((char)ch);}
reader.close();
}
catch(Exception exception) { }
return sb.toString();
}
}
Please tick on ASMA filename in sender and receiver file adapter.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ajay,
If you are not using ESR objects, you can deploy Eng Swee Yeoh module bean: DynamicAttributeChangeBean - The no-mapping sol... | SCN
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ajay
If you want file name in the receiver file adapter then use dynamic configuration in the mapping if you're u have mapping
Regards
Praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ajay,
Check the first UDF in the following link
To invoke the UDF, do a mapping like this
<source message type or Header Node in Source XML Structure> --- UDF --- <target message type or Header Node in Target XML Structue>
Make sure Dynamic Configuration (Filename) is selected in both source and target channel.
Regards
Suraj
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.