Page 1 of 2

How to Write Fixed length file as Variable Length file?

PostPosted: Wed May 04, 2011 5:16 pm
by pjagathis
I am having fixed length file as follows

AAAAAAAA BBBB AAA
AAAAAAAA BBBBB AAA
AAAAAAAA BBBB A
AAAAAAAA BBBBB AAA
AAAAAAAA BB AA
AAAAAAAA BB AAA
AAAAAAAA BB AA
AAAAAAAA BB AAA
AAAAAAAA BB
AAAAAAAA BB AAA
AAAAAAAA BB

I need as Varialble length file with delimiter as follows..

AAAAAAAA|BBBB|AAA|
AAAAAAAA|BBBBB|AAA|
AAAAAAAA|BBBB|A|
AAAAAAAA|BBBBB|AAA|
AAAAAAAA|BB|AA|
AAAAAAAA|BB|AAA|
AAAAAAAA|BB|AA|
AAAAAAAA|BB|AAA|
AAAAAAAA||AAA|
AAAAAAAA|BB|AAA|
AAAAAAAA|BB||

Regards,
Jagathis P

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Fri May 06, 2011 12:28 am
by Alissa Margulies
Your input file appears to be variable as well. Please use code tags so that we can see the actual record layout. If all you want to do is change the delimiter from a blank to a pipe, then you can use FINDREP.

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Thu May 26, 2011 10:43 am
by pjagathis
Alissa, thanks for your reply..

See my input file

Each field has fixed length.
Eg, Field1 starts from position 1 and ends @ 8.
Field2 starts from position 9 and ends @ 17 and so on..

I need a ouput as variable length file
Field-1 Field2 Field3
AAAAAAAA BBBB AAA
AAAAAAAA BBBBB AAA
AAAAAAAA BBBB A
AAAAAAAA BBBBB AAA
AAAAAAAA BB AA
AAAAAAAA BB AAA
AAAAAAAA BB AA
AAAAAAAA BB AAA
AAAAAAAA BB
AAAAAAAA BB AAA
AAAAAAAA BB


need as Varialble length file with delimiter as follows..

AAAAAAAA|BBBB|AAA|
AAAAAAAA|BBBBB|AAA|
AAAAAAAA|BBBB|A|
AAAAAAAA|BBBBB|AAA|
AAAAAAAA|BB|AA|
AAAAAAAA|BB|AAA|
AAAAAAAA|BB|AA|
AAAAAAAA|BB|AAA|
AAAAAAAA||AAA|
AAAAAAAA|BB|AAA|
AAAAAAAA|BB||


Thanks,
Jagathis P

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Thu May 26, 2011 1:18 pm
by NicC
See my input file

This shows as varying length - example:
AAAAAAAA BB aaaa
AAAAAAAA BB AAA
so your second field looks as though it is 2 bytes (in this case - other examples show 4 and 5 bytes)

If you posted with multiple spaces then, unless you use code tags (square brackets with code and /code within them at start and end) then spacing i not preserved.
AAAAAAAA BB      aaa
AAAAAAAA BB      AAA

Use the Full Editor button (available after you start a Quick Reply) to make it easier

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Thu May 26, 2011 3:30 pm
by pjagathis
Hi Nic,

My input file is fixed length FB file but i need output as variable length FB file..

Field-1   Field2        Field3
AAAAAAAA BBBB       AAA
AAAAAAAA BBBBB      AAA
AAAAAAAA BBBB       A
AAAAAAAA BBBBB      AAA
AAAAAAAA BB         AA
AAAAAAAA BBBBBB     AAA
AAAAAAAA BB         AA
AAAAAAAA BB         AAA
AAAAAAAA BBBBB
AAAAAAAA BB         AAA
AAAAAAAA BBBBB      AAAAAAAA



Re: How to Write Fixed length file as Variable Length file?

PostPosted: Thu May 26, 2011 7:08 pm
by BillyBoyo
pjagathis wrote:Hi Nic,

My input file is fixed length FB file but i need output as variable length FB file..

[...]


I guess you mean a VB, a blocked dataset with variable length records?

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Thu May 26, 2011 9:27 pm
by NicC
Variable or Fixed - you cannot have them both - they are mutually exclusive.

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Fri May 27, 2011 1:23 am
by Alissa Margulies
Hello PJAGATHIS.

Based on your field descriptions, try this and let me know if it gives you the desired output:
//STEP1 EXEC PGM=SORT                                         
//SYSOUT  DD SYSOUT=*                                         
//SORTOUT DD SYSOUT=*                                         
//SORTIN  DD *                                                 
AAAAAAAABBBB    AAA                                           
AAAAAAAABBBBB   AAA                                           
AAAAAAAABBBB    A                                             
AAAAAAAABBBBB   AAA                                           
AAAAAAAABB      AA                                             
AAAAAAAABB      AAA                                           
AAAAAAAABB      AA                                             
AAAAAAAABB      AAA                                           
AAAAAAAABB                                                     
AAAAAAAABB      AAA                                           
AAAAAAAABB                                                     
//SYSIN   DD *                                                   
  SORT FIELDS=COPY                                               
  OUTFIL IFTHEN=(WHEN=INIT,BUILD=(1,8,C'|',9,8,C'|',17,8,C'|')),
         IFTHEN=(WHEN=INIT,BUILD=(1,27,SQZ=(SHIFT=LEFT))),FTOV                                       
/*

This will convert your fixed length fields in fixed length records to variable length fields in variable length records. If you want variable length fields but wish to maintain fixed length records, then remove the FTOV parameter on the OUTFIL statement.

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Wed Jun 01, 2011 3:55 pm
by pjagathis
Hi Alissa Magulies,

Thanks!! Its working fine. Prevoiusly we do it in SAS.

Re: How to Write Fixed length file as Variable Length file?

PostPosted: Thu Jun 16, 2011 4:47 pm
by pjagathis
HI Alissa Maguiles,

One More help.....

Below code removing spaces within the fileds

For example,

4917 WWW BBBBB LN           |AAA  AAAAA  AAAA   |
15575 SSSSS HHYR            |BBB BBBB BBBB      |         
6357 OOOO OOOO OO           |CCC CCC CCC        |
16 COOOOO SSSSSS            |SDSDSD SDSDSD      |         
1523 45TH ST                |GHGHG   GHGG       |


In the above example, after converting to variable length file, I want to kept the space between words to be as.

as below,

4917 WWW BBBBB LN|AAA  AAAAA  AAAA|
15575 SSSSS HHYR |BBB BBBB BBBB|         
6357 OOOO OOOO OO|CCC CCC CCC|
16 COOOOO SSSSSS |SDSDSD SDSDSD|         
1523 45TH ST |GHGHG   GHGG|


I want to keep the space between "4917 WWW BBBBB LN" as it is.. Only I have to remove the spaces between fields.
Please advice...