on 04-22-2013 9:22 PM
Hello Everyone,
I have a requirement to add date to the receiver file adapter file.
Its a file to file scenario.
I know we have two options . one is custom module or a script.
Can someone help me with the script to be coded .
Regards,
Ravi
You might want to try adding Add Timestamp parameter under construction mode. Remember, this provides date followed by time. You might want to give only date format and ignoring the time part and see if that helps. Otherwise after the files are created, You run the script that append dates as the end.
Unix command
cp filename filename`date +%Y%m%d`
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Baskar,
My question is till open as i tried to write a script and it did not work ..
Can you please check the below script and see what is going wrong.
logDir=/interface/scripts
logFile=dateMATMASTFiles.log
echo "Entered script" >> $logDir/$logFile
USER=xxxxxx
PASSWD=xxxxxxx
HOST="xxx.xxx.xxx.xx"
ftp -n $HOST <<END_OF_FTP >> /interface/scripts/ftp_connection.log
user $USER $PASSWD
cd /interface/tes
binary
prompt off
cp filename filename`date +%Y%m%d
quit
END_OF_FTP
echo "Leaving script" >> $logDir/$logFile
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes Hanumantha Rao Gouru is correct . that is simple to handle in mapping level .
Step1:
Addtimestamp udf ->dyanamicConf(udf) -> targetnode.
Addtime stamp udf : (import pkg "java.text.SimpleDateFormat" under importInstructions)
public String AddTimestamp(String var1, Container container) throws StreamTransformationException{
String DATE_FORMAT_NOW = "yyyyMMddHHmmssSSS"; // here u have to give specific format
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
return sdf.format(cal.getTime());
dynamicUDF:
public 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 "";
step2:
use ASMS properties in both Adapters(sender & Receiver).
Without ESR Objects:
u can follow Baskar reply..
thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
use the below code.
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
//get current date
Date date = new Date( );
var_Filename = conf.get(key) + dateFormat.format(date);
conf.put(key, var_Filename);
Thanks,
Satish.
Hi Ravi,
I agree all above replies, if they siut your requirement as per your business.
My descriptions:
1.If you have AttribMapper in your PI (Generally comes from Seeburger AS2 Adapter),
then you can use that as below:
2. you are using Mapping for your scenario, then you write UDF same as above UDF (from Sugata) and use DATE functions as per your requirement to get file name and pass the same to UDF and use it to create file name.
Among all these replies now you can choose whichever is easy.
Regards,
Sreeni.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
You can simply write a UDF and use ASMA properties to add date. Instead of going for script this would be the better option.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use dynamic configuration in mapping along with ASMA in rcv file adapter..
Using UDF and Java date time class you can add your custom date time to the file.
e,g-
try {
String filename = "";
String timestamp = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
DynamicConfigurationKey key2 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","SourceFileTimestamp");
filename = conf1.get(key1);
timestamp = conf1.get(key2);
filename = filename.replaceAll( ".txt" ,"_" );
filename = filename+timestamp+".xml";
conf1.put(key1,filename);
return filename;
}
catch(Exception e)
{
String exception = e.toString();
return exception;
}
you can change the timestamp value as per your own.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.