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 

Variable lentgh file - sort
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Wed Feb 11, 2009 5:03 am    Post subject: Variable lentgh file - sort Reply with quote

Hi,

I've a scenario where I need to create a output file either by program or through JCL. I know that we can do it through SORT. But not sure how to do it. Please help me how to do it. If possible sample sort steps.

The requirement is as below
Quote:

I need to read in a client control card and extract all records where the first 2 positions of the file uto.cb160s01.cycrpt(0) which is variable length file , equal the company's in the client control card. The output file needs to be variable length.


Thanks
Nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Feb 11, 2009 9:46 am    Post subject: Reply with quote

nadh,

You can generate an INCLUDE COND from the client control card and extract records from the gdg as shown below

Code:

//STEP0100 EXEC PGM=ICEMAN                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
XX                                                     
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN    DD *                                             
  OPTION COPY,STOPAFT=1                                     
  OUTFIL BUILD=(C' SORT FIELDS=COPY',/,
                C' INCLUDE COND=(5,2,CH,EQ,C''',1,2,C''')',80:X)
//*                     
//STEP0200 EXEC PGM=ICEMAN                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=your VB file,
//            DISP=SHR
//SORTOUT  DD DSN=your output vb file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD DSN=&&T1,DISP=SHR 
//*

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Wed Feb 11, 2009 10:15 am    Post subject: Reply with quote

Thankyou Kolusu,

Unfortunatly we can't use ICEMAN in our project. Can I use this code using SORT?
Do I need to change anything in the above code to use sort?

Thanks
Nadh.
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Wed Feb 11, 2009 10:53 am    Post subject: Reply with quote

Sigh. PGM=ICEMAN and PGM=SORT are equivalent. Both call your sort product. You can change PGM=ICEMAN to PGM=SORT if you like, but it will work exactly the same.
_________________
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
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Wed Feb 11, 2009 11:24 am    Post subject: Reply with quote

Thankyou.

I've one doubt..
Code:

OUTFIL BUILD=(C' SORT FIELDS=COPY',/,
                C' INCLUDE COND=(5,2,CH,EQ,C''',1,2,C'''',80:X)
- do i need to add one ')' here?
what is the use of 80:X in this.
do i need to give client control card in place of
Code:

//SORTIN   DD *                                             
XX...


Thanks
Nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Feb 11, 2009 11:42 am    Post subject: Reply with quote

nadh wrote:
Thankyou.

I've one doubt..
Code:

OUTFIL BUILD=(C' SORT FIELDS=COPY',/,
                C' INCLUDE COND=(5,2,CH,EQ,C''',1,2,C'''',80:X)
- do i need to add one ')' here?
what is the use of 80:X in this.


Nadh,

Please copy the control cards carefully. You don't need the ')' as we are creating it in the control card itself. For DFSORT SYSIN data set must be defined with a RECFM of F or FB. The LRECL can be 80, or more (when valid). If the LRECL is greater than 80, DFSORT will use the first 80 bytes of each record. 80:X will create a byte file padding with spaces upto 80 bytes.

Quote:

do i need to give client control card in place of
Code:

//SORTIN   DD *                                             
XX...



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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Fri Feb 13, 2009 2:00 am    Post subject: Reply with quote

Thankyou verymuch Kolusu.

I tested it today after I got input dataset. It worked wonderfully. But Client Control card changed. Now it will be like
Quote:

##sample01 11
##sample01 09

Number of rows in control card will be variable. I need to extract all the records from the input file where first 2 positions are equal to 11 and 09....to output file.

Please provide what changes do I need to do in sysin cards to do this.

Thanks
Nadh.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Feb 13, 2009 11:21 am    Post subject: Reply with quote

nadh,

The following DFSORT JCl will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
##SAMPLE01 11                                               
##SAMPLE01 09                                               
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)   
//SYSIN    DD *                                             
  OPTION COPY                                               
  OUTFIL REMOVECC,                                           
    HEADER1=(' OPTION COPY',/,                               
             ' INCLUDE COND=(1,1,CH,NE,1,1,CH,OR,'),         
    BUILD=(15X,C'5,2,CH,EQ,C''',12,2,C''',OR,',80:X),       
    TRAILER1=(15X,'1,1,CH,NE,1,1,CH)')                       
/*                                                 
//STEP0200 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=your VB file,
//            DISP=SHR
//SORTOUT  DD DSN=your output vb file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD DSN=&&T1,DISP=SHR
//*

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Thu Feb 19, 2009 2:48 pm    Post subject: Reply with quote

Amazing Kolusu,

It worked wonderfuly. Thankyou so much. Could you please tell what is the use of 15X.
Kolusu there is a little change, now I need to extract all the records where the first 2 positions of the i/p file are equal to '01' or '09' and where position 3 and 4 are equal to the companys in the client control card. Also I need to include the header record in the input file which will have low values in position 1 and 2.
Sample data in input file is as below...
Quote:

.................................TXR19090219
0111IN098886 0000010...................................
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Feb 19, 2009 3:56 pm    Post subject: Reply with quote

nadh,

Use the following DFSORT JCL.

Code:

//STEP0100 EXEC  PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
##SAMPLE01 11                                                   
##SAMPLE01 09                                                   
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)     
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  OUTFIL REMOVECC,                                             
    HEADER1=(' OPTION COPY',/,                                 
             ' INCLUDE COND=(5,2,CH,EQ,X''','0000''',',OR,',/, 
             14X,'(5,2,SS,EQ,C''','01,09''',',AND,'),           
    BUILD=(15X,C'5,2,CH,EQ,C''',12,2,C''',OR,',80:X),           
    TRAILER1=(15X,'1,1,CH,NE,1,1,CH))')                         
/*                                                             
//STEP0200 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=your VB file,
//            DISP=SHR
//SORTOUT  DD DSN=your output vb file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD DSN=&&T1,DISP=SHR
//*



Quote:

Thankyou so much. Could you please tell what is the use of 15X.


Just to align the control cards.Look at the sysout from step0200 and you will see the generated control cards.

Code:

 INCLUDE COND=(5,2,CH,EQ,X'0000',OR,   
              (5,2,SS,EQ,C'01,09',AND,
               5,2,CH,EQ,C'11',OR,     
               5,2,CH,EQ,C'09',OR,     
               1,1,CH,NE,1,1,CH))       


if you see the first line which has include cond and the seconds lines don't have anything. So just to align and better readability, I padded the second record onwards with 15 spaces so that p,m,f,eq are all aligned together

Without 15x it would look like this.I don't like this kind of formating
Code:

 INCLUDE COND=(5,2,CH,EQ,X'0000',OR,     
 (5,2,SS,EQ,C'01,09',AND,   
 5,2,CH,EQ,C'11',OR,       
 5,2,CH,EQ,C'09',OR,       
 1,1,CH,NE,1,1,CH))         

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Fri Feb 20, 2009 1:57 am    Post subject: Reply with quote

Hi Kolusu,

Thankyou verymuch. The above code is working but its only retriving the records which are having only 09 in input file. I need to extract the records which are having 01 in input file. Please help me out. what is the use of SS in include condition.

Thanks & Regards
Nadh
Back to top
View user's profile Send private message Send e-mail
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Fri Feb 20, 2009 3:29 am    Post subject: Reply with quote

Hi Kolusu,

I have corrected
Quote:

5,2,CH,EQ,C'11',OR,
5,2,CH,EQ,C'09',OR,


to
Quote:

7,2,CH,EQ,C'11',OR,
7,2,CH,EQ,C'09',OR,

since position 3 and 4 should be equal to client control card values.

But still its extracting other records too which are having client control characters in records in position 3and4 in input file. Please help me out.

Thanks & Regards
nadh
Back to top
View user's profile Send private message Send e-mail
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Fri Feb 20, 2009 4:10 am    Post subject: Reply with quote

Hi Kolusu,

Here is the problem.
Quote:

(5,2,CH,EQ,X'0000',OR,
(5,2,SS,EQ,C'01,09',AND,
7,2,CH,EQ,C'11',OR,
7,2,CH,EQ,C'09',OR,
1,1,CH,NE,1,1,CH))

in this one
Quote:

7,2,CH,EQ,C'09',OR,

because of this its extracting all the records having equivalent data in 3,4 (7,2) which is equivalent to client control card.

Quote:

5,2,CH,EQ,X'0000',OR,
(5,2,SS,EQ,C'01,09',AND,
(7,2,CH,EQ,C'11',OR,
7,2,CH,EQ,C'09'),OR,
1,1,CH,NE,1,1,CH))

If this comes in this format I think it will work. Please help me out.

Thanks
Nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Feb 20, 2009 11:21 am    Post subject: Reply with quote

nadh,

*Sigh* Why do you keep posting the same question as a new topic? I am going to delete the other topic.

use the control cards as is

Code:

//SYSIN    DD *                                                 
  OPTION COPY                                                   
  OUTFIL REMOVECC,                                             
    HEADER1=(' OPTION COPY',/,                                 
             ' INCLUDE COND=(5,2,CH,EQ,X''','0000''',',OR,',/, 
             14X,'(5,2,SS,EQ,C''','01,09''',',AND,'),           
    BUILD=(15X,C'7,2,CH,EQ,C''',12,2,C''',OR,',80:X),           
    TRAILER1=(15X,'1,1,CH,NE,1,1,CH))')                         
/*                                                             


this will generate the following cards

Code:

OPTION COPY                           
INCLUDE COND=(5,2,CH,EQ,X'0000',OR,   
             (5,2,SS,EQ,C'01,09',AND, 
              7,2,CH,EQ,C'11',OR,     
              7,2,CH,EQ,C'09',OR,     
              1,1,CH,NE,1,1,CH))       

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Sat Feb 21, 2009 10:30 am    Post subject: Reply with quote

Hi

Thankyou Kolusu. I've tried with that code. But still its giving all the records which are having '09' in 3,4 positions. I should extract all the records which are having either 01 or 09 in position 1,2 and having 3,4 positions equal to client control card. If 3,4 positions are equal to client control card and 1,2 positions are not equal to 01 or 09 then that record should not be extracted. The above INCLUDE COND is acting as its retriving all the records having 01 or 09 in positons 1,2 and having 11 in position 3,4 and its retriving all the records having 09 in positions 3,4 irrespective of values in position 1,2. Please help me out.

Thanks
Nadh.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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