on 10-06-2012 7:57 AM
Hi Folks,
I working on SAP(Proxy) to SFTP interface.In this interface i am not able to generate file name in the below conversion format.
Can any one suggests how to genarte this..If we execute the interface if the profit cntrer is CN001 or from CN002 or from CN003
the file shpuld be shown as below fromat.
Naming conversions format.
BCOXXXXXX_Customer_YYYYMMDD.csv |
BCOXXXXXX_OpenItems_YYYYMMDD.csv |
Sample expected for this project.
BCOCN001 | GEED |
Customer File | BCOCN001_Customer_YYYYMMDD.csv |
Open Items File | BCOCN001_OpenItems_YYYYMMDD.csv |
BCOCN005 | GEGE |
Customer File | BCOCN005_Customer_YYYYMMDD.csv |
Open Items File | BCOCN005_OpenItems_YYYYMMDD.csv |
BCOCN006 | GEBR |
Customer File | BCOCN006_Customer_YYYYMMDD.csv |
Open Items File | BCOCN006_OpenItems_YYYYMMDD.csv |
Can any one help me on this...
Kalyan,
Please use above UDF given by Anupam , above udf will fulfill your requirement. Sorry i didn't checked AM & PM. So, i deleted my previous post.
Regards
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kalyan,
In communication channel -> adapter specific attributes check file name also and use the following udf .
public String Dynamic(String FileName, String Date,String BCOCN001,String BCOCN002,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");
String myFileName = "" ;
if(BCOCN001.equals("GEED"))
{
myFileName = FileName + "_Customer_" + Date+".csv";
conf.put(key, myFileName);
}
if(BCOCN002.equals("GEER"))
{
myFileName = FileName + "_OpenItems_" + Date+".csv";
conf.put(key, myFileName);
}
return myFileName;
}
1st parameter for this UDF is constant(i.e, BCOXXXXXX).
2nd parameter is Date (use current date function and specify date and time format )
3 rd & 4th parameters are BCOCN001 & BCOCN002 from Input payload.
Don't forget to map udf to any node , then only ur dynamic configuration will work.
Note : Above conditions are examples only (if(BCOCN002.equals("GEER"))) give your own condition.
Let me know the result.
Regards
Hari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hari,
Thanks for the reply..in the above file format example there are two interfaces(1 is Customer Master and 2.Open items interface).
Customer Number | Business Customer Number | A/R Customer Number | Paying Customer Number | Business Paying Customer Number | A/R Paying Customer Number | Billing Component |
1000123 | BCOCN001 |
If i Execute Customer master interface from sap the filename should be
BCOXXXXXX_Customer_YYYYMMDD.csv
Sample expected for this project.
BCOCN001_Customer_YYYYMMDD.csv
BCOCN005_Customer_YYYYMMDD.csv
BCOCN006_Customer_YYYYMMDD.csv
I am new to PI ,So Can you send me the udf and mapping for only Customer master interface.
Thanks
Kalyan
Hi Kalyan,
Please correct me , if I got your requirement wrongly , when ur using interface Customer Master . Input payload will contain BCOCN001 , BCOCN005 or BCOCN006 . If BCOCN001="GEED" then file name should be BCOCN001_Customer_YYYYMMDD.csv and so on for BCOCN005 & 06 .correct? If yes, Use following UDF .
public String Dynamic(String Date,String BCOCN001,String BCOCN005,String BCOCN006,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");
String myFileName = "" ;
if(BCOCN001.equals("GEED"))
{
myFileName = "BCOCN001" + "_Customer_" + Date+".csv";
conf.put(key, myFileName);
}
if(BCOCN005.equals("your condition"))
{
myFileName = "BCOCN005"+ "_Customer_" + Date+".csv";
conf.put(key, myFileName);
}
if(BCOCN006.equals("yourcondition"))
{
myFileName = "BCOCN006" + "_Customer_" + Date+".csv";
conf.put(key, myFileName);
}
return myFileName;
}
1st parameter is Date (use current date function and specify date and time format )
2 nd ,3rd & 4th parameters are BCOCN001, BCOCN005 & BCOCN006 from Input payload.
Regards
Hari.
Hi Hari,
Its working now,Thanks for the reply...
Now i am able to get the file name in above format.But only one chnage we got recently in file name.
i.e As per new chnages the file name should be like this
BCOCN001_Customer_YYYYMMDDHHmmssAM.csv
BCOCN001_Customer_YYYYMMDDHHmmssPM.csv
I am able to get file name upto here BCOCN001_Customer_YYYYMMDDHHmmss.
But for AM/PM i am nt able get,any logic need to write for this also?
If yes please help me on this...
Thanks
Kalyan
Hi Kalyan,
You are accepting the current date of the system in the UDF. I have made made little changes to the beautiful code written by Hari to meet your present requirement. There is no need to supply the current date to the UDF, instead generate the date in UDF itself. Thus the UDF becomes like this
public String Dynamic(String BCOCN001,String BCOCN005,String BCOCN006,Container container) throws StreamTransformationException{
java.util.Date currentDateTime=new java.util.Date();
java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyyMMDDkkmmssa");
String Date=sdf.format(currentDateTime).toString();
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
String myFileName = "" ;
if(BCOCN001.equals("GEED"))
{
myFileName = "BCOCN001" + "_Customer_" + Date+".csv";
conf.put(key, myFileName);
}
if(BCOCN005.equals("your condition"))
{
myFileName = "BCOCN005"+ "_Customer_" + Date+".csv";
conf.put(key, myFileName);
}
if(BCOCN006.equals("yourcondition"))
{
myFileName = "BCOCN006" + "_Customer_" + Date+".csv";
conf.put(key, myFileName);
}
return myFileName;
}
Hope this resolves your problem.
Regards
Anupam
Hi Kalyan,
You can achieve this with either Variable Substitution or Dynamic Configuration.
If you have a mapping step, you can use Dynamic Configuration code in UDF and set the receiver file name at runtime.
You can refer the below blog,
Check for Code the Dynamic Configuration: part point 3.
I hope you can get the Profit Center value from Proxy and then pass this as input to UDF in mapping.
Regards,
Zameer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.