cancel
Showing results for 
Search instead for 
Did you mean: 

how to change the delimiter in output file

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

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());

        }

    }

}

Former Member
0 Kudos

Thanx Raghu!

I tried, using the first method you specified i.e. FCC to FCC.

It is working fine for me.

I will definetly try it using JAVA mapping method as well

Answers (3)

Answers (3)

Former Member
0 Kudos

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!

ridvan_polat
Participant
0 Kudos

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,

http://wiki.scn.sap.com/wiki/download/attachments/94765915/Replace%20String%20Mapping.JPG?version=1&modificationDate=1240574399000&api=v2


Regards

Ridvan

former_member184720
Active Contributor
0 Kudos

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 XML in the Receiver File/FTP Adapter to Text Format - Advanced Adapter Engine - SAP Libra...

Converting Text Format in the Sender File/FTP Adapter to XML - Advanced Adapter Engine - SAP Library

Former Member
0 Kudos

Hi Hareesh,

I just want to change the delimiter comma ' to  colon ;

In ESR there is one to one mapping between all the fields.

Also can you pls. elaborate how can i use replace string function in java mapping?

former_member184720
Active Contributor
0 Kudos

>>> 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.