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

Edit 1st and last record of a file.


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

New User


Joined: 10 Nov 2006
Posts: 49
Location: Canada

PostPosted: Fri Mar 16, 2007 4:04 pm
Reply with quote

Hi,
I want to edit 1st and Last record of a file. All records are similar and we cannot differentiate between them.

eg:- Input File :-
'111111',
'222222',
'333333',
'444444',

Desired output file:-
('111111',
'222222',
'333333',
'444444');

The 1st record should be prefixed with OPEN BRACKET ( and for the LAST record COMMA should be removed and suffixed with CLOSE BRACKET ) and SEMI COLON ;

Can anybody please suggest the most appropiate way.

Thanks
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Fri Mar 16, 2007 5:33 pm
Reply with quote

Hi,

Why can't you use REXX to do that.


Sai
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Mar 16, 2007 5:43 pm
Reply with quote

Using a programming language this would be easy, you know when it's the first record, and at EOF, you know when it's the last record.
With sort, the trick is figuring out when you have the last record, but as shown several times in this forum and in DFSORT's Smart Tricks manual.
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Fri Mar 16, 2007 8:56 pm
Reply with quote

If you are looking for attaching this to a query..I think we could do this by single sort with sort card as:

Code:

   INREC  IFTHEN=(WHEN=INIT,                                     
               BUILD=(1,70,71:SEQNUM,4,ZD)),                   
       IFTHEN=(WHEN=(71,4,ZD,EQ,1),                           
               BUILD=(1:1,8,9:C') ',11:11,70)),               
       IFTHEN=(WHEN=(71,4,ZD,EQ,2),                           
               BUILD=(1:C'(',2:1,9,11:11,60,71:C'9999')),     
       IFOUTLEN=80                                             
   SORT FIELDS=(71,4,ZD,D)                                       
   OUTREC FIELDS=(1,70,10X)                                       


Code:

'111111',   
'222222',   
'333333',   
'444444',   


will be formatted to

Code:

('222222',   
'444444',     
'333333',     
'111111')   


I presume that order will not be a problem if you are attaching this to a query...
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 Mar 16, 2007 9:05 pm
Reply with quote

kaushik8205,

Here's a DFSORT job that will produce the output in the order you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//S1 DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(81:SEQNUM,8,ZD)
  OUTFIL FNAMES=T1
  OUTFIL FNAMES=S1,REMOVECC,NODETAIL,
    BUILD=(80X),
    TRAILER1=('LASTREC,+',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 (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
    IFTHEN=(WHEN=(81,8,ZD,EQ,+1),
      BUILD=(C'(',1,9)),
    IFTHEN=(WHEN=(81,8,ZD,EQ,LASTREC),
      BUILD=(1,8,C');'))
/*


SORTOUT will have:

Code:

('111111',     
'222222',     
'333333',     
'444444');     
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top