Skip to Content
avatar image
Former Member

File Sender / Separating a variable number of data blocks

Hi all,

I have a problem regarding the content conversion in a file sender adapter.

The source data has a fixed length of 10 chars, but is contained in one big line without any newlines or other sepators.

Example source data:

0123456789012345678901234567890123456789

The number of occurences can vary; that is the next file might contain more or less data blocks of 10 chars each.

Another example:

01234567890123456789

Is it possible to create a content conversion that handles this kind of data? We have already tried several configurations (for example using "fieldFixedLengths = 10") but didn't succeed. In most cases only the first data block is read an the rest is ignored. Therefore it seems to me that the adapter requires a newline in order to recognise data blocks.

The target xml structure should look like:

...

<Structure>

<Line>0123456789</Line>

<Line>0123456789</Line>

...

</Structure>

...

Do you have some hints on this one?

Thanks and regards,

lars

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jul 14, 2009 at 07:16 AM

    Hi Lars,

    How about handling it using a UDF which takes the input as a string and returns array of strings of fixed lengths.

    pseudo code for the UDF (Chose the Cache as Queue)

    String a=input[0];
    for(int i=0;i<=a.strlen()-10;i+=10)
    {
    result.addValue(a.substring(i,i+10);
    }

    Regards,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 14, 2009 at 08:44 AM

    Hi Satish,

    hello Ravi,

    thanks for your replies.

    If I understand it right, you would need two message mappings in order for this solution to work, resulting in the following steps:

    - Read File into one big record using content conversion.

    - Perform the first message mapping, splitting the content using the UDF.

    - Perform the second message mapping, containing the "business-mapping".

    Is this correct or is there a way to achive this in one single message mapping?

    Thx,

    lars

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Lars,

      No need for two mappings.

      You would just need one source structure with only one child element in it (Type string)

      And your target structure will be as shown by you in your question.

      Then you need to use the UDF that I have mentioned and map it to the node that has to repeat as many times as the number of blocks.

      After that, you have to map the same thing to the target field.

      Regards,

      Ravi

  • Jul 14, 2009 at 08:56 AM

    Source structure.

    <Source>
    <data/>    "1:unbounded
    </Endsource>
    
    Target Structure
    
    <Structure>
    <Line/> "1:unbounded
    </Structure>
    
    map 
    data -> UDF -> Line

    Regards,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 14, 2009 at 08:29 AM

    Hi Lars,

    Read the whole file into one line say record. Then as ravi suggested use his function which will split into different nodes for each fixed length. Then you can map using substring and do the other mapping logics.

    Regards,

    ---Satish

    Add comment
    10|10000 characters needed characters exceeded