on 04-02-2013 11:04 AM
Hi All,
I have a ECC to FTP pass through scenario i.e. no ESR objects.
ECC will send FILE.DAT. After adding timestamp it should look like FILE_DDMMYYYY.DAT. Using Add Time Stamp it will add time stamp but not in the desired format.
How to achieve this?
The best option for pass through scenario is to create dummy ESR objects and use UDF to name the file name dynamically, as sunil mentioned.
With this option you are creating only one valid ESR object, other objects shall be dummy ones.
Thanks,
Pranav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you wish to go for a Java mapping, then below code may be useful:
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);
Date obj1 = new Date();
SimpleDateFormat formatter = new SimpleDateFormat ("DDMMYYYY");
String dateStr = formatter.format(obj1);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
oldFilename = conf.get(key);
oldFilename = oldFilename+"_"+dateStr;
conf.put(key, newFilename);
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
outputstream.write(b);
}
catch (Exception exception)
{
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}
}
}
Also go through:
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.
Overall you have three possibilities..
> Create dummy ESR objects and use UDF for Dynamic Configuration
> Develope Adapter Module with your specific requirement
> RUN OS Command
As you are using FTP at receiver end, use of OS Command will be easiest way to achieve your scenario.
Assosiated threads already provided in above replies.
Hope it helps.!
Regards,
Sunil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shaibayan,
Yes, You can achieve by using Dynamic configuration UDF and well Adapter specific message attributes. Also please find the below step by step documents:
http://scn.sap.com/thread/1389680
http://saptechnical.com/Tips/XI/ASMA/Index.htm
" saptechnical "
Thanks,
Maruthi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shaibayan,
They is a Similar thread like this, you can check here,
https://scn.sap.com/thread/192751
Thanks,
Seshu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shaibayan,
AS you don't using ESR object so it is difficult to require file name with time stamp with dynamic configuration.
but you can go for RUN OS command and use the rename command after message processing and try to achieve this using OS command.
if you want to go for dynamic configuration then check blow blog that may help you.
Regards
Gagan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shaibayan,
You can achieve this in 2 ways.
1)Custom Module
2)OS command/batch/shell script executing from PI Receiver file channel.
1)I personally prefer this .With few lines of code you can achieve your requirement with good error handling.
2)OS dependent.Need to be bit cautious .Go through below link for better clarity .
http://scn.sap.com/thread/1987070
Regards
Venkat
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.