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

Sorting ONLY DETAIL Recs keeping HEADER & TRAILER as it


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Wed Jun 13, 2007 4:00 pm
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 Developer


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

PostPosted: Wed Jun 13, 2007 9:19 pm
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
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 Developer


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

PostPosted: Thu Jun 14, 2007 9:08 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
No new posts Creating CSV file from Variable recs ... DFSORT/ICETOOL 11
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
Search our Forums:

Back to Top