Skip to Content

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

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.

CSV1.JPG (15.5 kB)
CSV2.JPG (44.5 kB)
CSV3.JPG (34.5 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Aug 22, 2016 at 07:24 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 22, 2016 at 01:25 PM

    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


    scn.jpg (80.5 kB)
    scn.jpg (63.7 kB)
    scn.jpg (66.1 kB)
    filename.JPG (105.6 kB)
    csv.JPG (33.2 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.