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 

Copy only last record
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
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Thu Sep 17, 2009 5:21 am    Post subject: Copy only last record Reply with quote

I have one iput file but I dont know how many records it contain. I just want to copy the last record into another file. Please let me know if there is any simple solution
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 17, 2009 5:55 am    Post subject: Reply with quote

What are your options: Sort, file-aid or anything else?
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 17, 2009 5:59 am    Post subject: Reply with quote

Anyways, here is a way using File-aid:
Code:
//COPYREC  EXEC PGM=FILEAID                                     
//DD01     DD  DSN=...i/p file,DISP=SHR                   
//DD01O    DD  DSN=...o/p file,DISP=(,CATLG,DELETE), 
//             DCB=*.DD01                                       
//SYSIN    DD  *                                                 
$$DD01 COPYBACK OUT=1                                           
//SYSPRINT DD  SYSOUT=*                                         
//SYSOUT   DD  SYSOUT=*                                         
//*

_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 17, 2009 6:10 am    Post subject: Reply with quote

Are you a DFSORT user?

If yes, With z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can use SUBSET to do this kind of thing quite easily like this:
Code:
//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) KEEP INPUT LAST(1)
/*

If you are a SyncSort user, you need to tell us what version of it is in use at your shop?
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Thu Sep 17, 2009 6:50 am    Post subject: Reply with quote

Thanks anuj for your replies.
I tried the ICETOOL job given by you it is throwing following error.

Code:
ICE630I 0 MODE IN EFFECT:  STOP                                     
                                                                   
          SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST                   
          $                                                         
ICE614A 0 INVALID OPERATOR                                         
ICE602I 0 OPERATION RETURN CODE:  12                               
                                                                   
                                                                   
ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE:  12 


Is this possible through DFSORT.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 17, 2009 9:53 am    Post subject: Reply with quote

Hi Madhu,

From my previous post,
Quote:
Are you a DFSORT user? If yes, With z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can use SUBSET to do this...:
so to answer your question
Quote:
Is this possible through DFSORT.
yes, you can achieve this with DFSORT but you need to have the respective PTF to use the posted JCL there.

The messages you post tells that your shop does not have that PTF installed. You may ask your system programmers to install that, it's free.
_________________
Regards,
Anuj


Last edited by Anuj Dhawan on Thu Sep 17, 2009 11:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 17, 2009 10:05 am    Post subject: Reply with quote

Hi Madhu,

Did you try the file-aid solution, by the way?
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 17, 2009 10:08 am    Post subject: Reply with quote

For an alternate solution you can check this earlier thread.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Sep 17, 2009 2:47 pm    Post subject: Reply with quote

psmadhusudhan,

If your intention is to copy just the last record then it is very simple with subset , but since you dont have the latest ptf installed here is another solution

Code:

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=your input file lrecl GT 256,DISP=SHR
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                 
  SORT FIELDS=COPY               
  OUTFIL REMOVECC,NODETAIL,TRAILER1=(1,n)
//*
//* n = your lrecl


If you have a file which has lrecl greater than 256, then you need to split the output record into chunks of 256 bytes on trailer1

Code:

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=your input file lrecl LE 256,DISP=SHR
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                 
  SORT FIELDS=COPY               
  OUTFIL REMOVECC,NODETAIL,TRAILER1=(1,256,257,256,513,256,...n)
//*
//* n = your lrecl

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


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu Sep 17, 2009 11:27 pm    Post subject: Reply with quote

Hi Kolusu,

Why there is a check on LRECL, as you say here:
kolusu wrote:
If you have a file which has lrecl greater than 256, then you need to split the output record into chunks of 256 bytes on trailer1
and why LRECL=256 is a concern?
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Thu Sep 17, 2009 11:36 pm    Post subject: Reply with quote

Anuj Dhawan, max length that a TRAILER can take is only 255.
Extarct from Quick Ref
Code:
For a TRAILER1, the field(s) will be extracted from the  last record in a file; for a TRAILER2, the field(s)  will be extracted from the last record on a page; for a TRAILER3, the field(s) will be extracted from the last record in a section. p is the starting position of the field in the record; [b]l is the length in bytes (1-255) [/b]of the field. Any number of fields can be specified. (Contiguous fields within a record may be specified with a single p, l entry, but their combined length may not exceed 255 bytes.) The specified field(s) should be a character or alphanumeric string, or a number in printable format, and the field cannot be converted or edited.

_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Fri Sep 18, 2009 12:06 am    Post subject: Reply with quote

I see. Out of curiosity, why do they make such a restriction to use maximum length as 255?
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Fri Sep 18, 2009 12:16 am    Post subject: Reply with quote

kolusu,
I have tried your solution it is working. Thank you very much.

Out of curiosity I have one question, How to copy all records except last reord, even in this case I dont know no of records in input file. Please dont mind in replying if you know the solution.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Fri Sep 18, 2009 12:59 am    Post subject: Reply with quote

Hi Madhu,

You're asking a lot of questions in a single thread. You could start a new thread for that. Smile

Well, 'gain with z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can use SUBSET to do this:
Code:
//STEP1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//INDD DD DSN= INPUT FILE
//OUTDD DD DISP=OUTPUT FILE
//TOOLIN DD *
   SUBSET FROM (INDD) TO (OUTDD) REMOVE INPUT LAST
/*

But as you say that's not availabe at your shop -- you can use the technique described in the "Keep or remove the first and/or last records
" Smart DFSORT Trick at: www.ibm.com/systems/support/storage/software/sort/mvs/tricks/
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Fri Sep 18, 2009 1:18 am    Post subject: Reply with quote

Without that PTF UK90013, try this:
Code:
//S1      EXEC  PGM=ICEMAN                                         
//SYSOUT  DD  SYSOUT=*                                             
//SORTIN  DD DSN=...i/p  (LRECL=80)
//C1      DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)     
//SYSIN   DD    *                                                   
  OPTION COPY                                                       
  OUTFIL FNAMES=C1,REMOVECC,NODETAIL,                               
    BUILD=(80X),                                                   
    TRAILER1=(' OPTION COPY,SKIPREC=0,',                           
     'STOPAFT=',COUNT-1=(M11,LENGTH=8))                             
/*                                                                 
//S2      EXEC  PGM=ICEMAN                                         
//SYSOUT  DD  SYSOUT=*                                             
//SORTIN  DD DSN=...i/p  (LRECL=80)
//SORTOUT DD DSN=...o/p  (LRECL=80),DISP=(NEW,CATLG,DELETE)
//SYSIN   DD DSN=&&C1,DISP=(OLD,PASS)

_________________
Regards,
Anuj
Back to top
View user's profile Send private message
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