cancel
Showing results for 
Search instead for 
Did you mean: 

File Sender / Separating a variable number of data blocks

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member181962
Active Contributor
0 Kudos

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

Answers (3)

Answers (3)

former_member181962
Active Contributor
0 Kudos

Source structure.

<Source>
<data/>    "1:unbounded
</Endsource>

Target Structure

<Structure>
<Line/> "1:unbounded
</Structure>

map 
data -> UDF -> Line

Regards,

Ravi

Former Member
0 Kudos

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

former_member181962
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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