Page 1 of 1

Retrieving records in between!!!!

PostPosted: Mon Jul 23, 2012 11:52 pm
by ibmmf4u
Hi Everyone,

My requirement goes this way. I would like to retrieve the records from a file whose begin and end positions are always fixed and write them into a file. I would like to extract the records which were present in between those begin and end values. The recordlength of both the input and output files is 200.

Below mentioned is an example of same.

The input file contains the records as follows:-
RUNDATE:   07/20/12, RUN TIME:  201624                               
                                                                     
                                              ERROR REPORT
                                             ________________________
                                                  07/24/2012         
          ERROR NUMBER           ERROR NAME                     
          --------------           ------------                     
                                   -----    END OF REPORT    -----   
                        ERROR  LOG FOR QUEUE REQUEST  00000000                                                                               
                                                        REQUESTED  LIST   
      ERROR             DESCRIPTION                                         
  ---------------  -------------------------  --------------------------------
                                                                             
  0000ABEC00002E3                             ERROR MATCH                 
             
RUNDATE:   07/20/12, RUN TIME:  201611   
                                                                   
                                              ERROR REPORT
                                             ________________________
                                                  07/24/2012         
          ERROR NUMBER           ERROR NAME                     
          --------------           ------------                     
         000123ABC                 TEST ERROR
                                   -----    END OF REPORT    -----                                       

             ERROR  LOG FOR QUEUE REQUEST  00000000                                                                               
                                                        REQUESTED  LIST   
      ERROR             DESCRIPTION                                         
  ---------------  -------------------------  --------------------------------
                                                                             
  0000ABEC00002E3                             ERROR MATCH                 
             
RUNDATE:   07/20/12, RUN TIME:  201611   
                                              ERROR REPORT
                                             ________________________
                                                  07/24/2012         
          ERROR NUMBER           ERROR NAME                     
          --------------           ------------                     
         000456DEF                 TEST ERROR ONE
                                   -----    END OF REPORT    -----                                       




Where i would like to retrieve the reocrds which were present in between "ERROR REPORT" say whose position starts at 47 th position in a file and
"END OF REPORT"say whose position starts at 46 th postion in a file.

In short the output file should contain only the following records:-
Output file:-
                                              ERROR REPORT
                                             ________________________
                                                  07/24/2012         
          ERROR NUMBER           ERROR NAME                     
          --------------           ------------                     
                                   -----    END OF REPORT    -----   
                                              ERROR REPORT
                                             ________________________
                                                  07/24/2012         
          ERROR NUMBER           ERROR NAME                     
          --------------           ------------                     
         000123ABC                 TEST ERROR
                                   -----    END OF REPORT    -----                                       
                                              ERROR REPORT
                                             ________________________
                                                  07/24/2012         
          ERROR NUMBER           ERROR NAME                     
          --------------           ------------                     
         000456DEF                 TEST ERROR ONE
                                   -----    END OF REPORT    -----                                       



It should only contain's the above reocrds.

I tried the below piece of code but then it's just retreiving the contains present in between "ERROR REPORT" and "END OF REPORT" where it first encountered. its not retrieving the other error numbers "000123ABC" and "000456DEF".

Pasted below is the code which i used.

//STEP030  EXEC PGM=SORT                                 
//SYSPRINT DD  SYSOUT=*                                 
//SYSOUT   DD  SYSOUT=*                                 
//SORTIN   DD  DSN=INPUT.DATASET,DISP=SHR         
//SORTOUT  DD  DSN=OUTPUT.DATASET,DISP=SHR     
//SYSIN    DD  *                                         
  INREC IFTHEN=(WHEN=GROUP,                             
     BEGIN=((47,12,CH,EQ,C'ERROR REPORT')), 
     END=(46,15,CH,EQ,C'END OF REPORT'),PUSH=(201:ID=1))
   SORT FIELDS=COPY                                     
   OUTFIL INCLUDE=(201,1,ZD,EQ,1),BUILD=(1,200)         
//*                                                     


The output which i got is:-

                                              ERROR REPORT
                                             ________________________
                                                  07/24/2012         
          ERROR NUMBER           ERROR NAME                     
          --------------           ------------                     
                                   -----    END OF REPORT    -----   




Can some one provide me the sort card in achieving the above. Thanks in advance!!!

Re: Retrieving records in between!!!!

PostPosted: Tue Jul 24, 2012 4:30 am
by BillyBoyo
I think you misunderstand what ID is on the PUSH. Try the effect of (201,1,CH,NE,C' ') on your OUTFIL INCLUDE.

Re: Retrieving records in between!!!!

PostPosted: Tue Jul 24, 2012 11:41 pm
by ibmmf4u
Thanks a lot Bill. I modified the below piece of code per your suggestion and it's working fine.

//STEP030  EXEC PGM=SORT                                 
//SYSPRINT DD  SYSOUT=*                                 
//SYSOUT   DD  SYSOUT=*                                 
//SORTIN   DD  DSN=INPUT.DATASET,DISP=SHR         
//SORTOUT  DD  DSN=OUTPUT.DATASET,DISP=SHR     
//SYSIN    DD  *                                         
  INREC IFTHEN=(WHEN=GROUP,                             
     BEGIN=((47,12,CH,EQ,C'ERROR REPORT')),
     END=(46,15,CH,EQ,C'END OF REPORT'),PUSH=(201:ID=1))
   SORT FIELDS=COPY                                     
   OUTFIL INCLUDE=(201,1,CH,NE,C' '),BUILD=(1,200)         
//*                                                     


Thanks a lot once again!!!