Skip to Content
author's profile photo Former Member
Former Member

File Adapter - File Content Conversion to XML last element missing

I'm using the SAP File Adapter with File Content Conversion to convert | (pipe) delimited records into XML.

When the last field is blank, I would expect that an empty node gets created, however, the node doesn't get created at all.

For example given these settings...

Record.fieldSeparator = |

Record.endSeparator = 'nl'

Record.fieldNames = FIELD1,FIELD2,FIELD3

Using this three record file as my data...

|123|XYZ
ABC||XYZ
ABC|123|

When converted to XML, this is what the recordset XML structure looks like...

<Recordset>

<Record>

<FIELD1 />

<FIELD2>123</FIELD2>

<FIELD3>XYZ</FIELD3>

</Record>

<Record>

<FIELD1>ABC</FIELD1>

<FIELD2 />

<FIELD3>XYZ</FIELD3>

</Record>

<Record>

<FIELD1>ABC</FIELD1>

<FIELD2>123</FIELD2>

</Record>

</Recordset>

Notice that the last record is missing the "FIELD3" element.

Edited by: William Krick on Jun 17, 2011 4:49 PM

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Best Answer
    Posted on Jun 17, 2011 at 05:09 PM
    123|XYZ
    ABC||XYZ
    ABC|123|

    If I understood correctly, your question is field3 value is missing in the last record. The problem I see it is the pipe symbol missing after ABC

    It should be   ABC||123

    then in this case the second field (field2) will be empy and third field (field3) will be filled with 123

    If the last field is empty then FCC ignores for the valid reason. If the middle fields are empty, it has to show empty for those fields to continue for the next fields. So we see field with empty tag for the second line

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 17, 2011 at 03:17 PM

    Hi,

    is a sender CC?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Fabio Boni

      It's a required field in my data type. When it is not there, I get an exception.

      I know I can change the data type to make the field optional, however, I don't think I should have to.

      I believe this is a bug with the file content conversion.

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2011 at 02:58 PM

    use mapwithdefault function between source and target element this will create empty tag for no values from source.

    chirag

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 20, 2011 at 02:37 AM

    Hi William Krick,

    Can paste the error message you are getting and where you are getting it?

    Regards,

    Raghu_Vamsee

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi William Krick,

      I have checked the screenshot of error message. Message is failing as mandatory target field is not getting created.

      Solution: - Use If, exits, constant functions. If FIELD3 exits, map target with FIELD3, else mapp with empty Constant (nothing).

      Insert this logic to all mandatory target fields (occurrence 1 or 1...unbound). This will solve the issue.

      Regards,

      Raghu_Vamsee

  • Posted on Jun 20, 2011 at 02:00 PM

    Hi William,

    the record file is wrong formatted.

    You set pipe as field separator but in the third record the third field is not present, after 123| there must be another pipe, like it happens for first record (=field empty followed by pipe).

    Fabio

    Add a comment
    10|10000 characters needed characters exceeded

    • There IS a field in the third record. It just happens to be empty.

      Each row in my input file has three fields and two pipes.

      I expect the output to have three XML tags for each row. If there's no data, it should be an empty tag.

      The problem is that the behavior is different when the empty field is the last field.

      Hi,

      behavior is different because records are different: in the first 2 records after empty field there is a delimiter, in third record after empty field there is no delimiter.

      So:

      1 record empty --> delimiter

      3 record empty --> no delimiter

      behaviour is different.

      Try to add a pipe in third record at the end of the record and tell me the result.

      Best Regards

      Fabio

      p.s. Also solutions suggested by other users are solutions in order to add a field, because in 3 record last field is not present and so is not generated.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2011 at 12:38 PM

    Hi William

    Have you already found a solution for the problem with the last missing field?

    I agree with you, that if after the final delimiter is no value, at least one empty tag should be created.

    Currently I'm facing the same issue.

    I know, that with the parameter missingLastFields empty tags will be created for the missing items.

    Unfortunately this is no option for me because the inputfile has to be complete (missing fields are not allowed).

    I'm really looking forward to your reply.

    Kind regards,

    Susanne

    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.