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
 

 

Extract the records between two delimiters

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Tue Jun 03, 2008 6:26 pm    Post subject: Extract the records between two delimiters
Reply with quote

Hi i have done some code changes by adding the comments as below starting from the 7th column.

* 1.14567 BEGIN ****************
code
* 1.14567 END ****************

Is there any way to copy the code between the specified delimiters using DFSORT.
Back to top
View user's profile Send private message

Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Tue Jun 03, 2008 6:58 pm    Post subject:
Reply with quote

Where does these comments reside?

Are you referring to concatenating two datasets and having the data in the 2nd dataset between these to records ?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Jun 03, 2008 9:12 pm    Post subject:
Reply with quote

stly,

It's not clear what you want to do. Are there other records before and/or after these records? Are you trying to copy the records starting at the BEGIN line and ending at the END line, and eliminate the other records before and after those records?

Please show a better example of the input records and what you want for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of all relevant fields and constants.
Back to top
View user's profile Send private message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Wed Jun 04, 2008 9:34 am    Post subject:
Reply with quote

Frank Yaeger wrote:
stly,

It's not clear what you want to do. Are there other records before and/or after these records? Are you trying to copy the records starting at the BEGIN line and ending at the END line, and eliminate the other records before and after those records?

Please show a better example of the input records and what you want for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of all relevant fields and constants.


Thanks Frank for ur reply..

Let me explain you with an example..

I am changing my cobol program.I have added my code in between the limiters

* 1.14567 BEGIN ****************
code
* 1.14567 END ****************

and

* 1.14568 BEGIN ****************
code
* 1.14568 END ****************

Now i need to copy all the code in between the delimiters (including the delimters) in to a PS.The delimters starts from 7th position.
RECFM=F and LREC=80.




Code:


Input :

     IF RERVAL NOT EQUAL SPACES
* 1.14567 BEGIN *************************************************
*       MOVE  ATMVA     TO  INS-SER
        MOVE  ATMVA     TO  INS-VER
* 1.14567 END ***************************************************
        MOVE  LINE29  TO  T-SERV
        PERFORM 8000-PRINT-REC
           THRU 8999-PRINT-REC-EXIT
* 1.14568 BEGIN *************************************************
*       MOVE  ATMV1     TO  INS-SER1
        MOVE  ATMV1     TO  INS-VER1
* 1.14568 END ***************************************************
        PERFORM 8000-REC
           THRU 8999-REC-EXIT.


Output:

   
* 1.14567 BEGIN *************************************************
*       MOVE  ATMVA     TO  INS-SER
        MOVE  ATMVA     TO  INS-VER
* 1.14567 END ***************************************************
* 1.14568 BEGIN *************************************************
*       MOVE  ATMV1     TO  INS-SER1
        MOVE  ATMV1     TO  INS-VER1
* 1.14568 END ***************************************************
 
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jun 04, 2008 10:42 pm    Post subject:
Reply with quote

The following DFSORT JCl will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD *                                                       
   IF RERVAL NOT EQUAL SPACES                                         
* 1.14567 BEGIN *************************************************     
*       MOVE  ATMVA     TO  INS-SER                                   
        MOVE  ATMVA     TO  INS-VER                                   
* 1.14567 END ***************************************************     
        MOVE  LINE29  TO  T-SERV                                     
        PERFORM 8000-PRINT-REC                                       
           THRU 8999-PRINT-REC-EXIT                                   
* 1.14568 BEGIN *************************************************     
*       MOVE  ATMV1     TO  INS-SER1                                 
        MOVE  ATMV1     TO  INS-VER1                                 
* 1.14568 END ***************************************************     
        PERFORM 8000-REC                                             
           THRU 8999-REC-EXIT.                                       
//OUT      DD SYSOUT=*                                               
//TOOLIN   DD *                                                     
  SPLICE FROM(IN) TO(OUT) ON(81,8,CH)         -                     
  WITHALL WITH(1,80) KEEPNODUPS KEEPBASE USING(CTL1)               
//CTL1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),               
        IFTHEN=(WHEN=((1,1,CH,EQ,C'*',AND,11,5,CH,EQ,C'BEGIN'),OR, 
                      (1,1,CH,EQ,C'*',AND,11,3,CH,EQ,C'END')),     
       OVERLAY=(81:SEQNUM,8,ZD,1,15)),                             
        IFTHEN=(WHEN=NONE,                                         
       OVERLAY=(89:SEQNUM,8,ZD,                                     
                81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))               
                                                                   
                                                                   
  SORT FIELDS=COPY                                                 
  OUTFIL FNAMES=OUT,REMOVECC,BUILD=(01,80),                         
  INCLUDE=(89,15,SS,EQ,C'BEGIN'),                                   
  SECTIONS=(89,15,                                                 
  TRAILER3=(89,10,' END ',65'*'))                                   
/*                                                                 


Hope this helps...

Cheers
Back to top
View user's profile Send private message
Ed Groneman

New User


Joined: 11 Oct 2007
Posts: 7
Location: Cincinnati, OH

PostPosted: Wed Jun 18, 2008 11:58 pm    Post subject: Split input file
Reply with quote

Input file like this:
FH$ 158 70API810 APIFLAT 080616144835
BH$ 188IN 7000001
ST 054810 11211
BIG 10020080531LZ35148
N1 021RE IRON MOUNTAIN INC.
BT$ 001
FT$ 001
FH$ 158 100020API810X APIFLAT 080616144836
BH$ 188IN 10002000001
ST 054810 1
BIG 10020080516102748003
REF 062CA 00051705414 05144

Need output file to contain the FH$ record and all succeeding records until I hit the next FH$ record then that should be written to new file with it's succeeding records, etc. File will always start with FH$ record. Can this be done with SPLIT since there is never a set # of records associated with each FH$ record? Or must it be done with a loop in Cobol?

Thanks for your reply

Ed
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Jun 19, 2008 12:04 am    Post subject: Re: Split input file
Reply with quote

Ed Groneman wrote:
Need output file to contain the FH$ record and all succeeding records until I hit the next FH$ record then that should be written to new file with it's succeeding records, etc. File will always start with FH$ record. Can this be done with SPLIT since there is never a set # of records associated with each FH$ record? Or must it be done with a loop in Cobol?

Thanks for your reply

Ed


Do you mean to split each FH$ block into a new file? Do you know how many blocks do you have? We can split the Records into blocks , but you may run out off DD names . If there is a reasonable number (<=99) then we can show you an example of splitting the data.

What is the LRECL and RECFM of the input and output datasets?
Back to top
View user's profile Send private message
Ed Groneman

New User


Joined: 11 Oct 2007
Posts: 7
Location: Cincinnati, OH

PostPosted: Thu Jun 19, 2008 12:11 am    Post subject:
Reply with quote

Yes each FH$ block would be in a separate file but would be well under 99 total files. lrecl=516 and recfm=vb
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Jun 19, 2008 12:33 am    Post subject: Reply to: Extract the records between two delimiters
Reply with quote

Ed Groneman

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=&&T1,DISP=SHR                             
//OUT01    DD SYSOUT=*                                     
//OUT02    DD SYSOUT=*                                     
//OUT03    DD SYSOUT=*                                     
....
//OUT99    DD SYSOUT=*
//SYSIN    DD *                                             
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,SEQNUM,8,ZD,8X,5)),   
  IFTHEN=(WHEN=(21,3,CH,EQ,C'FH$'),OVERLAY=(5:SEQNUM,8,ZD)),
  IFTHEN=(WHEN=NONE,OVERLAY=(13:SEQNUM,8,ZD,               
           05:05,8,ZD,SUB,13,8,ZD,M11,LENGTH=8))           
                                                           
  SORT FIELDS=COPY                                         
                                                           
  OUTFIL FNAMES=OUT01,INCLUDE=(5,8,ZD,EQ,01),BUILD=(1,4,21)
  OUTFIL FNAMES=OUT02,INCLUDE=(5,8,ZD,EQ,02),BUILD=(1,4,21)
  OUTFIL FNAMES=OUT03,INCLUDE=(5,8,ZD,EQ,03),BUILD=(1,4,21)
  ....

  OUTFIL FNAMES=OUT99,INCLUDE=(5,8,ZD,EQ,99),BUILD=(1,4,21)
/*                                                         


Hope this helps....

Cheers
Back to top
View user's profile Send private message
Ed Groneman

New User


Joined: 11 Oct 2007
Posts: 7
Location: Cincinnati, OH

PostPosted: Thu Jun 19, 2008 1:10 am    Post subject:
Reply with quote

Yes, that worked perfectly! Thanks.
Ed
Back to top
View user's profile Send private message
Ed Groneman

New User


Joined: 11 Oct 2007
Posts: 7
Location: Cincinnati, OH

PostPosted: Tue Jun 24, 2008 6:19 pm    Post subject:
Reply with quote

Kolusu - New twist - I now need to further define the FH$ records using a unique vendor # on the record. How can I change the INREC statements to also use the vendor # (bold columns on FH$ rec)? In other words, I need to write the outfil files based on FH$ and the vendor #. How would I specify that?

FH$ 158 70API810 APIFLAT 080616144835
BH$ 188IN 7000001
ST 054810 11211
BIG 10020080531LZ35148
N1 021RE IRON MOUNTAIN INC.
BT$ 001
FT$ 001
FH$ 158 100020API810X APIFLAT 080616144836
BH$ 188IN 10002000001

thanks again,
Ed
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jun 24, 2008 9:19 pm    Post subject: Reply to: Extract the records between two delimiters
Reply with quote

Ed Groneman,

Assuming that the vendor number starts at 35 (31 + 4 byte rdw) the following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD DSN=your input vb file,DISP=SHR                                   
//OUT      DD DUMMY                                               
//OUT01    DD SYSOUT=*                                             
//OUT02    DD SYSOUT=*                                             
...
//OUT99    DD SYSOUT=*
//TOOLIN   DD *                                                   
  SPLICE FROM(IN) TO(OUT) ON(517,8,CH) KEEPNODUPS WITHALL -       
  WITH(5,512) KEEPBASE USING(CTL1)                                 
//CTL1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(517:SEQNUM,8,ZD)),             
  IFTHEN=(WHEN=(5,3,CH,EQ,C'FH$'),OVERLAY=(517:SEQNUM,8,ZD,35,12)),
  IFTHEN=(WHEN=NONE,OVERLAY=(525:SEQNUM,8,ZD,                     
           517:517,8,ZD,SUB,525,8,ZD,M11,LENGTH=8))               
                                                                   
  SORT FIELDS=COPY                                                 
                                                                   
  OUTFIL FNAMES=OUT01,BUILD=(1,4,5,512),                           
  INCLUDE=(525,12,CH,EQ,C'080616144835')                           
                                                                   
  OUTFIL FNAMES=OUT02,BUILD=(1,4,5,512),                           
  INCLUDE=(525,12,CH,EQ,C'080616144836')                           
               
  ....                                                 
  OUTFIL FNAMES=OUT99,BUILD=(1,4,5,512),                           
  INCLUDE=(525,12,CH,EQ,C'nnnnnnnnnnnnn')                           

/*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Sep 20, 2008 3:56 am    Post subject:
Reply with quote

You can do this kind of thing more easily and efficiently with the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008). Here's the job for stly's requirement:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT  DD SYSOUT=*
//SORTIN       DD *
   IF RERVAL NOT EQUAL SPACES
* 1.14567 BEGIN *************************************************
*       MOVE  ATMVA     TO  INS-SER
        MOVE  ATMVA     TO  INS-VER
* 1.14567 END ***************************************************
        MOVE  LINE29  TO  T-SERV
        PERFORM 8000-PRINT-REC
           THRU 8999-PRINT-REC-EXIT
* 1.14568 BEGIN *************************************************
*       MOVE  ATMV1     TO  INS-SER1
        MOVE  ATMV1     TO  INS-VER1
* 1.14568 END ***************************************************
        PERFORM 8000-REC
           THRU 8999-REC-EXIT.
/*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,
   BEGIN=(1,1,CH,EQ,C'*',AND,11,5,CH,EQ,C'BEGIN'),
   END=(1,1,CH,EQ,C'*',AND,11,3,CH,EQ,C'END'),
   PUSH=(81:ID=1))
  OUTFIL INCLUDE=(81,1,CH,NE,C' '),BUILD=(1,80)
/*


For complete details on the WHEN=GROUP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Sep 20, 2008 4:19 am    Post subject:
Reply with quote

Here's the DFSORT WHEN=GROUP job for Ed Groneman's last request:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (VB/516)
//OUT01 DD DSN=...   output file1 (VB/516)
//OUT02 DD DSN=...   output file2 (VB/516)
...
//OUT99 DD DSN=...   output file99 (VB/516)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,17:5)),
        IFTHEN=(WHEN=GROUP,BEGIN=(17,3,CH,EQ,C'FH$'),
           PUSH=(5:51,12))
  OUTFIL FNAMES=OUT01,
    INCLUDE=(5,12,CH,EQ,C'080616144835'),
    BUILD=(1,4,5:17)
  OUTFIL FNAMES=OUT02,
    INCLUDE=(5,12,CH,EQ,C'080616144836'),
    BUILD=(1,4,5:17)
  ...
  OUTFIL FNAMES=OUT99,
    INCLUDE=(5,12,CH,EQ,C'nnnnnnnnnnnn'),
    BUILD=(1,4,5:17)
/*
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am


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