Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Converting a record to fixed length and padding out fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Converting a record to fixed length and padding out fields
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    Post subject: Reply to: Converting a record to fixed length and padding ou
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    Post subject: Reply to: Converting a record to fixed length and padding ou
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    Post subject: Reply to: Converting a record to fixed length and padding ou
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 5 Sat Jan 21, 2017 4:02 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us