IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Delete the last record in an file based on a condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Fri Aug 01, 2008 1:27 am
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
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
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 Developer


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

PostPosted: Fri Aug 01, 2008 2:21 am
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
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 Developer


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

PostPosted: Fri Aug 01, 2008 3:31 am
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
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 Developer


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

PostPosted: Fri Aug 01, 2008 5:48 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts DELETE SPUFI DB2 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top