Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Copy data from one file to other using SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
sreekanth1984

New User


Joined: 23 Mar 2010
Posts: 22
Location: Bangalore

PostPosted: Tue Nov 09, 2010 3:03 pm    Post subject: Copy data from one file to other using SORT
Reply with quote

Hi,

I have a requirement where I need to copy data from one flat file other flat file using SORT statement. Before copying the data I have to check record count in the input file. If the record count is greater than 1 then I should copy data from input file to output file.I could get the record count using SEQNUM, but I am not able to compare the count with 1. Please provide me sort steps to acheive this.

Please let me know any details required.
Thanks
Srikanth
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 09, 2010 3:11 pm    Post subject:
Reply with quote

only detail i would like to have is
why did you not search the forum?

this type of thing (actually exact requirement)
has been discussed before,
since the originating process did not delete the file in the first place.

one question: what kind of output file are you to have if there is only 1 record in the input file?
Back to top
View user's profile Send private message
sreekanth1984

New User


Joined: 23 Mar 2010
Posts: 22
Location: Bangalore

PostPosted: Tue Nov 09, 2010 3:19 pm    Post subject:
Reply with quote

This requirement is posted only after extensive search is done in the forum....

And for the question raised, in case of input file contain only one record I don't want to write anything to output file.

Thanks
Srikanth
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 09, 2010 3:21 pm    Post subject:
Reply with quote

our definitions of 'extensive' differ.
Back to top
View user's profile Send private message
sreekanth1984

New User


Joined: 23 Mar 2010
Posts: 22
Location: Bangalore

PostPosted: Tue Nov 09, 2010 3:39 pm    Post subject:
Reply with quote

Can anyone please provide solution for this.....?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Nov 09, 2010 3:45 pm    Post subject:
Reply with quote

You can use IDCAMS to determine if two or more records exist in the file, and then conditionally execute the sort step to perform the copy.

Not sure if your sort product will be able to do this in just one step, but then we do not know the sort product or release level that is installed at your site.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Nov 09, 2010 3:51 pm    Post subject: Reply to: Copy data from one file to other using SORT
Reply with quote

Quote:
Can anyone please provide solution for this.....?


the previous identical post was deleted because it is considered uneducated behavior
to solicit for solutions after half an hour from the initial post


remember also the Frank and Kolusu work in a different time zone
so You cannot expect them to get up at three in the morning to answer Your question
Back to top
View user's profile Send private message
sreekanth1984

New User


Joined: 23 Mar 2010
Posts: 22
Location: Bangalore

PostPosted: Tue Nov 09, 2010 4:00 pm    Post subject:
Reply with quote

Thanks Expact, I could do this using IDCAMS. Through IDCAMS I could check for input file is empty or not. But I want to check no. of records in the file for specific count like if the no. of records in the input file is 5 then I should copy data from input file to output file. Hence I looking for the SORT card to accomplish this...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Nov 09, 2010 4:13 pm    Post subject: Reply to: Copy data from one file to other using SORT
Reply with quote

Quote:
This requirement is posted only after extensive search is done in the forum....
36_2_35.gif

a quick and dirty search with sort record count just gave back
and the search was not extensive at all
http://ibmmainframes.com/viewtopic.php?t=48624&highlight=sort+record+count
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Nov 09, 2010 11:30 pm    Post subject:
Reply with quote

sreekanth1984,

use the following DFSORT JCL. The first step sets a return code of 4 if there is just 1 record and return code of 0 if it has more than 1 record. The second step actually copies the file based on the return code.

Code:

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=Your input file,DISP=SHR
//SORTOUT  DD DUMMY                       
//SYSIN    DD *                           
  OPTION COPY                             
  OUTFIL NULLOFL=RC4,STARTREC=2,ENDREC=2   
//*                                       
//STEP0200 EXEC PGM=SORT,COND=(4,EQ,STEP0100)   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=Your input file,DISP=SHR
//SORTOUT  DD SYSOUT=*     
//SYSIN    DD *             
  OPTION COPY               
//*
Back to top
View user's profile Send private message
sreekanth1984

New User


Joined: 23 Mar 2010
Posts: 22
Location: Bangalore

PostPosted: Wed Nov 10, 2010 10:28 am    Post subject:
Reply with quote

Thanks Skolusu. I have run the JCL mentioned for different input files containing single record, more than one record and for some empty files. In each case STEP0100 is executing with cond code 000. step0200 is executing in all the cases as condition mentioned is false and copying all the input records to output reocrds.

I have mentione Output file in the SORTOUT statement of STEP0200, which was SYSOUT=* in the JCL provided by you.

The JCL provided is not serving my requirement.

Please let me know for any corrections.

Thanks
Srikanth
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Nov 10, 2010 10:52 am    Post subject:
Reply with quote

Hello,

Post all of the informational messages including message ids for a run that does not do what you want.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Nov 10, 2010 10:33 pm    Post subject:
Reply with quote

sreekanth1984 wrote:
Thanks Skolusu. I have run the JCL mentioned for different input files containing single record, more than one record and for some empty files. In each case STEP0100 is executing with cond code 000. step0200 is executing in all the cases as condition mentioned is false and copying all the input records to output reocrds.

I have mentione Output file in the SORTOUT statement of STEP0200, which was SYSOUT=* in the JCL provided by you.

The JCL provided is not serving my requirement.

Please let me know for any corrections.

Thanks
Srikanth


The provided job works exactly as you described the requirement. If the file is empty or has just 1 record , step0100 will issue an RC of 4. If it is not working then you need to show me the SYSOUT of step0100 to prove that. Show me the complete sysout of step0100.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Nov 11, 2010 9:25 am    Post subject:
Reply with quote

Hi Kolusu,

I noticed with your example that you are reading the entire file to identify whether more than 1 record exists in the input file, ie. if the file has millions of records there seems to be many unnecessary reads.

Would this be a better option



Code:
//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
//SORTOUT  DD DUMMY                                 
//SYSIN    DD *                                     
    OPTION COPY,SKIPREC=1,STOPAFT=1                 
    OUTFIL NULLOFL=RC4                             
//*                                                 
//STEP0200 EXEC PGM=SORT,COND=(4,EQ,STEP0100)       
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                     
  OPTION COPY                                       
//*                                                 


Gerry
Back to top
View user's profile Send private message
sreekanth1984

New User


Joined: 23 Mar 2010
Posts: 22
Location: Bangalore

PostPosted: Thu Nov 11, 2010 9:53 am    Post subject:
Reply with quote

JCL used:

In the previous post I have given STARTREC=1,ENDREC=200 which is changed as STARTREC=2,ENDREC=2 and the outputs are below.

Apologies for incorrect data provided in the previous post.

Code:
//STEP1    EXEC PGM=SORT                                           
//SYSPRINT DD  SYSOUT=*                                             
//SYSOUT   DD  SYSOUT=*                                             
//SORTIN   DD  DISP=SHR,DSN=Input file
//SORTOUT  DD  DUMMY                                               
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  OUTFIL NULLOFL=RC4,STARTREC=2,ENDREC=2                         
//*                                                                 
//STEP2    EXEC PGM=SORT,COND=(4,EQ,STEP1)                         
//SYSOUT   DD  SYSOUT=*                                             
//SORTIN   DD  DISP=SHR,DSN=Input file
//SORTOUT  DD   DISP=SHR,DSN=Output file
//SYSIN    DD *                                                     
  OPTION COPY                                                       


System messages for case 1, if the file is empty.

Code:

ICH70001I H27840   LAST ACCESS AT 05:00:01 ON THURSDAY, NOVEMBER 11, 2010       
IEF236I ALLOC. FOR H2784090 STEP1                                               
IEF237I JES2 ALLOCATED TO SYSPRINT                                             
IEF237I JES2 ALLOCATED TO SYSOUT                                               
IGD103I SMS ALLOCATED TO DDNAME SORTIN                                         
IEF237I DMY  ALLOCATED TO SORTOUT                                               
IEF237I JES2 ALLOCATED TO SYSIN                                                 
IEF142I H2784090 STEP1 - STEP WAS EXECUTED - COND CODE 0000                     
IEF285I   H27840.H2784090.JOB05382.D0000103.?          SYSOUT                   
IEF285I   H27840.H2784090.JOB05382.D0000104.?          SYSOUT                   
IGD104I Input file       RETAINED,  DDNAME=SORTIN   
IEF285I   H27840.H2784090.JOB05382.D0000101.?          SYSIN                   
IEF373I STEP/STEP1   /START 2010315.0501                                       
IEF374I STEP/STEP1   /STOP  2010315.0501 CPU    0MIN 00.02SEC SRB    0MIN 00.00S
IEF236I ALLOC. FOR H2784090 STEP2                                               
IEF237I JES2 ALLOCATED TO SYSOUT       
IGD103I SMS ALLOCATED TO DDNAME SORTIN                                         
IGD103I SMS ALLOCATED TO DDNAME SORTOUT                                         
IEF237I JES2 ALLOCATED TO SYSIN                                                 
IEF142I H2784090 STEP2 - STEP WAS EXECUTED - COND CODE 0000                     
IEF285I   H27840.H2784090.JOB05382.D0000105.?          SYSOUT                   
IGD104I Input file      RETAINED,  DDNAME=SORTIN   
IGD104I Output file      RETAINED,  DDNAME=SORTOUT 
IEF285I   H27840.H2784090.JOB05382.D0000102.?          SYSIN                   
IEF373I STEP/STEP2   /START 2010315.0501                                       
IEF374I STEP/STEP2   /STOP  2010315.0501 CPU    0MIN 00.03SEC SRB    0MIN 00.00S
IEF375I  JOB/H2784090/START 2010315.0501                                       
IEF376I  JOB/H2784090/STOP  2010315.0501 CPU    0MIN 00.05SEC SRB    0MIN 00.00S                                         



Sysout of step1:
Code:

SYNCSORT FOR Z/OS  1.3.2.0R    U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCSO
                                                      z/OS   1.10.0           
SYNCSORT LICENSED FOR IBM  GMBH                                LICEN
SYSIN :                                                                       
  OPTION COPY                                                                 
  OUTFIL NULLOFL=RC4,STARTREC=2,ENDREC=2                                     
WER108I  SORTIN   : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
WER110I  SORTOUT  : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
WER405I  SORTOUT  :  DATA RECORDS OUT          0; TOTAL RECORDS OUT          0
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 
WER054I  RCD IN          0, OUT          0                                     
WER169I  RELEASE 1.3 BATCH 0487 TPF LEVEL 2.0                                 
WER052I  END SYNCSORT - H2784090,STEP1,,DIAG=A800,728E,8084,004C,E07A,4C83,02C8


SYSOUT of STEP2
Code:

 SYNCSORT FOR Z/OS  1.3.2.0R    U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCSO
                                                       z/OS   1.10.0           
 SYNCSORT LICENSED FOR IBM DEUTSCHLAND GMBH                                LICEN
 SYSIN :                                                                       
   OPTION COPY                                                                 
 WER108I  SORTIN   : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
 WER110I  SORTOUT  : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 
 WER246I  FILESIZE 0 BYTES                                                     
 WER169I  RELEASE 1.3 BATCH 0487 TPF LEVEL 2.0                                 
 WER052I  END SYNCSORT - H2784090,STEP2,,DIAG=8A00,D180,A295,6C7F,C37A,6C8B,2240


For the case 2 if the file contains more than one record.
JESYSMSG

Code:

ICH70001I H27840   LAST ACCESS AT 04:16:43 ON THURSDAY, NOVEMBER 11, 2010       
IEF236I ALLOC. FOR H2784090 STEP1                                               
IEF237I JES2 ALLOCATED TO SYSPRINT                                             
IEF237I JES2 ALLOCATED TO SYSOUT                                               
IGD103I SMS ALLOCATED TO DDNAME SORTIN                                         
IEF237I DMY  ALLOCATED TO SORTOUT                                               
IEF237I JES2 ALLOCATED TO SYSIN                                                 
IEF142I H2784090 STEP1 - STEP WAS EXECUTED - COND CODE 0000                     
IEF285I   H27840.H2784090.JOB04963.D0000103.?          SYSOUT                   
IEF285I   H27840.H2784090.JOB04963.D0000104.?          SYSOUT                   
IGD104I Input file RETAINED,  DDNAME=SORTIN   
IEF285I   H27840.H2784090.JOB04963.D0000101.?          SYSIN                   
IEF373I STEP/STEP1   /START 2010315.0456                                       
IEF374I STEP/STEP1   /STOP  2010315.0456 CPU    0MIN 00.01SEC SRB    0MIN 00.00S
IEF236I ALLOC. FOR H2784090 STEP2                                               
IEF237I JES2 ALLOCATED TO SYSOUT     
IGD103I SMS ALLOCATED TO DDNAME SORTIN                                         
IGD103I SMS ALLOCATED TO DDNAME SORTOUT                                         
IEF237I JES2 ALLOCATED TO SYSIN                                                 
IEF142I H2784090 STEP2 - STEP WAS EXECUTED - COND CODE 0000                     
IEF285I   H27840.H2784090.JOB04963.D0000105.?          SYSOUT                   
IGD104I Input file RETAINED,  DDNAME=SORTIN   
IGD104I Output file RETAINED,  DDNAME=SORTOUT 
IEF285I   H27840.H2784090.JOB04963.D0000102.?          SYSIN                   
IEF373I STEP/STEP2   /START 2010315.0456                                       
IEF374I STEP/STEP2   /STOP  2010315.0456 CPU    0MIN 00.01SEC SRB    0MIN 00.00S
IEF375I  JOB/H2784090/START 2010315.0456                                       
IEF376I  JOB/H2784090/STOP  2010315.0456 CPU    0MIN 00.02SEC SRB    0MIN 00.00S                                           


SYSOUT of STEP1
Code:

SYNCSORT FOR Z/OS  1.3.2.0R    U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCSO
                                                      z/OS   1.10.0           
SYNCSORT LICENSED FOR IBM DEUTSCHLAND GMBH                                LICEN
SYSIN :                                                                       
  OPTION COPY                                                                 
  OUTFIL NULLOFL=RC4,STARTREC=2,ENDREC=2                                     
WER108I  SORTIN   : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
WER110I  SORTOUT  : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
WER405I  SORTOUT  :  DATA RECORDS OUT         11; TOTAL RECORDS OUT         11
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 
WER054I  RCD IN         11, OUT         11                                     
WER169I  RELEASE 1.3 BATCH 0487 TPF LEVEL 2.0                                 
WER052I  END SYNCSORT - H2784090,STEP1,,DIAG=8200,5042,AAA8,0066,CA56,6CEB,2AE8


SYSOUT of STEP2

Code:
SYNCSORT FOR Z/OS  1.3.2.0R    U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCSO
                                                      z/OS   1.10.0           
SYNCSORT LICENSED FOR IBM DEUTSCHLAND GMBH                                LICEN
SYSIN :                                                                       
  OPTION COPY                                                                 
WER108I  SORTIN   : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
WER110I  SORTOUT  : RECFM=VB   ; LRECL=   354; BLKSIZE=  7476                 
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 
WER246I  FILESIZE 1,599 BYTES                                                 
WER169I  RELEASE 1.3 BATCH 0487 TPF LEVEL 2.0                                 
WER052I  END SYNCSORT - H2784090,STEP2,,DIAG=C600,4040,EAB9,AC77,8E56,68CB,2660


I have replaced actual files as input and output files in the above.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Nov 11, 2010 10:15 am    Post subject: Reply to: Copy data from one file to other using SORT
Reply with quote

Hello,

You do realize you are not using DFSORT . . . You are using Syncsort.

Topic moved to proper part of the forum.

d
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Nov 11, 2010 10:16 am    Post subject: Reply to: Copy data from one file to other using SORT
Reply with quote

Hi Gerry,

Good catch icon_smile.gif

d
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Nov 11, 2010 10:52 am    Post subject:
Reply with quote

Hi Srikanth,

try this for SYNCSORT

Code:
  OPTION COPY,NULLOUT=RC4,SKIPREC=1,STOPAFT=1


Gerry
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Nov 11, 2010 11:50 am    Post subject:
Reply with quote

Why oh why do I bother to ask for the information that identifies the sort product and release level. It usually gets ignored and people end up wasting their valuable time working on inappropriate solutions because the OP is just too dumb or lazy to respond to questions designed to eliminate this.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Unwrap the data based on delimiter X'25' bhavana yalavarthi DFSORT/ICETOOL 30 Fri Dec 09, 2016 10:25 am
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us