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 

Copying a file using SORT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
ramlak
Beginner


Joined: 17 Apr 2007
Posts: 27
Topics: 6

PostPosted: Thu Apr 19, 2007 5:06 pm    Post subject: Copying a file using SORT Reply with quote

Hi,

I am using SORT to copy a file excluding few fields and adding a header from another file,

I need a help in formatting the output using SORT.

Input
LRECL = 1652

There are three fields which repeatedly occur from column 62 to end of record.

Example
1 - 61
xxxxxxxxxxxxxxxxxxx
61-1652
aaaaa bbb cccc aaaaa bbb cccc .......................

is there a simple way to delimit these repeating fields with comma wihtout specifying the whole layout in the OUTREC.

any help appreciated.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Apr 19, 2007 7:19 pm    Post subject: Reply with quote

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

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//RCD DD *
RECORD
//IN DD DSN=...  input file (FB/1652)
//C1 DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//C2 DD DSN=&&C2,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/1652)
//TOOLIN   DD    *
COPY FROM(RCD) TO(C1) USING(CTL1)
COPY FROM(IN) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
  OUTFIL FNAMES=C1,REPEAT=50,BUILD=(X,
    SEQNUM,4,ZD,START=67,INCR=15,C':C'','',',
    SEQNUM,4,ZD,START=71,INCR=15,C':C'','',',
    SEQNUM,4,ZD,START=76,INCR=15,C':C'','',',80:X)
  OUTFIL FNAMES=C2,REPEAT=55,BUILD=(X,
    SEQNUM,4,ZD,START=817,INCR=15,C':C'','',',
    SEQNUM,4,ZD,START=821,INCR=15,C':C'','',',
    SEQNUM,4,ZD,START=826,INCR=15,C':C'','',',80:X)
//CTL2CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1:1,1,
//    DD DSN=*.C1,VOL=REF=*.C1,DISP=(OLD,PASS)
//    DD *
   1:1,1)),
        IFTHEN=(WHEN=INIT,OVERLAY=(1:1,1,
//    DD DSN=*.C2,VOL=REF=*.C2,DISP=(OLD,PASS)
//    DD *
   1642:C',',1646:C','))
/*


If you need other statements (e.g. INCLUDE, SORT), you can put them before INREC in //CTL2CNTL. Change the second COPY operator to a SORT operator if you need a SORT statement.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ramlak
Beginner


Joined: 17 Apr 2007
Posts: 27
Topics: 6

PostPosted: Fri Apr 20, 2007 9:00 am    Post subject: Many Thanks frank....... Reply with quote

Many thanks frank i always admired you and kolusu,
i have been a passive spectator for around 2 years ......
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Apr 20, 2007 10:03 am    Post subject: Reply with quote

I thought of a much easier way to do this if your aaaaa, bbb and cccc variables represent strings without embedded blanks. We can just replace each blank with a comma. Here's the DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/1652)
//SORTOUT DD DSN=...  output file (FB/1652)
//SYSIN DD    *
  OPTION COPY
  ALTSEQ CODE=(406B)
  INREC OVERLAY=(62:62,1589,TRAN=ALTSEQ)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ramlak
Beginner


Joined: 17 Apr 2007
Posts: 27
Topics: 6

PostPosted: Fri Apr 20, 2007 3:18 pm    Post subject: Got a change in the requirement Reply with quote

Thanks once again for ur effort frank,
My requirements are changed now to convert the repeating fileds to
display format , among the recurring field one field is COMP-3 9(4).

i think i should be using TO=ZD ???

Also when we overlay the Comma in the records the comma should not be inserted when it is end of record(end of values).

example ,

even after the record is over the output shows ' , , , ,'

any help ?

i guess doing all this by a program would make it simpler , but i need to know whether all these is possible by JCL ?
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Apr 20, 2007 4:58 pm    Post subject: Reply with quote

I set up the job specifically NOT to put the commas at the end based on what you told me about how the data looks. If the data looks different, then you just need to adjust the positions to account for those last positions. I used 62:62,1589,TRAN=ALTSEQ to avoid putting commas in the last two positions. If you're getting commas past where you want them, then just subtract the number of extra commas from 1589. For example, if you're getting 4 extra commas, change it to 62:62,1585,TRAN=ALTSEQ.

Or for my other job, just adjust the positions to avoid putting commas past where you want them.

COMP-3 9(4) is a 3-byte PD field, so you can use p,3,PD,TO=ZD,LENGTH=n to convert it to ZD where p is the input starting position and n is the output length.

If you have binary or PD values in the recurring fields, the TRAN=ALTSEQ solution problaby won't work because these fields could have embedded X'40' characters.

Conceptually, my other job would work but it wasn't set up to do any conversions because you didn't say you needed to. It would have to be changed based on what your recurring fields actually look like and what you want the output to look like. I don't know exactly what your data looks like, so I can't tell you exactly how to code the job. You should be able to use my job as a model and adjust it for what you need. Just play around with it.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) 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