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
 

 

how to copy file based on contents of first record

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

New User


Joined: 08 Jan 2013
Posts: 20
Location: usa

PostPosted: Thu Oct 31, 2013 10:17 pm    Post subject: how to copy file based on contents of first record
Reply with quote

I have a file with a header type record, followed by details records. Would like to check some date values in the first record and if they match I want to write out the whole file to an output file, if they don't match, don't want to write out anything.

I know how check date values in the first record for the include, not not sure what syntax to use to get the header record and any subsequent records to be written if the condition is true
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Oct 31, 2013 10:40 pm    Post subject: Reply to: how to copy file based on contents of first record
Reply with quote

Can you show code for your validation of the header?
Back to top
View user's profile Send private message
norm.flynn

New User


Joined: 08 Jan 2013
Posts: 20
Location: usa

PostPosted: Thu Oct 31, 2013 11:33 pm    Post subject:
Reply with quote

The beginning of the file is as follows and has record length of 365, The data I have in the include only occurs in record 1, however if true I want to copy the whole file to the sortout
Code:
********************************* Top of Data **********************************
000000000000{131012000001................PCR42131023131012B1130929101  000000000
000020503021{131012B18510..  ............DUMMY, NAME                A      03
000020503021{131012B18523..3336766001     SUBS             SX C E  B0..ΓΈ.4 D TX1


The statement to do the include would be

Code:
SORT FIELDS=COPY                 
INCLUDE COND=(49,2,CH,EQ,C'12',AND,
              63,2,CH,EQ,C'12')
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Oct 31, 2013 11:49 pm    Post subject: Reply to: how to copy file based on contents of first record
Reply with quote

You can identify the header (I assume uniquely) with IFTHEN=(WHEN=GROUP then PUSH those values you want to test to extended fields on every record. Then use OUTFIL INCLUDE= for the values.

If you can't do it uniquely, you can make it unique by putting a sequence number on every record with IFTHEN=(WHEN=INIT and do the GROUP with the sequence number equal to 1.
Back to top
View user's profile Send private message
norm.flynn

New User


Joined: 08 Jan 2013
Posts: 20
Location: usa

PostPosted: Fri Nov 01, 2013 1:46 am    Post subject:
Reply with quote

Having some problem with the statement, turns out the file is a vb file, total length 369,

I am trying to look at the input file, and if the both dates have a month of '12' write it out to decdeco, if one month is 12 and the other is 01, then write to decjano

Here is my sysout, seems to be saying I am beyond the record, but thought I was pushing the 2 fields I need to 270 for 2, 272 for 2, can you see what is wrong?
Code:
 OPTION COPY                                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(49,3,CH,EQ,C'PCR'),                     
     PUSH=(370:15,2,372:49,2))                                           
                                                                         
  OUTFIL FNAMES=DECDECO,BUILD=(1,369),                                   
   INCLUDE=(370,2,CH,EQ,C'12',AND,372,2,CH,EQ,C'12')                     
                                                                         
  OUTFIL FNAMES=DECJANO,BUILD=(1,369),                                   
   INCLUDE=(370,2,CH,EQ,C'12',AND,372,2,CH,EQ,C'01')                     
WER276B  SYSDIAG= 28960, 1616256, 1616256, 2327250                       
WER164B  6,916K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,       
WER164B     0 BYTES RESERVE REQUESTED, 3,360,296 BYTES USED               
WER108I  SORTIN   : RECFM=VB   ; LRECL=   369; BLKSIZE= 27998             
WER257I  INREC RECORD LENGTH =   373                                     
WER238I  POTENTIALLY INEFFICIENT USE OF INREC                             
WER110I  DECDECO  : RECFM=VB   ; LRECL=   369; BLKSIZE= 27998             
WER110I  DECJANO  : RECFM=VB   ; LRECL=   369; BLKSIZE= 27998             
WER410B  5,888K BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE, 
WER410B     0 BYTES RESERVE REQUESTED, 3,192,360 BYTES USED   
WER250A  DECDECO  INCLUDE/OMIT FIELD BEYOND RECORD   
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE           
Back to top
View user's profile Send private message
norm.flynn

New User


Joined: 08 Jan 2013
Posts: 20
Location: usa

PostPosted: Fri Nov 01, 2013 2:31 am    Post subject:
Reply with quote

figured it out, just needed to code OPTION COPY,VLSHRT

Thanks
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Nov 01, 2013 2:41 am    Post subject: Reply to: how to copy file based on contents of first record
Reply with quote

OK. You have SyncSort, so your topic has been moved to the JCL forum.

For a variable-length record, the trick is to do the extension at the front of the record.
Code:

  INREC IFTHEN=(WHEN=INIT,
                    BUILD=(1,4,4X,5)),


The 1,4 is the RDW, from the input which is necessary always to put in a BUILD for a variable-length record. The 4X puts four blanks in the first four data positions. The 5, with no length, says "from position 5 to the end of the current record".

Then use 1,2 and 3,2 for your PUSH. Amend the INCLUDE='s for the 1,2 and 3,2.

Then in the BUILDs on the OUTFILs:

Code:
  BUILD=(1,3,9)


Copying the RDW again (necessary on each BUILD for a variable-lenght record) then then the 5th data position (record position 9) to the end of the record.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Nov 01, 2013 2:43 am    Post subject: Reply to: how to copy file based on contents of first record
Reply with quote

No, not really. All your variable-length records are now fixed-length-in-variable-clothing.

If one or more of the fields you want are within the variable part of the data on the record, you need an option to give you what you want. If there is an unexpected short record, you'll need to know what it is before blindly using it :-)
Back to top
View user's profile Send private message
norm.flynn

New User


Joined: 08 Jan 2013
Posts: 20
Location: usa

PostPosted: Fri Nov 01, 2013 3:09 am    Post subject:
Reply with quote

Trying do use your example of doing the push at the beginning, but getting a 16, inrec rdw error?

Code:
            SYNCSORT LICENSED FOR CPU SERIAL NUMBER 3A990, MODEL 2098 N03             LICEN
SYSIN :                                                                       
 OPTION COPY,VLSHRT                                                           
  INREC IFTHEN(WHEN=INIT,BUILD=(1,4,4X,5)),                                   
        IFTHEN=(WHEN=GROUP,BEGIN=(46,3,CH,EQ,C'PCR'),                         
     PUSH=(1:20,2,3:53,2))                                                     
                                                                               
  OUTFIL FNAMES=DECDECO,BUILD=(1,3,9),                                         
   INCLUDE=(1,2,CH,EQ,C'12',AND,3,2,CH,EQ,C'12')                               
                                                                               
  OUTFIL FNAMES=DECJANO,BUILD=(1,3,9),                                         
   INCLUDE=(1,2,CH,EQ,C'12',AND,3,2,CH,EQ,C'01')                               
WER276B  SYSDIAG= 770300, 1908634, 1908634, 2324925                           
WER164B  6,916K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,             
WER164B     0 BYTES RESERVE REQUESTED, 1M BYTES USED                           
WER108I  SORTIN   : RECFM=VB   ; LRECL=   369; BLKSIZE= 27998                 
WER235A  INREC    RDW NOT INCLUDED                                             
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                                                         
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Nov 01, 2013 4:45 am    Post subject: Reply to: how to copy file based on contents of first record
Reply with quote

Sorry, meaning 1,2 and 3,2 in the data portion: so 5,2 and 7,2.
Back to top
View user's profile Send private message
norm.flynn

New User


Joined: 08 Jan 2013
Posts: 20
Location: usa

PostPosted: Fri Nov 01, 2013 9:15 pm    Post subject:
Reply with quote

Wanted to thank you for your help, the final sort statement which worked is as follows, adjusting the values for putting the group by values at the beginning of the record.

Code:
 OPTION COPY,VLSHRT                                                     
  INREC IFTHEN(WHEN=INIT,BUILD=(1,4,4X,5)),                             
        IFTHEN=(WHEN=GROUP,BEGIN=(50,3,CH,EQ,C'PCR'),                   
     PUSH=(5:24,2,7:57,2))                                             
                                                                       
  OUTFIL FNAMES=DECDECO,BUILD=(1,4,9),                                 
   INCLUDE=(5,2,CH,EQ,C'12',AND,7,2,CH,EQ,C'12')                       
                                                                       
  OUTFIL FNAMES=DECJANO,BUILD=(1,4,9),                                 
   INCLUDE=(5,2,CH,EQ,C'12',AND,7,2,CH,EQ,C'01')             
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Fri Nov 01, 2013 9:23 pm    Post subject: Reply to: how to copy file based on contents of first record
Reply with quote

No problem. Thanks for posting the code, may help someone else.

Just one thing, the 7: in the PUSH is redundant, as the next available position is 7 anyway. Doesn't hurt any.
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
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
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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