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
 

 

Suggest me a way to do this using sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
prasanth_bs

New User


Joined: 08 Aug 2005
Posts: 9

PostPosted: Fri Nov 24, 2006 5:34 pm    Post subject: Suggest me a way to do this using sort
Reply with quote

Hi,

I am having a requirement like below

My input file is like this


Input file

ASCC 1234567890
ASDD 12345678970
ASDC 123456789870

And i want my output file to be

Output file

ASCC 0,0,12345,67890
ASDD 0,1,23456,78970
ASDC 1,2,34567,89870


My second field starts from position 9 if the length of the field is only 10 then i want to pad two
zeroes to the left.If length of the second field is 11 then i want to pad only one zero and if the length of field is 12 keep it as such and i want to put commas as shown in the example

Could you please suggest me a way to do this using sort
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Nov 24, 2006 9:44 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
ASCC    1234567890
ASDD    12345678970
ASDC    123456789870
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(9:9,15,UFF,EDIT=(T,T,TTTTT,TTTTT))
/*


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
prasanth_bs

New User


Joined: 08 Aug 2005
Posts: 9

PostPosted: Mon Nov 27, 2006 11:25 am    Post subject: Re: Suggest me a way to do this using sort
Reply with quote

Actually my requirement is like this

I am having an input file of the following format

File1

918100030,9153028018,10.89,2.92,13.39,0,0,0,0,0,0
918103030,19153028018,10.89,2.92,13.39,0,0,0,0,0,0
918100730,139153028018,10.89,2.92,13.39,0,0,0,0,0,0

Output file

918100030,0,0,91530,28018,10.89,2.92,13.39,0,0,0,0,0,0
918103030,0,1,91530,28018,10.89,2.92,13.39,0,0,0,0,0,0
918100730,1,3,91530,28018,10.89,2.92,13.39,0,0,0,0,0,0


ie, my second field length can be either 10,11 or 12,.If the second field is of length 10 i want to append 2 zeroes in left serperated by commas as shown in output file first record ie, if second field is 9153028018 then in my output file it should come as 0,0,91530,28018

If the second field is of length 11 i want to append 1 zeroes in left serperated by commas as shown in output file first record ie, if second field is 19153028018 then in my output file it should come as 0,1,91530,28018

If the second field is of length 12 my output file should be ie, if second field is 139153028018 then in my output file it should come as 1,3,91530,28018


could you please suggest me a way for doing this

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

DFSORT Moderator


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

PostPosted: Mon Nov 27, 2006 9:43 pm    Post subject:
Reply with quote

Here's a DFSORT job that will 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=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
918100030,9153028018,10.89,2.92,13.39,0,0,0,0,0,0
918103030,19153028018,10.89,2.92,13.39,0,0,0,0,0,0
918100730,139153028018,10.89,2.92,13.39,0,0,0,0,0,0
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=(21,1,CH,EQ,C','),
    BUILD=(1,10,C'0,0,',11,5,C',',16,34)),
   IFTHEN=(WHEN=(22,1,CH,EQ,C','),
    BUILD=(1,10,C'0,',11,1,C',',12,5,C',',17,34)),
   IFTHEN=(WHEN=(23,1,CH,EQ,C','),
    BUILD=(1,10,11,1,C',',12,1,C',',13,5,C',',18,34))
/*
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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


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