IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Converting a record to fixed length and padding out fields


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Michaelod
Warnings : 1

New User


Joined: 02 Sep 2008
Posts: 49
Location: Edinburgh

PostPosted: Fri Oct 09, 2009 4:34 pm
Reply with quote

All,

I have the following input:

Code:
SGL10,080630,+102.12, ,GBP
SGL10,080630,+1378.47,-18.66 ,GBP
SGL10,080630, ,-3087.24,GBP
SGL10,080630,+32,-6178,GBP
.


I need to make each field a fixed length. Field 1 should be 10 bytes, field 2 should be 6, field 3 should be 32, field 4 should be 32 and field 5 should be 3.

I also want to omit any records where the first byte is '.', like the last record above.

The output should look like the following:

Code:
SGL10     ,080630,+0000000000000000000000000102.12,                                ,GBP
SGL10     ,080630,+0000000000000000000000001378.47,-0000000000000000000000000018.66,GBP
SGL10     ,080630,                                ,-0000000000000000000000003087.24,GBP
SGL10     ,080630,+0000000000000000000000000032.00,-0000000000000000000000006178.00,GBP


The output record will have a fixed length of 87.

Thanks
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Oct 09, 2009 8:56 pm
Reply with quote

Michaelod,

Use the following DFSORT JCL. Your total length of 5 fields is only 83 (10+6+32+32+3) and the last 4 bytes will be spaces

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
SGL10,080630,+102.12, ,GBP                                             
SGL10,080630,+1378.47,-18.66 ,GBP                                     
SGL10,080630, ,-3087.24,GBP                                           
SGL10,080630,+32,-6178,GBP                                             
.                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  OMIT COND=(1,1,CH,EQ,C'.')                                           
  SORT FIELDS=COPY                                                     
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),                           
               %02=(ENDBEFR=C',',FIXLEN=06),                           
               %03=(ENDBEFR=C',',FIXLEN=32),                           
               %04=(ENDBEFR=C',',FIXLEN=32),                           
               %05=(FIXLEN=3)),                                       
        BUILD=(%01,%02,%03,%04,%05)                                   
                                                                       
  OUTREC IFOUTLEN=87,IFTHEN=(WHEN=(17,32,SS,EQ,C'.'),                 
  OVERLAY=(17:17,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT.TT),       
           SIGNS=(+,-)),HIT=NEXT),                                     
  IFTHEN=(WHEN=(17,32,SS,NE,C'.',AND,17,32,CH,NE,C' '),               
  OVERLAY=(17:17,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT),         
           SIGNS=(+,-),C'.00'),HIT=NEXT),                             
  IFTHEN=(WHEN=(49,32,SS,EQ,C'.'),                                     
  OVERLAY=(49:49,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT.TT),       
           SIGNS=(+,-)),HIT=NEXT),                                     
  IFTHEN=(WHEN=(49,32,SS,NE,C'.',AND,49,32,CH,NE,C' '),               
  OVERLAY=(49:49,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT),         
           SIGNS=(+,-),C'.00'))                                       
//*
Back to top
View user's profile Send private message
Michaelod
Warnings : 1

New User


Joined: 02 Sep 2008
Posts: 49
Location: Edinburgh

PostPosted: Fri Oct 09, 2009 9:59 pm
Reply with quote

The length is 87.........there is a comma i.e. ',' between each field.

Is there not an easier way pad out the amount fields?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Oct 09, 2009 10:26 pm
Reply with quote

Michaelod,

Oops, I did not notice the comma's in between.

Quote:

Is there not an easier way pad out the amount fields?


Well given that you want pad zeros if the decimals doesn't exist and retain spaces when there is no amount , I can't really see an easier way to do it

Here are the updated control control cards for creating the file with comma's


Code:

//SYSIN    DD *                                                   
  OMIT COND=(1,1,CH,EQ,C'.')                                       
  SORT FIELDS=COPY                                                 
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),                       
               %02=(ENDBEFR=C',',FIXLEN=06),                       
               %03=(ENDBEFR=C',',FIXLEN=32),                       
               %04=(ENDBEFR=C',',FIXLEN=32),                       
               %05=(FIXLEN=3)),                                   
        BUILD=(%01,C',',%02,C',',%03,C',',%04,C',',%05)           
                                                                   
  OUTREC IFTHEN=(WHEN=(19,32,SS,EQ,C'.'),                         
  OVERLAY=(19:19,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT.TT),   
           SIGNS=(+,-)),HIT=NEXT),                                 
  IFTHEN=(WHEN=(19,32,SS,NE,C'.',AND,19,32,CH,NE,C' '),           
  OVERLAY=(19:19,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT),     
           SIGNS=(+,-),C'.00'),HIT=NEXT),                         
  IFTHEN=(WHEN=(52,32,SS,EQ,C'.'),                                 
  OVERLAY=(52:52,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT.TT),   
           SIGNS=(+,-)),HIT=NEXT),                                 
  IFTHEN=(WHEN=(52,32,SS,NE,C'.',AND,52,32,CH,NE,C' '),           
  OVERLAY=(52:52,32,SFF,EDIT=(STTTTTTTTTTTTTTTTTTTTTTTTTTTT),     
           SIGNS=(+,-),C'.00'))                                   
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top