on 04-08-2015 6:55 PM
I have CSV as a source file.
My requirment is to have colon ; as a delimiter in target file.
What parmaters should I pass in FCC for this requirement?
Source File:
H,1205,RUBY,19
D,2222,STEVE,25
T,000,507.4,22.5
Expected Target File:
H;1205;RUBY;19
D;2222;STEVE;25
T;000;507.4;22.5
Sarjana,
Use FCC in sender channel to convert CSV to XML then one-to-one graphical mapping (mapping not required) then in receiver channel FCC XML to text file (; delimited).
OR.
1. Follow "Steps in ESR" mentioned in Link (As Hareesh mentioned)
2. Create Java Mapping.
3. Remove SWCV (as input is non XML- CSV).
package com.javaMapping;
import java.io.*;
import com.sap.aii.mapping.api.*;
public class WellformedXML_JavaMapping extends AbstractTransformation {
@Override
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
try {
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
// a) Copy Input content to String
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
String inputContent = new String(b);
// b) Replace all , with ;
inputContent = inputContent.replaceAll(",", ";");
outputstream.write(inputContent.getBytes());
} catch (Exception exception) {
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Guys one more thing,I am now trying using JAVA Mapping method as Raghu specified and have one query.
Do I have to write the logic in NWDS and then have to import Archive in ESR?
Is there any other method for doing it i.e. cant I write the java code directly in ESR for this scenario, If yes , how?
New to JAVA mapping, Pls help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sarjana,
If your source file has delimiter comma then add below parameter to your FCC
Recordset.fieldSeparator = ,
If it has delimiter semicolon then add this parameter
Recordset.fieldSeparator = ;
If you want PI to get the source file with delimiter comma and output the target file as converted to delimiter semicolon, you can do it by using Replace String standart function in graphical mapping.
Example,
Regards
Ridvan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would you be just changing the delimiter or do you have any transformation?
if you are just changing the delimiter, then go for a java mapping and use replace string which way you don't need to develop any ESR objects.
Reference code to read file : Dynamic file name for pass-through scenario - Process Integration - SCN Wiki
if you have some transformations requirements, just follow the help documentation/ search for blogs.. We have many blogs available on FCC.
Converting Text Format in the Sender File/FTP Adapter to XML - Advanced Adapter Engine - SAP Library
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>>> elaborate how can i use replace string function in java mapping?
You can just google for java replace string.. You get lot of tutorials.
If you go with graphical mapping, then as i mentioned in my previous reply, FCC is not that difficult.
Just search and follow the SAP documentation.
If you have already tried and getting some errors, then let us know so that we can help you.
User | Count |
---|---|
86 | |
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.