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
 

 

Sorting ONLY DETAIL Recs keeping HEADER & TRAILER as it

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sivaraj.ramaraj
Currently Banned

New User


Joined: 04 May 2007
Posts: 3
Location: softwarew

PostPosted: Wed Jun 13, 2007 3:49 pm    Post subject: Sorting ONLY DETAIL Recs keeping HEADER & TRAILER as it
Reply with quote

Hi ,

I have some problem in sorting a file using DFSORT.Scenario is like,
I have to sort a file based on some reference number. But actual file is variable length format and the file format is like

T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000005
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000008
T20 - Detail - 166 bytes - 0000000000000009
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000001
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000010
T20 - Detail - 166 bytes - 0000000000000018
T20 - Detail - 166 bytes - 0000000000000013
T20 - Detail - 166 bytes - 0000000000000015
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000004
T20 - Detail - 166 bytes - 0000000000000002
T20 - Detail - 166 bytes - 0000000000000001
T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000002345
T20 - Detail - 166 bytes - 0000000000001234

The output should be

T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000003
T20 - Detail - 166 bytes - 0000000000000005
T20 - Detail - 166 bytes - 0000000000000008
T20 - Detail - 166 bytes - 0000000000000009
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000001
T20 - Detail - 166 bytes - 0000000000000002
T20 - Detail - 166 bytes - 0000000000000004
T20 - Detail - 166 bytes - 0000000000000010
T20 - Detail - 166 bytes - 0000000000000013
T20 - Detail - 166 bytes - 0000000000000015
T20 - Detail - 166 bytes - 0000000000000018
T10 - Header - 238 bytes
T30 - Trailer - 143 bytes
T20 - Detail - 166 bytes - 0000000000001234
T20 - Detail - 166 bytes - 0000000000002345

We want to sort ONLY the DETAIL records based on some reference number with an offset of (154 : 9) in DETAIL record.

Here we want to keep both HEADER and TRAILER records as it is without sorting.

Can we handle this total process in a one DFSORT step?

Could anybody please suggest the solution.

Thanks in advance,
Siva
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 13, 2007 4:00 pm    Post subject:
Reply with quote

Take a look at this thread which may help you

http://www.ibmmainframes.com/viewtopic.php?t=20599&highlight=sort+header+trailer
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: Wed Jun 13, 2007 9:19 pm    Post subject:
Reply with quote

sivar,

The indicated trick only works for one header and one trailer. You have multiple headers and trailers, so you need a different trick.

I need more information to give you a solution:

It appears that groups 1 and 3 have a header and trailer, but group 2 only has a trailer. Is that the way the data really looks? Can a group start with just a header, just a trailer, or a header and a trailer? Or is it more restrictive than that (each group starts with a header and trailer but you forgot the header for group2)?

What is the LRECL of the input file?

I assume 154 does not include the RDW in positions 1-4 so the starting position is really 158 - right?
Back to top
View user's profile Send private message
sivaraj.ramaraj
Currently Banned

New User


Joined: 04 May 2007
Posts: 3
Location: softwarew

PostPosted: Thu Jun 14, 2007 8:57 am    Post subject: Sorting ONLY DETAIL Recs keeping HEADER & TRAILER as it
Reply with quote

Hi Frank,

Yes, the indicated trick only works for one header and one trailer. But I am having multiple headers and trailers.

Each group having header,trailer and detail. sorry Frank I forgot to add header for group2.

Input file RECFM=VB,LRECL=255

Yes, Starting position is 158 of length 9 bytes packed Decimal
(i.e PIC 9(16) COMP-3) only in DETAIL.

Thanks
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: Thu Jun 14, 2007 9:08 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB/255)
//SORTOUT DD DSN=...  output file (VB/255)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,
          BUILD=(1,4,5:C'2',6:SEQNUM,8,ZD,22:5)),
        IFTHEN=(WHEN=(22,3,CH,EQ,C'T10'),
                OVERLAY=(5:C'0',6:SEQNUM,8,ZD),HIT=NEXT),
        IFTHEN=(WHEN=(22,3,CH,EQ,C'T30'),
                OVERLAY=(5:C'1'),HIT=NEXT),
        IFTHEN=(WHEN=(22,3,CH,NE,C'T10'),
                OVERLAY=(14:SEQNUM,8,ZD,
                         6:6,8,ZD,SUB,14,8,ZD,M11,LENGTH=8))
  SORT FIELDS=(6,8,ZD,A,5,1,CH,A,175,9,PD,A)
  OUTREC BUILD=(1,4,5:22)
/*
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 How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm


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