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

Suggest me a way to do this using sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Fri Nov 24, 2006 9:44 pm
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:

Use [URL] BBCode for External Links
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
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 Developer


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

PostPosted: Mon Nov 27, 2006 9:43 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top