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
 

 

Delete the last record in an file based on a condition

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

New User


Joined: 01 Aug 2008
Posts: 6
Location: denver

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

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
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Aug 01, 2008 1:27 am    Post subject:
Reply with quote

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
View user's profile Send private message
sundars

New User


Joined: 01 Aug 2008
Posts: 6
Location: denver

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

yes, there can be other blank lines in the input file and
the RECFM is VB and LRECL=454
Back to top
View user's profile Send private message
sundars

New User


Joined: 01 Aug 2008
Posts: 6
Location: denver

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

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Aug 01, 2008 2:21 am    Post subject:
Reply with quote

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
View user's profile Send private message
sundars

New User


Joined: 01 Aug 2008
Posts: 6
Location: denver

PostPosted: Fri Aug 01, 2008 2:51 am    Post subject:
Reply with quote

Frank. Not sure, what you mean, but my input file has all spaces as the last record
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 Aug 01, 2008 3:31 am    Post subject:
Reply with quote

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
View user's profile Send private message
sundars

New User


Joined: 01 Aug 2008
Posts: 6
Location: denver

PostPosted: Fri Aug 01, 2008 4:39 am    Post subject:
Reply with quote

Frank,

last record has a length of 454 and 450 blanks
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 Aug 01, 2008 5:48 am    Post subject:
Reply with quote

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
View user's profile Send private message
sundars

New User


Joined: 01 Aug 2008
Posts: 6
Location: denver

PostPosted: Fri Aug 01, 2008 9:02 pm    Post subject:
Reply with quote

Thanks Frank!!!!
IT works
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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 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 JCL to delete component in a package sundaram.naveen Compuware & Other Tools 14 Tue Nov 29, 2016 6:21 pm


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