cancel
Showing results for 
Search instead for 
Did you mean: 

adapter file receiver - file with fix length record

Former Member
0 Kudos

Hi everybody,

In the file adapter receiver, I want to create a fixed length record file .

Each record need to have the same size.

How is it possible, because I have a file which contains variable legnth depending of the lenght of message?

exemple:

<mess>

<row>1234567</row>

<row>123456789A</row>

</mess>

give the file

1234567<CR>

123456789A<CR>

<CR> means carriage return

and I want a file like

1234567 <CR>

123456789A<CR>

with the same lenth of record (10 in the example).

Can anyone help me, ,please?

Kind regards.

E. Koralewski

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

> and I want a file like

> 1234567 <CR>

> 123456789A<CR>

>

> with the same lenth of record (10 in the example).

>

> Can anyone help me, ,please?

This you have to handle in mapping. You need to created an UDF which should check the length of field, if length is less than 10 then it should add spaces for the remaining values.

Regards,

Sarvesh

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Eric,

Create a value user defined function with one input argument a and name it is inputpad. Then add the following code:

Imports: java.*;

while (a.length()<Integer.parseInt("10"))

{

a= a +" " ;

}

return String;

Here I am assuming your fixed length for the field is 10. If it is more or less then change the number. Now in your mapping do all your logic and then in the final add this like:

input ---> your logic --> inputpad udf --> target.

Regards,

---Satish