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 

to identify last record in SORTIN

 
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
kframes
Beginner


Joined: 16 Dec 2007
Posts: 3
Topics: 1

PostPosted: Wed Dec 19, 2007 1:40 am    Post subject: to identify last record in SORTIN Reply with quote

Hi,

I am having the following requirement....

I have to add comma(,) to all records of input file and
I should not add comma(,) to the last record in the input file

Input:
'1111'
'2222'
'3333'
'4444'
'5555'

Output should be:
'1111',
'2222',
'3333',
'4444',
'5555'

Here if we observe.....there is no comma(,) for last record '5555'

May I know whether this can be done using SORT.....

Hope you all understood the requirement....

Thx in advance....
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Dec 19, 2007 1:52 am    Post subject: Reply with quote

kframes,
Try the below code. It puts comma for last record too. You can remove it manually.
Code:
//S1    EXEC  PGM=ICEMAN                       
//SYSOUT    DD  SYSOUT=*                       
//SORTIN DD *                                   
'1111'                                         
'2222'                                         
'3333'                                         
'4444'                                         
'5555'                                         
//SORTOUT DD SYSOUT=*                           
//SYSIN    DD    *                             
  OPTION COPY                                   
  INREC BUILD=(1,80,JFY=(SHIFT=LEFT,TRAIL=C','))
/*                                             


Last edited by vkphani on Wed Dec 19, 2007 2:41 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Wed Dec 19, 2007 2:29 am    Post subject: Reply with quote

kframes,

Quote:

Here if we observe.....there is no comma(,) for last record '5555'


The following job will give u the desired results.

Code:


                       
//S1       EXEC PGM=ICEMAN                                           
//SYSOUT    DD  SYSOUT=*                                             
//SORTIN DD *                                                         
'1111'                                                               
'2222'                                                               
'3333'                                                               
'4444'                                                               
'5555'                                                               
/*                                                                   
//SYM      DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)     
//T1       DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)     
//SYSIN    DD    *                                                   
  OPTION COPY                                                         
  INREC OVERLAY=(07:SEQNUM,2,ZD)                                     
  OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,OUTREC=(80X),         
    TRAILER1=('LAST,+',COUNT=(M11,LENGTH=8))               
  OUTFIL FNAMES=T1                                         
/*                                                         
//S2       EXEC  PGM=SORT                                   
//SYSOUT   DD  SYSOUT=*                                     
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                     
//SORTIN   DD DSN=&&T1,DISP=(OLD,PASS)                     
//SORTOUT DD SYSOUT=*                                       
//SYSIN    DD    *                                         
  OPTION COPY                                               
  INREC BUILD=(1,10,JFY=(SHIFT=LEFT,TRAIL=C','))           
  OUTREC IFTHEN=(WHEN=(07,2,ZD,EQ,LAST),OVERLAY=(09:C' ')) 
  OUTFIL OUTREC=(1,06,9,1)                                 
/*                                                         


_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)


Last edited by vivek1983 on Wed Dec 19, 2007 3:11 am; edited 1 time in total
Back to top
View user's profile Send private message
kframes
Beginner


Joined: 16 Dec 2007
Posts: 3
Topics: 1

PostPosted: Wed Dec 19, 2007 2:30 am    Post subject: Reply with quote

hi vkphani,

Thanks for the info......But I am getting comma for last record also.....for which I shouldn't get....

SDSF OUTPUT DISPLAY UTVT005J JOB00534 DSID 104 LINE 0 COLUMNS 02- 81
COMMAND INPUT ===> SCROLL ===> CSR
********************************* TOP OF DATA *********************************
'1111',
'2222',
'3333',
'4444',
'5555',
******************************** BOTTOM OF DATA *******************************

I shouldn't get comma for last record '5555'
Back to top
View user's profile Send private message
kframes
Beginner


Joined: 16 Dec 2007
Posts: 3
Topics: 1

PostPosted: Wed Dec 19, 2007 2:38 am    Post subject: Reply with quote

hi vivek1983,

Thanks for the solution.....

May I know whether this can be done using single SORT step.....

kumar
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Wed Dec 19, 2007 4:17 am    Post subject: Reply with quote

kframes,

Quote:

May I know whether this can be done using single SORT step.....


Well... The first step is to identify the last record.
I am not able to think of a single step solution.. Maybe we may have to wait for the experts..
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Wed Dec 19, 2007 8:54 am    Post subject: Reply with quote

Looks like you might be building an IN list. Would it be possible to put the comma at the beginning of each record? If you can, then I think you'd be able to use a SKIPREC to not put the comma on the first record. Just a thought.
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: Wed Dec 19, 2007 11:27 am    Post subject: Reply with quote

Kumar,

Vivek is on the right track, but his job is more complex than it has to be. Here's a better version of the DFSORT job. I assumed that 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 DSN=...  input file (FB/80)
//SYM      DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//T1       DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(81:SEQNUM,8,ZD)
  OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,BUILD=(80X),
    TRAILER1=('LASTREC,+',COUNT=(M11,LENGTH=8))
  OUTFIL FNAMES=T1
/*
//S2       EXEC  PGM=SORT
//SYSOUT   DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN   DD DSN=&&T1,DISP=(OLD,PASS)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
        IFTHEN=(WHEN=(81,8,ZD,NE,LASTREC),
          BUILD=(1,80,JFY=(SHIFT=LEFT,TRAIL=C',')))
/*


Quote:
May I know whether this can be done using single SORT step.....


I can't think of a way to do it in one pass.
_________________
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
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Dec 19, 2007 7:07 pm    Post subject: Reply with quote

You are requesting a solution by SORT which is a utility. Why post in the JCL section which is to do with the Job Control Language???
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
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 -> 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