cancel
Showing results for 
Search instead for 
Did you mean: 

FCC for picking a CSV file & read the file name a pass to the target in one field

former_member355445
Participant
0 Kudos

HI All,

I have a requirement that need to pick CSV file from the source(NFS location) and pass to ECC through Proxy.

1) I need a content conversion for reading the CSV file. for looking the .csv file as below.

the file looking as below

and also if I open the file looks like below

and also if open the file with notepad++ looks like below

need to pick this file from NFS location.

2) also I need to exclude the first line which is a header, having the names of the fields and consume from second line onwards.

3) and also the file name to be read and pass to the ECC in a separate field in the target  like BR_CSVXXXX

Thanks for your help in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Vinay,

                  Use the following FCC for creating the xml out of csv

The data type you need to create is this for input source xml

inbound xsd will be

you can use an udf in mapping as shown below. All fields are mapped one to one direct mapping.

the udf


public String fileName(String var1, 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");

return conf.get(key);

}

tick ASMA and filename in sender communication channel.


The input csv file

output xml

<?xml version="1.0" encoding="UTF-8"?>

-<ns0:MT_TGT xmlns:ns0="urn:Demo/SCN">-<Header><Details><BANKID>"abc"</BANKID><BANKNAME>xyz</BANKNAME><ACCTID>123</ACCTID><ACCNUMBER>456</ACCNUMBER><ACCTNAME>abc</ACCTNAME><CURRENCY>45</CURRENCY><PROCESSDATE>8112015</PROCESSDATE><VALUEDATE>8122015</VALUEDATE><TRANSACTIONDATE>234</TRANSACTIONDATE><ITEMTYPE>78.67</ITEMTYPE><AMOUNT>hi</AMOUNT><DESC>br</DESC><BRTN>cr</BRTN><BRCR>cr</BRCR></Details>-<Details><BANKID>abc</BANKID><BANKNAME>"xyz"</BANKNAME><ACCTID>123</ACCTID><ACCNUMBER>456</ACCNUMBER><ACCTNAME>abc</ACCTNAME><CURRENCY>45</CURRENCY><PROCESSDATE>8112015</PROCESSDATE><VALUEDATE>8122015</VALUEDATE><TRANSACTIONDATE>234</TRANSACTIONDATE><ITEMTYPE>78.67</ITEMTYPE><AMOUNT>hi</AMOUNT><DESC>br</DESC><BRTN>cr</BRTN><BRCR>cr</BRCR></Details><Filename>t1.csv</Filename></Header></ns0:MT_TGT>

you can remove double quotes in mapping using standard text function replaceString(inputstring,"/"",""); you can see this blog for more details

Message Mapping Replace String - Wiki - SCN Wiki

Regards

Anupam

manoj_khavatkopp
Active Contributor
0 Kudos

You can remove the double quotes at FCC level only parameter : NameA.enclosureSignEscape

anupam_ghosh2
Active Contributor
0 Kudos

Thanks Manoj, I wanted to keep the FCC simple and handle the same in mapping.

Thank you for pointing out.

former_member190293
Active Contributor
0 Kudos

Hi Manoj!

I guess that you need two parameters for that:

enclosureSign="

enclosureSignEscape=""

Regards, Evgeniy.

former_member190293
Active Contributor
0 Kudos

Hi Vinay!

1. Use File Content Conversion to build XML structure from your source .CSV file.

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

2. Use FCC "Document offset" property to skip first line in your .CSV file.

3. Use ASMA parameter "File name" in sender file adapter to store file name to Dynamic Configuration and use UDF in message mapping to get file from DC and put to payload.

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");

string filename=conf.get(key);

return filename;

Regards, Evgeniy.