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

Replace the value only for the last record.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Huan-Nguyen

New User


Joined: 17 Jan 2006
Posts: 17

PostPosted: Tue Nov 27, 2007 6:47 am
Reply with quote

I need to replace the value @ and # to blank (space) only for the last record in the input file(record format VB and rec length 512)

Input file

Code:

123456789@@@
ABCD12456578NNNNN
NNNNNVVVVVVV
XXXXXXXXXXXXXMMMMMMMMM@@@@@NNNNNNNN###VVV


Expected Output

Code:

123456789@@@
ABCD12456578NNNNN
NNNNNVVVVVVV
XXXXXXXXXXXXXMMMMMMMMM     NNNNNNNN   VVV
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Nov 27, 2007 8:43 am
Reply with quote

Huan,

Is there a way to identify the last record directly?
Back to top
View user's profile Send private message
vkphani

New User


Joined: 29 Oct 2003
Posts: 29

PostPosted: Tue Nov 27, 2007 10:59 am
Reply with quote

Huan-Nguyen,

As it is only for teh last record you wanna change, why don't you just edit the file and put spaces.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Nov 27, 2007 11:02 am
Reply with quote

Phani,

Quote:
As it is only for teh last record you wanna change, why don't you just edit the file and put spaces.

You suggestion might be good for dev file but not on PROD files.
Back to top
View user's profile Send private message
Huan-Nguyen

New User


Joined: 17 Jan 2006
Posts: 17

PostPosted: Tue Nov 27, 2007 11:13 am
Reply with quote

murmohk1 wrote:
Huan,

Is there a way to identify the last record directly?

I will change the design to identify the last record. Thanks,
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Tue Nov 27, 2007 12:29 pm
Reply with quote

Huan-Nguyen,

Please check with the folllowing code for your requirement.
Code:
//S EXEC PGM=SORT                                                   
//SORTIN DD DSN=XXXXX.YYYYYYY.V512,DISP=OLD                         
//SORTOUT DD DSN=&&SYMNAMES,DISP=(,PASS)                             
//SYSOUT DD SYSOUT=*                                                 
//SYSIN DD *                                                         
 OPTION COPY                                                         
 OUTFIL REMOVECC,NODETAIL,VTOF,BUILD=(80X),                         
 TRAILER1=(C'LASTREC,+',COUNT=(M11,LENGTH=8),80:X)                   
/*                                                                   
// EXEC PGM=SORT                                                     
//SORTIN DD DSN=XXXXX.YYYYYYY.V512,DISP=OLD                         
//SYMNAMES DD DSN=*.S.SORTOUT,DISP=(OLD,DELETE),VOL=REF=*.S.SORTOUT 
//SORTOUT DD DSN=XXXXX.YYYYYYY.V512.OUT,DISP=(,CATLG),               
// DCB=(XXXXX.YYYYYYY.V512),SPACE=(CYL,(1,1))                       
//SYSOUT DD SYSOUT=*                                                 
//SYSIN DD *                                                         
 OPTION COPY                                                         
 ALTSEQ CODE=(7B40,7C40)                                           
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(513:SEQNUM,8,ZD)),               
 IFTHEN=(WHEN=(513,8,ZD,EQ,LASTREC),OVERLAY=(5:5,508,TRAN=ALTSEQ))
 OUTFIL OUTREC=(1,4,5,508)
/*                                       
//                                                                 

Input:
Code:
123456789@@@                             
ABCD12456578NNNNN                         
NNNNNVVVVVVV                             
XXXXXXXXXXXXXMMMMMMMMM@@@@@NNNNNNNN###VVV

Output:
123456789@@@
Code:
ABCD12456578NNNNN                         
NNNNNVVVVVVV                             
XXXXXXXXXXXXXMMMMMMMMM     NNNNNNNN   VVV
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: Tue Nov 27, 2007 10:53 pm
Reply with quote

Huan,

Shankar's "solution" will pad your variable length records with blanks so they will ALL be 512 bytes. So a record that was 20 bytes long will be increased to 512 bytes long. This is a very bad idea as it negates the reason for having a VB file. (This is a case of a little knowledge being a dangerous thing.)

Here's a DFSORT job that will do what you want and preserve your original record lengths:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB/512)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=T1,BUILD=(1,4,5:SEQNUM,8,ZD,13:5)
  OUTFIL FNAMES=SYM,NODETAIL,REMOVECC,VTOF,
    BUILD=(80X),
    TRAILER1=('TARG,+',COUNT=(M11,LENGTH=8))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//SORTOUT DD DSN=...  output file (VB/512)
//SYSIN    DD    *
  OPTION COPY
  ALTSEQ CODE=(7B40,7C40)
  INREC IFTHEN=(WHEN=(5,8,ZD,EQ,TARG),
    BUILD=(1,4,5:13,TRAN=ALTSEQ)),
   IFTHEN=(WHEN=NONE,BUILD=(1,4,5:13))
/*
Back to top
View user's profile Send private message
Huan-Nguyen

New User


Joined: 17 Jan 2006
Posts: 17

PostPosted: Wed Nov 28, 2007 7:07 am
Reply with quote

Frank,

Thank you very much for your help. I will try to run it by tomorrow and will let you know the result . Thanks,
Back to top
View user's profile Send private message
Huan-Nguyen

New User


Joined: 17 Jan 2006
Posts: 17

PostPosted: Sat Dec 01, 2007 5:22 am
Reply with quote

Frank,

It works perfectly with your JCL. Many thanks,
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top