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
 

 

Trailer records beyond end-of-record must be moved, but how?

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

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Wed Jul 14, 2010 7:40 pm    Post subject: Trailer records beyond end-of-record must be moved, but how?
Reply with quote

I have a dataset with the following structure:

Code:
 
DATASET-HEADER - several records (number unknown) to describe the data.
RECORD1-START (identifiable)
...
data records (number unknown)
...
RECORD1-END  (identifiable)
RECORD1-TRAILER-DATA (exactly 3 records)
RECORD2-START  (identifiable)
...
data records (number unknown)
...
RECORD2-END  (identifiable)
RECORD2-TRAILER-DATA (exactly 3 records)
..
and so on until end of data.


My task is to "move" the 3 RECORD-TRAILER-DATA records, so that they appear right before each RECORD-END in the same order as before. If you choose, you can move the RECORD-END below the 3 RECORD-TRAILERs - the result should be the same.

Consider the following INPUT (RECFM=FB,LRECL=80:

Code:

HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
RECORD1-START
DATA-RECORD1
DATA-RECORD2
DATA-RECORD3
DATA-RECORD4
DATA-RECORD5
DATA-RECORD6
RECORD1-END
RECORD1-TRAILER-DATA1
RECORD1-TRAILER-DATA2
RECORD1-TRAILER-DATA3
RECORD2-START
DATA-RECORD7
DATA-RECORD8
DATA-RECORD9
DATA-RECORD10
DATA-RECORD11
DATA-RECORD12
RECORD2-END
RECORD2-TRAILER-DATA1
RECORD2-TRAILER-DATA2
RECORD2-TRAILER-DATA3


Expected output:

Code:

HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
RECORD1-START
DATA-RECORD1
DATA-RECORD2
DATA-RECORD3
DATA-RECORD4
DATA-RECORD5
DATA-RECORD6
RECORD1-TRAILER-DATA1
RECORD1-TRAILER-DATA2
RECORD1-TRAILER-DATA3
RECORD1-END (moved)
RECORD2-START
DATA-RECORD7
DATA-RECORD8
DATA-RECORD9
DATA-RECORD10
DATA-RECORD11
DATA-RECORD12
RECORD2-TRAILER-DATA1
RECORD2-TRAILER-DATA2
RECORD2-TRAILER-DATA3
RECORD2-END (moved)


Can anyone help me solve this? I'm running DFSORT V1R10.
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jul 14, 2010 10:03 pm    Post subject: Reply to: Trailer records beyond end-of-record must be moved
Reply with quote

Claes Norreen,

The following DFSORT JCL will give you the desired results. I assumed that each group starts with word "start" in pos 9 and the RECORD-END will be the only record which will have END at pos 9. This record will be moved to the end of the group.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
HEADER-RECORD                                                           
HEADER-RECORD                                                           
HEADER-RECORD                                                           
HEADER-RECORD                                                           
HEADER-RECORD                                                           
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
RECORD1-START                                                           
DATA-RECORD1                                                           
DATA-RECORD2                                                           
DATA-RECORD3                                                           
DATA-RECORD4                                                           
DATA-RECORD5                                                           
DATA-RECORD6                                                           
RECORD1-END                                                             
RECORD1-TRAILER-DATA1                                                   
RECORD1-TRAILER-DATA2                                                   
RECORD1-TRAILER-DATA3                                                   
RECORD2-START                                                           
DATA-RECORD7                                                           
DATA-RECORD8                                                           
DATA-RECORD9                                                           
DATA-RECORD10                                                           
DATA-RECORD11                                                           
DATA-RECORD12                                                           
RECORD2-END                                                             
RECORD2-TRAILER-DATA1                                                   
RECORD2-TRAILER-DATA2                                                   
RECORD2-TRAILER-DATA3                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(9,5,CH,EQ,C'START'),PUSH=(81:ID=8)), 
  IFTHEN=(WHEN=(9,3,CH,EQ,C'END'),OVERLAY=(89:C'1'))                   
  SORT FIELDS=(81,9,CH,A),EQUALS         
  OUTREC BUILD=(1,80)                             
//*
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Jul 15, 2010 12:30 am    Post subject: Reply to: Trailer records beyond end-of-record must be moved
Reply with quote

Simple and straightforward! Much better than the solution I was able to come up with. Thanks a lot! :-)
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Jul 15, 2010 1:35 pm    Post subject:
Reply with quote

Unfortunately I messed the input up a bit. icon_cry.gif Sorry about that. Can you give directions on this one too, please? The big difference is that a new record actually start before the trailer data. I also added the EOF-marker.

Also, TRAILER-DATA2 and TRAILER-DATA3 are identical, and if possible, one of them should be removed from the output.

Code:

HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
HEADER-RECORD
RECORD1-START
DATA-RECORD1
DATA-RECORD2
DATA-RECORD3
DATA-RECORD4
DATA-RECORD5
DATA-RECORD6
RECORD1-END
RECORD2-START
RECORD1-TRAILER-DATA1
RECORD1-TRAILER-DATA2
RECORD1-TRAILER-DATA3
DATA-RECORD7
DATA-RECORD8
DATA-RECORD9
DATA-RECORD10
DATA-RECORD11
DATA-RECORD12
RECORD2-END
RECORD3-START
RECORD2-TRAILER-DATA1
RECORD2-TRAILER-DATA2
RECORD2-TRAILER-DATA3
DATA-RECORD13
DATA-RECORD14
DATA-RECORD15
DATA-RECORD16
DATA-RECORD17
DATA-RECORD18
RECORD3-END
RECORD3-TRAILER-DATA1
RECORD3-TRAILER-DATA2
RECORD3-TRAILER-DATA3
END-OF-FILE-RECORD
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Jul 15, 2010 1:51 pm    Post subject:
Reply with quote

With your code, it proved not to be too difficult - even for me: icon_wink.gif

Code:

  INREC IFTHEN=(WHEN=GROUP,BEGIN=(9,3,CH,EQ,C'END'),PUSH=81:ID=8)),
        IFTHEN=(WHEN=(9,7,CH,EQ,C'TRAILER'),OVERLAY=(89:C'1'))                         
  SORT FIELDS=(81,8,CH,A,89,1,CH,D),EQUALS       
  OUTREC BUILD=(1,80)


Still interested in the removal of the duplicate TRAILER-record, if you can guide me?

Thanks,
Claes
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jul 15, 2010 9:46 pm    Post subject: Reply to: Trailer records beyond end-of-record must be moved
Reply with quote

Claes Norreen,

Use the following control cards. This will retain the first 2 trailer records

Code:

//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(9,3,CH,EQ,C'END'),PUSH=(81:ID=8)),
  IFTHEN=(WHEN=(9,7,CH,EQ,C'TRAILER'),                             
  OVERLAY=(89:C'1',SEQNUM,1,ZD,RESTART=(81,8)))                     
  SORT FIELDS=(81,8,CH,A,89,1,CH,D),EQUALS                         
  OUTFIL OMIT=(90,1,ZD,GT,2),BUILD=(1,80)                           
//*
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 Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


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