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
 
sort records under sub-header

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

Active User


Joined: 01 Feb 2007
Posts: 120
Location: Hyderabad

PostPosted: Tue May 12, 2009 2:33 pm    Post subject: sort records under sub-header
Reply with quote

Hi,

I had a file in below format.

Code:

000SSC ORDERS          207649220090507120353WFPOM      - MAIN HEADER 
030A7082598011111S708259801                            - SUB HEADER   
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
031AAAA3333220903054544010601800000000411111708259801  - DETAIL RECORD
031BBBB3333220903054544010604200000000411111708259801  - DETAIL RECORD
031CCCC3333220903054544010608300000000611111708259801  - DETAIL RECORD
031DDDD3333220903054544010611700000000611111708259801  - DETAIL RECORD
030A7082598555555S708259851                            - SUB HEADER   
03170825985944903054544010601800000001655555708259851  - DETAIL RECORD
03170825985944903054544010604200000001655555708259851  - DETAIL RECORD
999000011195                                           - TRAILER     


1-3 -> ID
17-31 -> Sort Key
LRECL = 53
RECFM = FB

Header is identified by 000
Trailer is identified by 999
Sub Header is identified by 030
Detail record is identified by 031

i want to sort detail records under each sub header. Kindly guide me how i can do this.
Back to top
View user's profile Send private message

expat

Global Moderator


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

PostPosted: Tue May 12, 2009 4:46 pm    Post subject:
Reply with quote

Click HERE to view DFSORT smart tricks, and see the section sort groups of records, which I believe will help you.
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: Tue May 12, 2009 8:56 pm    Post subject:
Reply with quote

Bhaskar,

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

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/53)
//SORTOUT DD DSN=...  output file (FB/53)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,SS,EQ,C'000,030,999'),
    PUSH=(54:ID=8))
  SORT FIELDS=(54,8,ZD,A,1,3,CH,A,17,15,CH,A)
  OUTREC BUILD=(1,53)
/*
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 120
Location: Hyderabad

PostPosted: Wed May 13, 2009 4:33 pm    Post subject: Reply to: sort records under sub-header
Reply with quote

Hi Frank,

Thanks for providing solution. But my installation doesnt support WHEN=GROUP option. Is there any other way other than this. Kindly let me know whenther we can do this other than this option.
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 May 13, 2009 9:01 pm    Post subject:
Reply with quote

Here's a DFSORT job without WHEN=GROUP that will do what you asked for:

Code:

//S2    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/53)
//SORTOUT DD DSN=...  output file (FB/53)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(54:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,3,SS,EQ,C'000,030,999'),
                OVERLAY=(54:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(62:SEQNUM,8,ZD,
                         54:54,8,ZD,SUB,62,8,ZD,TO=ZD,LENGTH=8))
  SORT FIELDS=(54,8,ZD,A,1,3,CH,A,17,15,CH,A)
  OUTREC BUILD=(1,53)
/*
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 120
Location: Hyderabad

PostPosted: Thu May 14, 2009 11:24 am    Post subject: Reply to: sort records under sub-header
Reply with quote

Hi Frank,

Excellent solution. This job worked perfectly. The logic you have coded is simple and nice. thank you so much frank.
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 Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm
No new posts SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am

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