Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Edit 1st and last record of a file.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Edit 1st and last record of a file.
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Mar 16, 2007 5:43 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Mar 16, 2007 9:05 pm    Post subject:
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    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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us