how to read and write only first & last records of a fil

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

how to read and write only first & last records of a fil

Post by Subha » Mon Jul 11, 2011 12:57 pm

Hi,

How to read only first & last records of a file and write first 8 characters of first, last records into output file.

Its urgent, someone pls help. Thanks.

Input:

Code: Select all

20110625  a  CMNSTARTSUBSYS                                           
20110625  mÅ  BAACMHK AHJC019335Staging libraries have been aged       
20110625  mg  BAACMHK AHJC019335Staging libraries have been deleted    
20110625  ë À  BAACMHK ECSC000047Package has been aged                  
20110625  ë a  BAACMHK ECSC000047Package has been deleted               
20110625  ëí  BAACMHK ECSC000049Package has been aged                  
20110702  Ál  S1XSUD1 ESC6000267Activate RWBGBD51.LOD                  
20110702  øè  S1XSUD1 ESC6000267Activate RWBGBD51.PKG                  
20110702  È  S1XSUD1 ESC6000267Activate RWBGBD51.DBR                  
20110702  Ä  S1XSUD1 ESC6000267Activate RWBGBD51.LST                  
20110702  é  CMNSTARTSUB                                              

Output:

Code: Select all

20110625 20110702

It will be even great, if output comes as below.

Code: Select all

20110625 TO 20110702
or

Code: Select all

20110625 - 20110702
Thanks,
Subha

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Jul 11, 2011 9:54 pm

You can use a DFSORT/ICETOOL job like the following to do what you asked for:

Code: Select all

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) INPUT KEEP FIRST LAST USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,1),PUSH=(13:1,8,21:SEQ=8))
  OUTFIL INCLUDE=(21,8,ZD,NE,1),
    BUILD=(13,8,C' TO ',1,8,80:X)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

Post by Subha » Tue Jul 12, 2011 11:41 am

Thanks Frank. But this did not work for me, Can you pls advise where is it going wrong?

Here is the DFSMSG log.

Code: Select all

ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0001                               
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 07:58 ON TUE JU
            INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,1),PUSH=(13:1,8,21:SEQ=8))     
                                     £                                          
ICE006A 0 OPERAND DEFINER ERROR                                                 
            OUTFIL INCLUDE=(21,8,ZD,NE,1),                                      
              BUILD=(13,8,C' TO ',1,8,80:X)                                     
ICE146I 0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW    
          DEBUG NOABEND,ESTAE                                                   
          OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTDD=CTL1,SORTIN=IN,SO
                         TOUT=OUT,DYNALLOC,EQUALS,NOCHECK,COPY                  
          OMIT COND=ALL                                                         
          OUTFIL FNAMES=OUT                                                     
ICE751I 0 C5-K51707 C6-K51707 C7-K54603 C8-K51707 E7-K51707                     
ICE052I 3 END OF DFSORT                                                         

Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

Post by Subha » Tue Jul 12, 2011 11:49 am

Also, Is it possible to get output as below?

Code: Select all

20110625 TO 20110702  CHGMAN3
Note: CHGMAN3 should start at column 23.

Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

Post by Subha » Tue Jul 12, 2011 2:20 pm

Frank,

If the error is because of that I dont have DFSORT R14 PTF UQ95213 (Dec, 2004) to use DFSORT's new IFTHEN function then can you please suggest someother way to get the output?

coz, this is urgent and may not be able to wait for PTF installation. Also, please suggest how to install PTF, I will try to get this done.

Thanks.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Jul 12, 2011 10:23 pm

The only PTF you are missing is the Oct, 2010 PTF, but you need that to use KEYBEGIN. Ask your System Programmer to install z/OS DFSORT V1R10 PTF UK90025.

Here's a DFSORT job that will do what you want without using KEYBEGIN:

Code: Select all

//S1    EXEC  PGM=ICETOOL 
//TOOLMSG DD SYSOUT=* 
//DFSMSG  DD SYSOUT=* 
//IN DD DSN=... input file 
//OUT DD DSN=...  output file 
//TOOLIN DD * 
SUBSET FROM(IN) TO(OUT) INPUT KEEP FIRST LAST USING(CTL1) 
/* 
//CTL1CNTL DD * 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:SEQNUM,8,ZD)),           
    IFTHEN=(WHEN=GROUP,BEGIN=(21,8,ZD,EQ,1),PUSH=(13:1,8))     
  OUTFIL INCLUDE=(21,8,ZD,NE,1),                               
    BUILD=(13,8,C' TO ',1,8,23:C'CHGMAN3',80:X)                
/* 
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

Post by Subha » Thu Jul 14, 2011 11:24 am

i got below error. Please suggest what could be the problem.

Code: Select all

ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0001                               
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 07:48 ON THU JU
            INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:SEQNUM,8,ZD)),                  
              IFTHEN=(WHEN=GROUP,BEGIN=(21,8,ZD,EQ,1),PUSH=(13:1,8))            
            OUTFIL INCLUDE=(21,8,ZD,NE,1),                                      
              BUILD=(13,8,C' TO ',1,8,23:C'CHGMAN3',80:X)                       
ICE146I 0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW    
          DEBUG NOABEND,ESTAE                                                   
          OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTDD=CTL1,SORTIN=IN,SO
                         TOUT=OUT,DYNALLOC,EQUALS,NOCHECK,COPY                  
          OMIT COND=ALL                                                         
          OUTFIL FNAMES=OUT                                                     
ICE201I G RECORD TYPE IS V - DATA STARTS IN POSITION 5                          
ICE251A 9 MISSING RDW OR DATA FOR OUT     : REASON CODE 03, IFTHEN 0            
ICE751I 0 C5-K51707 C6-K51707 C7-K54603 C8-K51707 E9-K51707 E7-K51707           
ICE052I 3 END OF DFSORT                                                         
I think the error is something to do with record format.

Attributes of input file:

Code: Select all

Management class . . : X000N395 
Storage class  . . . : SCTMM    
  Volume serial . . . : EWRK73 + 
  Device type . . . . : 3390     
Data class . . . . . : DCTMM    
  Organization  . . . : PS       
  Record format . . . : VB       
 Record length . . . : 5000     
 Block size  . . . . : 27998    
  1st extent megabytes: 1        
 Secondary megabytes : 50       
 Data set name type  :          
 SMS Compressible. . : NO       
Attributes of output file:

Code: Select all

Management class . . : X999N002
Storage class  . . . : SCTSO   
 Volume serial . . . : ETSO03  
 Device type . . . . : 3390    
Data class . . . . . : DCNORMAL
 Organization  . . . : PS      
 Record format . . . : FB      
 Record length . . . : 163     
  Block size  . . . . : 16300   
 1st extent tracks . : 45      
 Secondary tracks  . : 30      
 Data set name type  :         
 SMS Compressible. . : NO      
[/b][/u]

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Jul 14, 2011 9:45 pm

You should have mentioned the input and output attributes earlier. It makes a difference.

Here's a DFSORT job for those attributes:

Code: Select all

//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (VB/5000)
//OUT DD DSN=...  output file (FB/163)
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) INPUT KEEP FIRST LAST USING(CTL1)
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,12,21:SEQNUM,8,ZD)),
      IFTHEN=(WHEN=GROUP,BEGIN=(21,8,ZD,EQ,1),PUSH=(13:5,8))
  OUTFIL INCLUDE=(21,8,ZD,NE,1),VTOF,
    BUILD=(13,8,C' TO ',5,8,C'  CHGMAN3',163:X)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

Post by Subha » Fri Jul 15, 2011 5:15 pm

I did not observe the difference in the attributes.

Anyway, thanks a lot for all your help. You are genious, I must say.

Thanks again.

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 10:00 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others