I will be getting data in this format. But its not necessary that fields will contain full according to their length. Like Emp-key is of 10 byte but it can contain of 5 bytes data. So i need to write a sort card which will concatenate all fields in output file by '|' (pipe) and based on their data length output files' length must also vary. But it wont be greater than 104.
i.e
EMP-KEY(10)|EMP-NAME(30)|EMP-DESIGN-TEXT(20)|EMP-ADDRESS-TEXT(30)|EMP-SALARY

Also I hv to do vice-varsa.
I will be gettin file in above format of output file. So I need to write a sort card which will create file similart to the above input file containing LEN as well.

you spend a lot of time (and space) defending yourself,
but you never supply any of the info asked for.

and what i was referring to was threads started by you,
questions asked in order to create a solution for you,
that you never answer, and the thread dies.

but i digress,

you want:
EMP-KEY(10)|EMP-NAME(30)|EMP-DESIGN-TEXT(20)|EMP-ADDRESS-TEXT(30)|EMP-SALARY
but spaces on the right truncated?
EMP-SALARY will always be 10 char numeric?
will this be generated as a Variable record file or Fixed length (104) record file?

as well as the converse?

again, answer the question of variable length and/or fixed length.

EMP-KEY|EMP-NAME|EMP-DESIGN-TEXT|EMP-ADDRESS-TEXT|EMP-SALARY
EMP-KEY expanded to 10
EMP-NAME expanded to 30
EMP-DESIGN-LEN generated as 2 bytes binary reflecting the length of data between the two | bounding EMP-DESIGN-TEXT
EMP-DESIGN-TEXT expanded to 20
EMP-ADDRESS-LEN generated as 2 bytes binary reflecting the length of data between the two | bounding EMP-ADDRESS-TEXT
EMP-ADDRESS-TEXT expanded to 30
EMP-SALARY copied as the 10 char

Dick,
As mentioned by you, yes I need my output as:
EMP-KEY(10)|EMP-NAME(30)|EMP-DESIGN-TEXT(20)|EMP-ADDRESS-TEXT(30)|EMP-SALARY
But the fields shudn't contain trailing spaces.
YES, EMP-SALARY will always contain 10 digit numeric data.
Output File can be created in VB with 104 length.
Say if all fields contain full data without spaces then whole 104 lenth would be full. If all length fields data without spaces + 4 pipes(|) is less than 104 then remaining positions after last field(EMP-SALARY) can be filled with spaces.

While for Vice versa
It will be other way round.
Either a field contains spaces or not it shud be included till its exact length.
Ex. EMP-KEY(10) contains 5 bytes data but next field shud be written from 11th position.
LEN field will contain the length of field containing actual data without spaces. EMP-ADDRESS-TEXT(30) contains 15 bytes data then LEN will be 15.
RECFM will be FB with LRECL of 104.

Output File can be created in VB with 104 length.
Say if all fields contain full data without spaces then whole 104 lenth would be full. If all length fields data without spaces + 4 pipes(|) is less than 104 then remaining positions after last field(EMP-SALARY) can be filled with spaces.

that means you want a fixed length output.....................................................