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 

How to find missing record through JCL?
Goto page 1, 2  Next
 
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
mayuresh.tendulkar
Beginner


Joined: 25 Apr 2003
Posts: 31
Topics: 6
Location: Pune

PostPosted: Mon Jan 05, 2004 9:25 am    Post subject: How to find missing record through JCL? Reply with quote

Hi All,

There is a DB2 table EMPLOYEE, with the following fields

Sr No. 9(03) <---- Primary Key, Autogenerated, starting from 1 incremented by 1 everytime the new record is added
Emp Name X(30)
Emp Address X(50)
...

etc.

Here the requirement is as below:

Say the table has 10000 records with Sr No starting from 1 to 10000. If I delete the record in between, then how can I find out the missing record's Sr No. programmtically?

Theres one way of doing it through a COBOL program as below:

Download the table in a FLAT file and then process it sequentially, Since the Sr No is starting from 1 and will be upto 10000, we can increment it in steps of 1 and compare it with Sr No, Wherever the record is missing, it will be displayed as deleted from table.

The other way of doing it is

2) Through EZTRIEVE also.
3) Through actually processing table in the COBOL program using cursor.


Do we have any other way of doing it?? Probably through DFSORT / ICETOOL???

Regards

Mayuresh Tendulkar
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: Mon Jan 05, 2004 11:22 am    Post subject: Reply with quote

Mayuresh,

There are many ways of doing it. you can find the missing number with a DB2 query itself.you can even find the missing number with sort product.

DB2 Query:

Code:

SELECT A.SR_NO + 1 AS DELETED_ROW                 
FROM TABLE A                                         
WHERE NOT EXISTS ( SELECT SR_NO                       
                   FROM TABLE B                     
                   WHERE B.SR_NO = A.SR_NO + 1)
AND A.TBL_NO <> 999     
    ;       


Sort Code:

The following DFSORT/ICETOOL jcl will give you the desired results.If you have syncsort at your shop then change the Pgm name to synctool.A brief explanation of the job. UNload the db2 table with just the Sr_no. The first copy operator splits the file into 3 different temp files. Temp T1 is just a copy of the input as is and temp file T2 will be a file by adding 1 to the sr_no and the third temp file will have just record with sr_no '001'.

Now we concatenate all the 3 files together and select all the records which do not have any duplicates.And the next copy step will again split into 2 files one which will have the missing sr_no and other is just a dummy file to eliminate the unwanted records.

Code:

//STEP0100  EXEC  PGM=ICETOOL   
//TOOLMSG   DD SYSOUT=*         
//DFSMSG    DD SYSOUT=*         
//IN        DD DSN=YOUR UNLOAD DB2 TABLE WITH JUST THE SRNO,
//             DISP=SHR
//T1        DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2        DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T3        DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON       DD DSN=&T1,DISP=OLD,VOL=REF=*.T1               
//          DD DSN=&T2,DISP=OLD,VOL=REF=*.T2               
//          DD DSN=&T3,DISP=OLD,VOL=REF=*.T3               
//T4        DD DSN=&T4,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T5        DD DUMMY                                       
//OUT       DD SYSOUT=*                                   
//TOOLIN    DD *                                           
  COPY FROM(IN) USING(CTL1)                               
  SELECT FROM(CON) TO(T4) ON(1,3,CH) NODUPS               
  COPY FROM(T4) USING(CTL2)                               
//CTL1CNTL  DD *                                           
  OUTFIL FNAMES=T1,OUTREC=(1,3)                             
  OUTFIL FNAMES=T2,OUTREC=(+1,ADD,1,3,ZD,EDIT=(TTT))       
  OUTFIL FNAMES=T3,ENDREC=1,OUTREC=(C'001')                 
//CTL2CNTL  DD *                                           
  OUTFIL FNAMES=(OUT,T5),SPLIT
/*


Hope this helps...

cheers

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


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

PostPosted: Mon Jan 05, 2004 3:17 pm    Post subject: Reply with quote

Mayuresh,

Just for kicks here is an easytrieve code and cobol code which will give the desired results.However I deliberately coded a bug in all the versions(easytrieve as well as cobol). can you find that? Laughing

Easytrieve code:

Code:

//STEP0100 EXEC PGM=EZTPA00                                     
//STEPLIB  DD DSN=CORP.EASYTREV.PROD.LOADLIB,                   
//            DISP=SHR                                         
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SYSSNAP  DD SYSOUT=*                                         
//SYSUDUMP DD SYSOUT=*                                         
//INFILE   DD *                                                 
001                                                             
002                                                             
003                                                             
004                                                             
005                                                             
007                                                             
008                                                             
009                                                             
010                                                             
012                                                             
013                                                             
014                                                             
015                                                             
016                                                             
017                                                             
018                                                             
//SYSIN    DD *                                                 
                                                     
 FILE INFILE                                         
    SR-NO                 01 03  N 0                 
                                                     
 WS-NO                    W  03  N 0 VALUE 0         
                                                     
 JOB INPUT INFILE                                   
                                                     
   WS-NO    =   WS-NO  + 1                           
   IF SR-NO = WS-NO                                 
      CONTINUE                                       
   ELSE                                             
      DISPLAY ' THE DELETED SR_NO IS : ' WS-NO       
      WS-NO    =   WS-NO  + 1                       
   END-IF                                           
                                                     
/*


Cobol Code using unloaded flat file:

Code:

        IDENTIFICATION DIVISION.                       
        PROGRAM-ID.    MISSING                         
        DATE-COMPILED.                                 
        ENVIRONMENT DIVISION.                           
        CONFIGURATION SECTION.                         
        INPUT-OUTPUT SECTION.                           
        FILE-CONTROL.                                   
           SELECT  SR-FILE                             
           ASSIGN  TO INFILE                           
           ORGANIZATION IS SEQUENTIAL.                 
        DATA DIVISION.                                 
                                                       
        FILE SECTION.                                   
                                                       
        FD SR-FILE                                     
           RECORDING MODE IS F                         
           LABEL RECORDS ARE STANDARD                   
           BLOCK CONTAINS 0 RECORDS                     
           DATA RECORD IS SR-REC.                       
                                                       
        01 SR-REC.                                     
           05 SR-NO                PIC 9(03).           
           05 FILLER               PIC X(77).           
                                                       
        WORKING-STORAGE SECTION.                       
                                                       
        01 WS-NO                PIC 9(03) VALUE ZERO.   
        01 S-EOF-FILE           PIC X(01) VALUE 'N'.   
                                                       

        PROCEDURE DIVISION.                                       
                                                                 
           PERFORM 1000-INITIALIZATION                           
                                                                 
           PERFORM 2000-MAIN-PROCESS UNTIL S-EOF-FILE = 'Y'       
                                                                 
           PERFORM 3000-WRAPUP                                   
                                                                 
           GOBACK                                                 
           .                                                     
       1000-INITIALIZATION.                                       
      ************************************************************
      * THIS PARAGRAPH OPENS INPUT FILE AND DOES THE PRIME READ  *
      ************************************************************
                                                                 
           OPEN INPUT SR-FILE                                     
                                                                 
           PERFORM 2100-READ-SR-FILE                             
           .                                                     
                                                                 
       2000-MAIN-PROCESS.                                         
      ************************************************************
      *THIS PARAGRAPH PERFORMS THE MAIN LOGIC                    *
      ************************************************************
                                                                 
           ADD +1 TO WS-NO                                       
                                                                 
           IF SR-NO = WS-NO                                       
              CONTINUE                                           
           ELSE                                                   
              DISPLAY ' THE DELETED SR NO IS : ' WS-NO           
              ADD +1 TO WS-NO                                     
           END-IF                                                 
           PERFORM 2100-READ-SR-FILE                             
           .                                                     
                                                                 
       2100-READ-SR-FILE.                                         
      ************************************************************
      *THIS PARAGRAPH READS THE SR-FILE                          *
      ************************************************************
                                                                   
           READ SR-FILE                                           
               AT END                                             
                   MOVE 'Y'            TO S-EOF-FILE               
           END-READ                                               
           .                                                       
       3000-WRAPUP.                                               
      ************************************************************
      * THIS PARAGRAPH CLOSES THE INPUT FILE.                    *
      ************************************************************
                                                                   
           CLOSE SR-FILE                                           
           .                                                       


Cobol code with DB2 cursor:

Code:

IDENTIFICATION DIVISION.                                     
PROGRAM-ID.    MISSING.                                     
AUTHOR.        KOLUSU.                   
ENVIRONMENT DIVISION.                                       
DATA DIVISION.                                               
WORKING-STORAGE SECTION.                                     

01  S-EOF-CURSOR                PIC X(01) VALUE SPACE.       
01  WS-NO                       PIC 9(03) VALUE ZERO.       
01  WS-SR-NO                    PIC 9(03) VALUE ZERO.       
01  WS-FORMAT-SQLCODE           PIC  -9(3). 
**************************************************************
**  DB2 INCLUDES                                            **
**************************************************************
    EXEC SQL                               
         INCLUDE SQLCA                     
    END-EXEC                               
                                           
01  EMPLOYEE.                                   
    10 SR-NO                PIC X(3).       
    10 EMP-NAME             PIC X(30).     
    10 EMP-ADDRESS          PIC X(50).     
**************************************************************
**  CURSOR DECLARATION                                      **
**************************************************************
     EXEC SQL                                                 
         DECLARE SERIAL CURSOR FOR                             
            SELECT  SR_NO                                     
            FROM   EMPLOYEE                               
            ORDER BY SR_NO                                     
     END-EXEC                                                 
                           
PROCEDURE DIVISION.                   
                                                                 
     MOVE 'N'                TO S-EOF-CURSOR                     
                                                                 
     PERFORM 2000-OPEN-CURSOR                                     
     PERFORM 2100-FETCH-CURSOR                                   
                                                                 
     PERFORM UNTIL S-EOF-CURSOR   = 'Y'                           
         ADD +1 TO WS-NO                                         
         IF WS-SR-NO = WS-NO                                     
            CONTINUE                                             
         ELSE                                                     
            DISPLAY ' THE DELETED SR NO IS:' WS-NO           
            ADD +1 TO WS-NO                                   
        END-IF                                                   
        PERFORM 2100-FETCH-CURSOR                                 
     END-PERFORM                                                 
                                                                 
     PERFORM 2200-CLOSE-CURSOR                                   
                                                                 
     GOBACK                                                       
     .                                                           
 2000-OPEN-CURSOR.                                               
******************************************************************
**  THIS PARA OPENS THE CURSOR SERIAL .                         **
******************************************************************
     EXEC SQL                                                     
         OPEN SERIAL                                             
     END-EXEC                                                     
                                                                 
     EVALUATE SQLCODE                                             
         WHEN +0                                                 
             CONTINUE                                             
         WHEN OTHER                                               
             MOVE SQLCODE        TO WS-FORMAT-SQLCODE             
             DISPLAY 'THE SQLCODE IS: WS-FORMAT-SQLCODE
             PERFORM INHOUSE-ABEND-ROUTINE                                 
     END-EVALUATE                                                 
     .         

 2100-FETCH-CURSOR.                                               
******************************************************************
**  THIS PARA FETCHES THE CURSOR SERIAL .                       **
******************************************************************
     EXEC SQL                                                     
        FETCH SERIAL                                             
        INTO                                                     
             :EMPLOYEE.SR-NO                                         
     END-EXEC                                                     
                                                                 
     EVALUATE SQLCODE                             
         WHEN +0                                 
              MOVE SR-NO OF TEND TO WS-SR-NO     
         WHEN +100                               
             MOVE 'Y'            TO S-EOF-CURSOR 
         WHEN OTHER                                               
             MOVE SQLCODE        TO WS-FORMAT-SQLCODE             
             DISPLAY 'THE SQLCODE IS: WS-FORMAT-SQLCODE
             PERFORM INHOUSE-ABEND-ROUTINE                                 
     END-EVALUATE                                                 
     .         
 2200-CLOSE-CURSOR.                                               
******************************************************************
**  THIS PARA CLOSES THE CURSOR SERIAL.                         **
******************************************************************
     EXEC SQL                                                     
        CLOSE SERIAL                                             
     END-EXEC                                                     
                                                                 
     EVALUATE SQLCODE                                             
         WHEN +0                                                 
             CONTINUE   
         WHEN OTHER                                               
             MOVE SQLCODE        TO WS-FORMAT-SQLCODE             
             DISPLAY 'THE SQLCODE IS: WS-FORMAT-SQLCODE
             PERFORM INHOUSE-ABEND-ROUTINE                                 
     END-EVALUATE                                                 
     .         



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


Joined: 25 Apr 2003
Posts: 31
Topics: 6
Location: Pune

PostPosted: Tue Jan 06, 2004 2:28 am    Post subject: Reply with quote

Hello Kolusu,

Thanks a million for the ICETOOL code.

I think the bug in the easytrieve & cobol code is:

What if i have deleted the last record from the table?? I will not be able to find out this record with these codes.

RIGHT??

Moreover, the DB2 query you gave was also great.

We could have done it in a different way as below:

Since we know there are 10000 records starting from 1 with the increments of 1.

So we can write a query as:

1)
SUM(Sr No) ----> this will give us the sum of all the record's Sr No. (with 1 record deleted in between)

2)
N* ((N + 1)/2) will give you the sum of all the record's
here N = 10,000

3)
The difference of this 2 will give you the deleted Sr No.

Please let me know if i am wrong.

Laughing

Regards

Mayuresh Tendulkar
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: Tue Jan 06, 2004 5:29 am    Post subject: Reply with quote

mayuresh,

A couple of corrections. In your very first post you said that the Sr_no is defined is 9(03), but your example data you show the maximum value of the SR_NO as 10000 which I don't think will fit in a 9(03).

Your guess about the bug in my code is not true.

I am not really sure of your alternate solution. My first impression of the solution is that might not work . The reason being simple that the difference between 2 sums will always result in a single digit. what happens if there is more than 1 record which is deleted?

Take the following data
Code:

Sr_no
001
002
003
005
006
007
009
010


In the above data I am missing sr_no 4 and 8. Now try to apply your sum logic and can you retrieve the 2 missing Sr_no ?

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


Joined: 25 Apr 2003
Posts: 31
Topics: 6
Location: Pune

PostPosted: Tue Jan 06, 2004 7:53 am    Post subject: Reply with quote

Hello Kolusu,

My mistake, it should have been 9(5).

Ya about the BUG also my first guess was wrong. While giving the answer I did not looked at the data you have supplied.

In the easytrieve code, you have deleted the 2 records with Sr No 6 & 11. So this will not cause any problems till the fields are matching but once the code has found the mismatched record at WS-NO = 6, it will display all the other records to the mismatched condition as we are incrementing the WS-NO counter twice.

Code:
WS-NO    =   WS-NO  + 1                            ---> once
IF SR-NO = WS-NO                                 
    CONTINUE                                       
ELSE                                             
    DISPLAY ' THE DELETED SR_NO IS : ' WS-NO       
   WS-NO    =   WS-NO  + 1                        ---> twice
END-IF


Same case applies to COBOL code also.

Code:
ADD +1 TO WS-NO                                                ---> once
IF SR-NO = WS-NO                                       
    CONTINUE                                           
ELSE                                                   
     DISPLAY ' THE DELETED SR NO IS : ' WS-NO           
     ADD +1 TO WS-NO                                          --> twice
END-IF



Yes, the SUM logic will only work when there is ONLY one record deleted.

Thanks a lot

Regards

Mayuresh Tendulkar
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: Tue Jan 06, 2004 9:01 am    Post subject: Reply with quote

Mayuresh,

Thanks for clarifying about the size of the column. Now your second guess is also not accurate.

You said

Quote:


In the easytrieve code, you have deleted the 2 records with Sr No 6 & 11. So this will not cause any problems till the fields are matching but once the code has found the mismatched record at WS-NO = 6, it will display all the other records to the mismatched condition as we are incrementing the WS-NO counter twice.


Not exactly true. If you run the code shown above it will indeed display only the record numbers 6 and 11.

The bug I coded is for the condition when there are more than one successive deleted record.
i.e take the following example data
Code:

001
002
007
008
009
010


Here I deleted srno's 3,4,5,6. It is in this case that you get the wrong results. To fix this you need to a perform loop in cobol and do loop in easytrieve

i.e
Easytrieve code

Code:

WS-NO    =   WS-NO  + 1                             
IF SR-NO = WS-NO                                     
   CONTINUE                                         
ELSE                                                 
   DO UNTIL WS-NO >= SR-NO       <===    new code start
      DISPLAY ' THE DELETED SR_NO IS : ' WS-NO       
      WS-NO    =   WS-NO  + 1                       
   END-DO                        <===    new code end               
END-IF                                               




cobol code:
Code:

ADD +1 TO WS-NO                                 
                                               
IF SR-NO = WS-NO                               
   CONTINUE                                     
ELSE                                           
   PERFORM UNTIL WS-NO >= SR-NO     <====  new code start           
      DISPLAY ' THE DELETED SR NO IS : ' WS-NO 
      ADD +1 TO WS-NO                           
   END-PERFORM                      <====  new code end               
END-IF                                         


Hope this helps...

cheers

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


Joined: 25 Apr 2003
Posts: 31
Topics: 6
Location: Pune

PostPosted: Tue Jan 06, 2004 9:13 am    Post subject: Reply with quote

Hello Kolusu,

Agreed, I did not gave it a thought.
It was really a refreshing session for me. Thanks a lot.

Regards

Mayuresh Tendulkar
Back to top
View user's profile Send private message Send e-mail
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Wed Jan 14, 2004 5:07 am    Post subject: Reply with quote

Kolusu,
For the DB2 query, if the first row gets deleted, then the query would not capture it.

Cheers,
Coolman
________
digital vaporizer


Last edited by coolman on Sat Feb 05, 2011 1:32 am; edited 1 time in total
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: Wed Jan 14, 2004 2:28 pm    Post subject: Reply with quote

coolman,

Yes ofcourse it does not find the missing record if the deleted record happens to be the very first record. hmm I need to fix it.

Here is another version of DFSORT/ICETOOL which will find all the missing seqnum.You need to have DFSORT PTF UQ90053 installed for this job to work. A brief explanation of the job. The first sort operator will sort the file on seqnum descending so that I will get the max seqnum in the table. It create control file for generating the seqnum upto the max seqnum.

The second copy operator will the control file created in the first sort step and generates seqnum file using REPEAT parm,so that the file will have seqnum in serial upto the max number.

Now concatenate both the files(input & generated senum file) and using SELECT with NODUPS to find the missing numbers.

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN       DD DSN=INPUT FILE,
//            DISP=SHR
//NULL     DD *
DUMMY RECORD
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON      DD DSN=INPUT FILE,
//            DISP=SHR
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//OUT      DD DSN=YOUR OUTPUT MISSING SR_NO FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *                                         
  SORT FROM(IN)   USING(CTL1)                             
  COPY FROM(NULL) USING(CTL2)                           
  SELECT FROM(CON) TO(OUT) ON(1,5,ZD) NODUPS             
//CTL1CNTL DD *                                         
  SORT FIELDS=(1,5,ZD,D)                                 
  OUTFIL FNAMES=CTL2CNTL,ENDREC=1,                       
  OUTREC=(C' OUTFIL FNAMES=T1,',/,                       
          C' OUTREC=(SEQNUM,5,ZD,80:X),REPEAT=',1,5,80:X)
//*
//CTL2CNTL DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//*

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Thu Jan 15, 2004 10:44 am    Post subject: Reply with quote

I just realized that we can change Kolusu's DFSORT/ICETOOL job slightly to replace the SORT with a COPY by using TRAILER1 to create the OUTREC statement. TRAILER1 will pick up the sequence number from the last record. Here's the modified DFSORT/ICETOOL job:

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD DSN=INPUT FILE,
//            DISP=SHR
//NULL     DD *
DUMMY RECORD
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON      DD DSN=INPUT FILE,
//            DISP=SHR
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//OUT      DD DSN=YOUR OUTPUT MISSING SR_NO FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *
  COPY FROM(IN)   USING(CTL1)
  COPY FROM(NULL) USING(CTL2)
  SELECT FROM(CON) TO(OUT) ON(1,5,ZD) NODUPS
//CTL1CNTL DD *
  OUTFIL FNAMES=CTL2CNTL,REMOVECC,NODETAIL,
   OUTREC=(80X),
   TRAILER1=(C' OUTFIL FNAMES=T1,',/,
          C' OUTREC=(SEQNUM,5,ZD,80:X),REPEAT=',1,5)
//*
//CTL2CNTL DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//*

_________________
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
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jan 15, 2004 12:14 pm    Post subject: Reply with quote

Frank,

Using copy instead of sort is good idea and it also saves time . Why didn't I think of it Sad

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Thu Jan 15, 2004 1:08 pm    Post subject: Reply with quote

Kolusu,

Well, for that matter, why didn't I think of it when we were discussing this problem offline. Embarassed
_________________
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
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jan 15, 2004 3:01 pm    Post subject: Reply with quote

Frank,

Aha I remember now why I wanted to sort the data instead of copy.I need the max but not the last record. The last record is not always the max seqnum. what if the data is not sorted on the seqnum?.

for ex take a look at this data :
Code:

00002
00003
00005
00007
00010
00013
00014
00015
00012


using copy with trailer will give you the counter for REPEAT parm as 00012. But in this we need it as 00015.

We can still use a copy operation but we need to use the max parm to get the max of the seqnum. I changed the job to pick the max seqnum

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD DSN=INPUT FILE,
//            DISP=SHR
//NULL     DD *
DUMMY RECORD
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON      DD DSN=INPUT FILE,
//            DISP=SHR
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
//OUT      DD DSN=YOUR OUTPUT MISSING SR_NO FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *
  COPY FROM(IN)   USING(CTL1)
  COPY FROM(NULL) USING(CTL2)
  SELECT FROM(CON) TO(OUT) ON(1,5,ZD) NODUPS
//CTL1CNTL DD *
  OUTFIL FNAMES=CTL2CNTL,NODETAIL,                         
  TRAILER1=(C' OUTFIL FNAMES=T1,',/,                       
            C' OUTREC=(SEQNUM,5,ZD,80:X),REPEAT=',           
            MAX=(1,5,ZD,M11),80:X)                             
//*
//CTL2CNTL DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//*


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Thu Jan 15, 2004 3:38 pm    Post subject: Reply with quote

Kolusu,

The first post says
Quote:
Say the table has 10000 records with Sr No starting from 1 to 10000
and
Quote:
Since the Sr No is starting from 1 and will be upto 10000, we can increment it in steps of 1 and compare it with Sr No


I took that to mean that the sequence numbers are in order. Am I misinterpreting those statements?
_________________
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
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
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