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

add leading and trailing zero for different conditions


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

New User


Joined: 24 Feb 2009
Posts: 14
Location: chennai

PostPosted: Fri Feb 27, 2009 5:02 pm
Reply with quote

Input File -1
Code:

153
155
160
17
0
1
2


output File-1
Code:

00153
00155
16000
00017
00000
00001
20000


1. If It is a ODD number , gotta include leading zeros
2. if it is a EVEN number , gotta incluide trailing zeros,for zero - 00000
3. Lenght should be = 5
Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Fri Feb 27, 2009 5:50 pm
Reply with quote

i tried this.. worked for me..

Code:

   SORT FIELDS=COPY                               
   INREC FIELDS=(1,5,X,1,5,UFF,M10)               
   OUTFIL IFTHEN=(WHEN=(11,1,SS,EQ,C'1 3 5 7 9'), 
          BUILD=(1,5,UFF,M11)),                   
          IFTHEN=(WHEN=(11,1,SS,EQ,C'0 2 4 6 8'), 
          BUILD=(1,5,ZD,M11))                     
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Feb 27, 2009 10:15 pm
Reply with quote

Vaasuki,

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
153
155
160
17
0
1
2
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,
    OVERLAY=(81:1,5,UFF,MOD,+2,M11,LENGTH=1)),
   IFTHEN=(WHEN=(81,1,CH,EQ,C'1'),
    OVERLAY=(1:1,5,UFF,M11,LENGTH=5)),
   IFTHEN=(WHEN=NONE,
    OVERLAY=(1:1,5,ZD,M11,LENGTH=5))
/*
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 IEBGENER to copy from FB to VB and re... All Other Mainframe Topics 3
No new posts Convert Numeric to Packed decimal and... DFSORT/ICETOOL 5
No new posts Process Last Key of a record based on... DFSORT/ICETOOL 5
No new posts INCLUDE 2 conditions to copy in the o... DFSORT/ICETOOL 10
This topic is locked: you cannot edit posts or make replies. Issue in suppressing leading zeros &a... COBOL Programming 21
Search our Forums:

Back to Top