MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Removing leading zeroes

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Thu Aug 02, 2007 1:23 am    Post subject: Removing leading zeroes Reply with quote

I have one file with 5 bytes length
5 bytes will contain numeric data as
Code:

00003
00100
00055
01258

I want to take this as input file in
icetool and get output as
Code:

3
100
55
1258

Can anybody help me with the code.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Aug 02, 2007 7:08 am    Post subject: Reply with quote

psmadhusudhan,

Try this DFSORT job. You'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's JFY function. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
00003                                                         
00100                                                         
00055                                                         
01258                                                         
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  OUTREC OVERLAY=(1,05,JFY=(SHIFT=LEFT,PREBLANK=C'0',LENGTH=5))
/*                                                             


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Mon Apr 28, 2008 4:08 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Thu Aug 02, 2007 8:43 am    Post subject: Reply with quote

Thanks Kolusu
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
sushma4satya
Beginner


Joined: 04 Nov 2005
Posts: 14
Topics: 4

PostPosted: Mon Apr 28, 2008 3:15 pm    Post subject: Reply with quote

Kolusu,
I used the below code for the below records.
0000107218
0000107768
0000107768
0000107652
0000107652

Iam getting the output as
17218
17768
17768
17652
17652

but i expected the o/p as
107218
107768
107768
107652
107652

Could you suggest me the changes in the code.

Thanks
Satya
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Apr 28, 2008 4:05 pm    Post subject: Reply with quote

sushma4satya,

I am sorry. Here is the updated job which would give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
0000107218                                                     
0000107768                                                     
0000107768                                                     
0000107652                                                     
0000107652                                                     
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1,10,JFY=(SHIFT=RIGHT))),
  IFTHEN=(WHEN=INIT,OVERLAY=(1,10,ZD,M10,LENGTH=10)),       
  IFTHEN=(WHEN=INIT,OVERLAY=(1,10,JFY=(SHIFT=LEFT)))       
//*                                                         

_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Thu Feb 11, 2010 12:32 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sushma4satya
Beginner


Joined: 04 Nov 2005
Posts: 14
Topics: 4

PostPosted: Tue Apr 29, 2008 1:56 pm    Post subject: Reply with quote

Thanks Kolusu.

One more question.

If my i/p file has :

0000107139
0000107139
000107666A
000107666A

I need o/p as :

000107139 ( Should suppress first leading zero if i/p rec has 4 zeros)
000107139 ( Should suppress first leading zero if i/p rec has 4 zeros)
000107666A( Should remain intact if i/p rec has 3 zeros)
000107666A( Should remain intact if i/p rec has 3 zeros)

Could you please suggest.

Thanks
Satya
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Apr 29, 2008 3:13 pm    Post subject: Reply with quote

sushma4satya,

What about other conditions when the input has 10,9,8,7,6,5,2,1 zeros ?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sushma4satya
Beginner


Joined: 04 Nov 2005
Posts: 14
Topics: 4

PostPosted: Tue Apr 29, 2008 3:20 pm    Post subject: Reply with quote

The only condition we have is if first 4 bytes in i/p has zeroes then we need to suppress the first leading zero for all other cases then we should not disturb that field.

i/p:

0000107139
0000107139
000107666A
000107666A
1000007888
2000007888

o/p

000107139
000107139
000107666A
000107666A
1000007888
2000007888

Thanks
Satya
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Apr 29, 2008 3:36 pm    Post subject: Reply with quote

sushma4satya,

try the following control cards

Code:

//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'0000',AND,5,1,ZD,NE,0),
       OVERLAY=(1:2,3,5,6,X))                             
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sushma4satya
Beginner


Joined: 04 Nov 2005
Posts: 14
Topics: 4

PostPosted: Wed Apr 30, 2008 10:20 am    Post subject: Reply with quote

Thanks Kolusu..this helped me.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group