on 05-14-2013 11:12 AM
Hi Frndz,
I have scenario where i am getting Flat file from source system.I need to read the file and process to target directory.
No IR is in place.(Just pick and drop)
I need to modify file name as ccyymmddhhmmss format and ignore the actual file name.
How we can achieve this using reciver file channel.??
Regards,
Naren
Hi Naren,
If you are PI system is unix/linux system then you can use the below OS command in your receiver file adapter in Run Operating System Command After message processing. It will replace your file name to the current time stamp.
mv %f `date +'%Y%m%d%H%M%S'` or mv %F `date +'%Y%m%d%H%M%S'`
Regards,
Stephen Rouvier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IMO, if you generate all the filenames with timestamp, it is possible that some files could be generated with same timestamp period. To avoid duplicates, we use filename + timestamp. I know that your timestamp format is different from the standard file adapter option Add timestamp yyyyMMdd-HHmmss-SSS. If you are flexible to use the above use this with some prefix and later using OS script you can remove the prefix. You don't use ESR for this scenario. So might need to go with OS level script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Frnds,
Still i am stuck up with the issue....now i am creating IR objects and thinking to go with dynamic configuration
now i have created IR objects:
Created DT with one Field considering each line as string and given max lenght is 500.i confirmed from the business that max lenght will be 300.
Here Configured CC with Content conversion and channel is picking perfectly.When it comes mapping it is throwing Empty data to target structure.
it is one to one mapping still facing the problem.Please suggest.
The link for the jar is discussed here:
Hi Narendra,
for this requirement you can use Add time stamp option to generate the file with the format yyyyMMdd-HHmmss-SSS.
or you can go for dynamic file name or variable substitution or ASMA or use OS command.
go through the below link to understand better..
http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=272171407
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you try if below code works:
package com.sap.pi.java.mapping;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
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.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class DynamicFileName extends AbstractTransformation{
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException
{
String oldFilename = "";
String newFilename = "";
try
{
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
Map mapParameters = (Map) transformationInput.getInputHeader().getAll();
mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic",StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");
DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
DateFormat dateFormat = new SimpleDateFormat("YYYYMMDD");
conf.put(key, dateFormat);
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
outputstream.write(b);
}
catch (Exception exception)
{
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}
}
}
You may change the format as you wish. You can also take help from:
https://wiki.sdn.sap.com/wiki/display/XI/Sample+JAVA+Mapping+code+using+PI+7.1+API
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can write Java mapping where you read the whole input messages as steam along with that you can set the ASMA property - file name to the output steam.
Regards,
Ashish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would prefer OS script for this requirement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
>>>>How we can achieve this using reciver file channel.??
custom adapter module would be one way - just setting the ASMA for filename to this format ccyymmddhhmmss
Regards,
Michal Krawczyk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.