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
 

 

Extracting only first and last records in a file

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

New User


Joined: 10 Oct 2005
Posts: 27

PostPosted: Tue Oct 23, 2007 5:11 pm    Post subject: Extracting only first and last records in a file
Reply with quote

Hi All,

Would any one please suggest a solution for the below requirement.

We have to extract only header (1st record) and trailer (last record) from a file, but we dont have any specific indicator to know the record type i.e. header/detail/trailer.

Please suggest a solution for this requirement.

Many thanks in advance,
Kranti & Sarma.
Back to top
View user's profile Send private message

shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Tue Oct 23, 2007 5:35 pm    Post subject:
Reply with quote

kranti,

Please check with the following code for your requirement
Code:
// EXEC PGM=SORT
//SORTIN DD DSN=INFILE,DISP=OLD
//SORTOUT DD DSN=OUTFILE,DISP=OLD
//SYSOUT DD SYSOUT=*
//SYSIN DD *
 OPTION COPY,STOPAFT=1
/*
// EXEC PGM=FILEAID
//DD01 DD DSN=INFILE,DISP=OLD
//DD01O DD DSN=OUTFILE,DISP=MOD
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
$$DD01 COPYBACK OUT=1
/*
//
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 Oct 23, 2007 10:16 pm    Post subject:
Reply with quote

Kranti,

You can use a DFSORT job like the one below to do what you asked for. I assumed your input file has RECF=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    HEADER1=(1,80),
    TRAILER1=(1,80)
/*
Back to top
View user's profile Send private message
uchekala

New User


Joined: 01 Nov 2007
Posts: 7
Location: chennai

PostPosted: Thu Nov 01, 2007 9:18 pm    Post subject:
Reply with quote

Hi Frank,

if i try your method i am getting the below error.

Code:

********************************* TOP OF DATA **********************************
1ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED
 ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES A
 ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 10:42 ON THU NO
0            OPTION COPY
             OUTFIL REMOVECC,NODETAIL,
               HEADER=(1,5818),
               $
 ICE213A 0 INVALID OUTFIL STATEMENT OPERAND
               TRAILER=(1,5818)
               $
 ICE005A 0 STATEMENT DEFINER ERROR
 ICE751I 0 C5-K20802 C6-K90007 C7-K90000 C8-K90007 E7-K11698
 ICE052I 3 END OF DFSORT
******************************** BOTTOM OF DATA ********************************
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Thu Nov 01, 2007 10:31 pm    Post subject:
Reply with quote

Upendra,

You didn't copy/paste properly Frank's example !

Alain
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: Thu Nov 01, 2007 11:17 pm    Post subject:
Reply with quote

Upendra,

You used HEADER instead of HEADER1 and TRAILER instead of TRAILER1.

But you didn't say your records were 5818 bytes. The method I showed will only work for up to 256 bytes. To get 5818 bytes, you'd need to use 23 p,m fields which is probably not practical.

Instead, you can use a DFSORT/ICETOOL job like the following:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG  DD  SYSOUT=*
//IN DD DSN=...  input file (FB/5818)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//***> USE MOD FOR OUT DD
//OUT DD DISP=MOD,DSN=... (FB/5818)
//TOOLIN   DD    *
SORT FROM(IN) USING(CTL1)
COPY FROM(T1) TO(OUT)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(5819:SEQNUM,8,PD)
  SORT FIELDS=(5819,8,PD,D)
  OUTFIL FNAMES=T1,ENDREC=1,BUILD=(1,5818)
  OUTFIL FNAMES=OUT,INCLUDE=(5819,8,PD,EQ,+1),BUILD=(1,5818)
/*
Back to top
View user's profile Send private message
uchekala

New User


Joined: 01 Nov 2007
Posts: 7
Location: chennai

PostPosted: Fri Nov 02, 2007 12:17 am    Post subject: Reply to: Extracting only first and last records in a file
Reply with quote

thanks Frank,

it's working now if it is FB format.

my input file is VB with lrecl=5818 and i want to convert it into FB and copy only first and last records, could you help me to do it.
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: Fri Nov 02, 2007 12:59 am    Post subject:
Reply with quote

Quote:
my input file is VB with lrecl=5818 and i want to convert it into FB and copy only first and last records


Why didn't you say that in your first post? It makes a big difference.

If your input file is VB/5818 and you want to convert it to FB, you wouldn't want the RDW in the FB records, so the output length would be 5814, not 5818. Here's a DFSORT/ICETOOL job to do it.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG  DD  SYSOUT=*
//IN DD DSN=...  input file (VB/5818)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//***> USE MOD FOR OUT DD
//OUT DD DISP=MOD,DSN=... (FB/5814)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=&&O1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//TOOLIN   DD    *
SORT FROM(IN) USING(CTL1)
COPY FROM(T1) TO(OUT)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,4,5:SEQNUM,8,PD,13:5)
  SORT FIELDS=(5,8,PD,D)
  OUTFIL FNAMES=T1,ENDREC=1,VTOF,BUILD=(13,5814)
  OUTFIL FNAMES=OUT,INCLUDE=(5,8,PD,EQ,+1),VTOF,BUILD=(13,5814)
/*
Back to top
View user's profile Send private message
uchekala

New User


Joined: 01 Nov 2007
Posts: 7
Location: chennai

PostPosted: Fri Nov 02, 2007 8:45 pm    Post subject: Reply to: Extracting only first and last records in a file
Reply with quote

Frank,

It worked for me, thanks a ton... you rocks.
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: Thu Sep 04, 2008 2:49 am    Post subject:
Reply with quote

You can now do this more easily and efficiently using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1  EXEC  PGM=ICETOOL                                           
//TOOLMSG   DD  SYSOUT=*                                           
//DFSMSG    DD  SYSOUT=*                                           
//IN DD DSN=...  input file (VB/5818)                                   
//OUT DD DSN=...  output file (FB/5814)     
//TOOLIN DD *                                                     
SUBSET FROM(IN) TO(OUT) KEEP INPUT HEADER TRAILER USING(CTL1)
/*     
//CTL1CNTL DD *                                                   
  OUTFIL FNAMES=OUT,VTOF,BUILD=(5,5814)                           
/*


For complete details on the new SUBSET 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
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 Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm
No new posts Updating a VSAM file with DISP=OLD sheersh JCL & VSAM 8 Tue Mar 14, 2017 6:14 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am


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