on 06-11-2013 8:29 AM
Hi Experts,
I am working on FCC content conversion scenario. Where I need to pick the .csv files and convert into XML file. My source file structure will be like this.
"InvoiceNumber","InvDate","InvoiceAmount","VendorNumber","CheckIdentifier","CheckDate","PaymentAmount","InternalComments","RemittanceNotes"
"19251087",01-DEC-12,1725.07 ,"1000002780","1012989",15-MAR-13,1725.07 ,,
"19251090",01-DEC-12,820.17 ,"1000002780","1012989",15-MAR-13,820.17 ,,
"19251091",01-DEC-12,609.31 ,"1000002780","1012989",15-MAR-13,609.31 ,,
"3946417",01-DEC-12,1938.23 ,"1000003686","0020063147",15-MAR-13,1938.23 ,,
"514488068120112",01-DEC-12,131.58 ,"1000007578","000937",15-MAR-13,131.58 ,,
in my file sender comm channel which FCC parameters i need to use to pick the fields. I need your valuable inputs
Thanks & Regards,
Pavan
Hi Pavan,
You can use the following parameters..
change Record.fieldnames :
InvoiceNumber,InvDate,InvoiceAmount,VendorNumber,CheckIdentifier,CheckDate,PaymentAmount,InternalComments,RemittanceNotes.
Document name: specify the message type of file.
Document namespace: specify the name space which you have created for the scenario.
Record structure as you specified in your message type.
Hope it will helpful..
Regards
Bhargava krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhargav,
I have created my comm channel as you mentioned. I am able to pick the file successfully. I am facing some issue with receiver file is not converted into XML properly.
here the output XML message.i have used ASMA parameters in my comm channel configuartion.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:output xmlns:ns0="http://testfile2file"><gad><InvoiceNumber><?xml version="1.0" encoding="UTF-8"?></InvoiceNumber></gad><gad><InvoiceNumber><ns0:output xmlns:ns0="http://testfile2file"><gad><InvoiceNumber>"InvoiceNumber"</InvoiceNumber><InvDate>"In...
here is my comm channel config
Record.fieldSeparator | , |
Record.endSeparator | 'nl' |
Record.fieldNames | InvoiceNumber,InvDate,InvoiceAmount,VendorNumber,CheckIdentifier,CheckDate,PaymentAmount,InternalComments,RemittanceNotes |
ignoreRecordsetName | true |
Thanks & Regards,
Pavan
Hi Bhargav,
After unchecking the asma option , i am able to see the output file in xml format. but i want use same source filename schema for target also. I know we can achieve this dynamic configuration UDF in my mapping ,but i never done this before. can you guide me how to create a UDF?
my requrement is lkne this if source file 123. csv then my output file name will be 123_yyMMdd.xml
Thanks & Regards,
Pavan
Hi Pavan,
Also Add the below parameters in content conversion parameters an see.
Record.fieldSeparator = |
Record.endSeparator = 'nl'
Record..keyFieldInStructure = ignore
Also refer this post
http://saptechnical.com/Tutorials/XI/Contentconversion/page2.htm
http://scn.sap.com/message/5854463
Hope it will helpful..
Regards
Bhargava krishna
Hi Pavan,
You can achieve this by using variable substitution or UDF
Refer below link for the same.
http://scn.sap.com/message/13969105#13969105
Regards
Bhargava krishna
HI Bhargav,
I used 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);
I am getting this error when i am testing the mapping
Source text of object Message Mapping: mm_mapping | http://testfile2file has syntax errors: |
17:57:08 End of test
Hi Pavan,
Did you add below import statements ?
import java.text.DateFormat;
import java.text.SimpleDateFormat;
Adding the import statements might resolve the problem.
Regards
Anupam
Hi Anupam,
I have imported your import statements
now i am getting this below error. I am using PI 7.3 (dual stack)SP5
Hi Ambirsh,
this is my first UDF . I have created my UDF like this
Name:DynamicFileName
Title:DynamicFileName
ExecutionType:SingleValues
Type : Arugurement Var1 String
and here is my code for the UDF
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);
I have taken my variable as current date and mapped to UDF and mapped to Target node.
I am getting this below error.
Source text of object Message Mapping: mm_mapping | http://testfile2file has syntax errors: |
19:54:22 End of test
Hi Pavan,
There is always a first time.
For the UDF, your target can be any node, which you have to create once.
You need to pass current date in format you need yymmdd to the function.
Here is your code assuming your argument is called Var1.
String var_FileName = new String();
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
var_FileName = conf.get(key) + "_"+ Var1;
conf.put(key,var_FileName);
return "";
Hope it helps!
Hi Ambrish,
Thanks for your response. I have added your code in my UDF .
my mapping is like this currentdate--->UDF--->Targetnode. I am getting this error
Hi pavan,
refer this blog
http://scn.sap.com/thread/3373138
you can use the same..
Regards
Bhargava krishna
Hi Pavan,
In current date, put format as yyMMdd. This should work. I tested in my machine.I hope you have not used any SampleDate format variable in the code. No need to import any other class.
I read your requirement again.
if source file 123.csv then my output file name will be 123_yyMMdd.xml
So you need to strip out 123 from the file name 123.csv, you will get when you do conf.get(key) and append _yyMMdd and extension .xml
Try it else paste your code here and I will modify.
Ambrish
Hi Ambrish,
Thanks for your concern, i changed my date format to yyMMdd and tested the scenario. i am getting my outputfile name like this. ALXN_PAYMENT_03192013.csvjava.text.
i'll tell you my requirement.
my source file name will be like this ALXN_PAYMENT_03192013.csv
i need to add current date (yyMMdd) using dynmaic file configuartion.now my desired output file name will be like this ALXN_PAYMENT_03192013_yyMMdd.xml
my UDF code is below.
String var_FileName = new String();
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
var_FileName = conf.get(key) + "_"+ var1;
conf.put(key,var_FileName);
return "";
Here is the modified code:
String originalFileName = new String();
String newFileName = new String();
DynamicConfiguration conf = (DynamicConfiguration) container .getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
originalFileName = conf.get(key);
newFileName = originalFileName.substring(0,originalFileName.indexOf('.'))+"_"+ var1+".xml"
conf.put(key,newFileName);
return "";
Hope this works!
Ambrish
Hi,
You can also try below code. Map the output of this code to the top node of the target structure.
String oldFilename = "";
String newFilename = "";
String newFilename2 = "";
DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
oldFilename = conf.get(key);
DateFormat dateFormat = new SimpleDateFormat("yyMMdd");
newFilename2 = oldFilename.replaceAll(".csv","");
newFilename = newFilename2+"_"+dateFormat+".xml";
conf.put(key, newFilename);
return "";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pavan,
Plz take a look here :http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
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.