IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

Delete the last record in an file based on a condition

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
View previous topic :: View next topic  
Author Message
sundars



Joined: 01 Aug 2008
Posts: 6
Location: denver

Posted: Fri Aug 01, 2008 1:16 am    Post subject: Delete the last record in an file based on a condition  

Can we delete/skip the last record in a file from getting copied into an output file, only if the last record is a blank line?
Back to top  
Frank Yaeger



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

Posted: Fri Aug 01, 2008 1:27 am    Post subject:  

Can there be other blank lines in the input file or would the last line be the only blank line in the file?

What is the RECFM and LRECL of the input file?

Please show an example of what the input records look like.
Back to top  
sundars



Joined: 01 Aug 2008
Posts: 6
Location: denver

Posted: Fri Aug 01, 2008 1:43 am    Post subject: Delete the last record in an file based on a condition  

yes, there can be other blank lines in the input file and
the RECFM is VB and LRECL=454
Back to top  
sundars



Joined: 01 Aug 2008
Posts: 6
Location: denver

Posted: Fri Aug 01, 2008 1:45 am    Post subject: Delete the last record in an file based on a condition  

OOPS missed the sample and here it is
Sample input file:
I/p file:
123456789
123456789

8910111234
8910111234

9911111111
--->Last RECord
EOF
Back to top  
Frank Yaeger



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

Posted: Fri Aug 01, 2008 2:21 am    Post subject:  

Since it's a VB record, we need to know what a blank record will look like. Will it be a 5-byte record with one blank data byte, or could it have more than one blank data byte? If it can have any number of blank data bytes, that will complicate things.
Back to top  
sundars



Joined: 01 Aug 2008
Posts: 6
Location: denver

Posted: Fri Aug 01, 2008 2:51 am    Post subject:  

Frank. Not sure, what you mean, but my input file has all spaces as the last record
Back to top  
Frank Yaeger



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

Posted: Fri Aug 01, 2008 3:31 am    Post subject:  

S.Sudhir.

A VB record has a 4-byte RDW with the length followed by data bytes.

So saying "my input file has all spaces as the last record" doesn't really tell me anything.

Do you mean that the last record has a length of 454 and 450 blanks like this in hex:

X'01C6000040...40' (540 X'40's)

Or does the last record have a length of 5 and one blank like this in hex:

X'000540'

or something else?

If you don't know, use this DFSORT job to display your blank last record in hex and post the results:

Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC BUILD=(1,4,1,4,HEX,5,HEX)
/*
Back to top  
sundars



Joined: 01 Aug 2008
Posts: 6
Location: denver

Posted: Fri Aug 01, 2008 4:39 am    Post subject:  

Frank,

last record has a length of 454 and 450 blanks
Back to top  
Frank Yaeger



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

Posted: Fri Aug 01, 2008 5:48 am    Post subject:  

Ok, that makes things easier.

With z/OS DFSORT V1R5 PTF UK90013 (July, 2008) you can use this DFSORT/ICETOOL job. If you don't have this PTF installed, ask your System Programmer to install it. Alternatively, use the second more complex job shown below.

Code:
//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (VB/454)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//*** Use MOD for //OUT
//OUT DD DISP=MOD, DSN=...  MOD output file (VB/454)
//TOOLIN DD *
* Write n-1 records to MOD //OUT data set.
* Write last record to //T1 data set.
SUBSET FROM(IN) TO(OUT) INPUT REMOVE LAST DISCARD(T1)
* Write last record to MOD //OUT data set if it's not blank
COPY FROM(T1) TO(OUT) USING(CTL1)
//CTL1CNTL DD *
  OPTION VLSCMP
* Don't copy the last record to //OUT if it has 450 blanks.
  OUTFIL FNAMES=OUT,
    INCLUDE=(1,2,BI,NE,454,OR,5,450,SS,NE,C' ')
/*


If you can't use SUBSET, you can use this more complex multistep DFSORT job. Use your input file in all three steps. Use your output file in steps 2 (NEW) and 3 (MOD).

Code:
//S1  EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB/454)
//C1 DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//C2 DD DSN=&&C2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
 OPTION COPY
 OUTFIL FNAMES=C1,REMOVECC,NODETAIL,VTOF,BUILD=(80X),
   TRAILER1=('  OPTION COPY,STOPAFT=',COUNT-1=(M11,LENGTH=8))
 OUTFIL FNAMES=C2,REMOVECC,NODETAIL,VTOF,BUILD=(80X),
   TRAILER1=('  OPTION COPY,VLSCMP,SKIPREC=',COUNT-1=(M11,LENGTH=8))
/*
//S2  EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB/454)
//SORTOUT DD DISP=NEW,DSN=output,...  NEW output file (VB/454)
//SYSIN DD DSN=&&C1,DISP=(OLD,PASS)
//S3  EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB/454)
//OUT DD DISP=MOD,DSN=output    MOD output file (VB/454)
//SYSIN DD DSN=&&C2,DISP=(OLD,PASS)
// DD *
  OUTFIL FNAMES=OUT,
    INCLUDE=(1,2,BI,NE,454,OR,5,450,SS,NE,C' ')
/*
Back to top  
sundars



Joined: 01 Aug 2008
Posts: 6
Location: denver

Posted: Fri Aug 01, 2008 9:02 pm    Post subject:  

Thanks Frank!!!!
IT works
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM