Skip to Content
avatar image
Former Member

File content conversion question

Hi Friends,

I am having a text file that I need to send to partner in XML format for that i am going to use FCC.

Content of text file is like this:

:20:2000000003

:32A:081227USD10000,00

:50:ABC COMPANY

SMALL INDUSTRIAL CITY

USA

:52A:AAALSARI

:53B:/010-049-123-008

:57A:BSFRSARI

:59:/812-8300-270

ABC COMP. (TESTING FOR B2B)

OFFICE NO. 999

11111 SMALL INDUSTRIAL CITY

:70:INV. 9876543 FR.27.12.08

and I want to convert it to:

<TransactionData>:20:2000000003

:32A:081227USD10000,00

:50:ABC COMPANY

SMALL INDUSTRIAL CITY

USA

:52A:AAALSARI

:53B:/010-049-123-008

:57A:BSFRSARI

:59:/812-8300-270

ABC COMP. (TESTING FOR B2B)

OFFICE NO. 999

11111 SMALL INDUSTRIAL CITY

:70:INV. 9876543 FR.27.12.08

</TransactionData>

How can I do so, kindly suggest.

Thanks,

Brij....

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Mar 02, 2009 at 02:04 PM

    It should be simple. Basically you are treating the entire file as one record. Define the record strucuture as record,1.

    You should be done..!!

    VJ

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 03, 2009 at 03:51 AM

    Hi,

    Your requirement is to read the input text file to a single field of target structure.

    check out the wiki, detailing step by step procedure to implement the above requirement..

    https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/read%252binput%252btext%252bfile%252bas%252ba%252bsingle%252bfield

    Regards,

    Swetha.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Yeah, as you said it concates the complete text of the file.

      For your requirement,

      If the length of the input text is fixed for all the incoming files,then fcc is possible considering the entire text as a single field/single record.

      If the length is variable, fcc is not possible as there is no specific delimiter/separator in the file you have mentioned.

      You have to go for java mapping if the length is variable ,i suppose.

      If you can see the java code provided in the link which i have mentioned, each line of the input file is being appended using "buffer.append(line)". Try the same java code, with the lines not being appended and the text as it is to string.

      Try using the below in the code provided(in the link)

      String line= inpfile.readLine();

      while ((line != null){

      buffer.append(line);

      line= inpfile.readLine();

      if(line!=null){

      buffer.append("\n");

      }

      }

      String inptfile=buffer.toString();

      Regards,

      Swetha.

      Edited by: Swetha Reddy on Mar 3, 2009 7:18 AM

      Edited by: Swetha Reddy on Mar 3, 2009 7:29 AM

      Edited by: Swetha Reddy on Mar 3, 2009 9:07 AM

  • avatar image
    Former Member
    Mar 03, 2009 at 07:21 AM

    Hi,

    Please refer to a blog:

    File Adapter (Receiver) - Are we "really" sure about the concepts?

    /people/shabarish.vijayakumar/blog/2007/08/03/file-adapter-receiver--are-we-really-sure-about-the-concepts

    Rgds

    joel

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 03, 2009 at 08:27 AM

    Hi,

    Follow the steps mentioned below to get the desired output:

    Create Mapping :http://www.flickr.com/photos/23639237@N02/3040806902/sizes/o/

    Sender FCC: http://www.flickr.com/photos/23639237@N02/3040809452/sizes/o/

    Receiver FCC: Since you want to send XML file, so there will be no FCC at receiver adapter.

    Output: http://www.flickr.com/photos/23639237@N02/3039973629/sizes/o/

    Note: The above output was created for exactly similar kind of problem.

    Regards,

    Sarvesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 04, 2009 at 07:45 PM

    Have you tried the solution provided by me?? If you feel any difficulty, let me know.

    Regards,

    Sarvesh

    Add comment
    10|10000 characters needed characters exceeded