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

Sort a Report file which has Headers and Trailers


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bharath_gct2002

New User


Joined: 08 Oct 2007
Posts: 27
Location: Dallas, TX

PostPosted: Thu Aug 21, 2008 4:10 am
Reply with quote

Hi,

I would like to know whether sorting a report file which has headers (more than 1 line) in every page and trailer(more than 1 line) in the last page of the report.

My Input file looks like the below:
Code:

----+----1----+----2----+----3----+----4
****************************************
1REPORT           DATE: 08/20/2008 11:34
0                             PAGE: 0001
  FLD  FL   FLD.   FIELD     
  NO.1 NO.2 No.3   N0.4       
  ---- ---- ---- ----------
  355  000  IDW  0000001210       
  355  000  IDW  0000001231       
  355  000  IDW  0000001231       
  355  000  IDW  0000001231       
  355  000  IDW  0000001232       
  355  000  IDW  0000001164       
  355  000  IDW  0000001164       
  356  000  IDW  0000001164       
  356  000  IDW  0000001164       
  356  000  IDW  0000001143       
  356  000  IDW  0000001162       
  356  000  IDW  0000001155       

 NUMBER OF LINES IN THE REPORT = 0012


If you note the Input contains the header in its first 5 lines on every page and the trailer is present in the last page ad is of 2 lines (1 blank line and a text line). Also the page count for a page is 66 records.

My requirement is to Sort this file with the Field no.1 and then by Field no. 4 and obviously this sort should happen without affecting the header and trailer. The output for this should be:

Code:

----+----1----+----2----+----3----+----4
****************************************
1REPORT           DATE: 08/20/2008 11:34
0                             PAGE: 0001
  FLD  FL   FLD.   FIELD     
  NO.1 NO.2 No.3   N0.4       
  ---- ---- ---- ----------
  355  000  IDW  0000001164       
  355  000  IDW  0000001164       
  355  000  IDW  0000001210       
  355  000  IDW  0000001231       
  355  000  IDW  0000001231       
  355  000  IDW  0000001231       
  355  000  IDW  0000001232       
  356  000  IDW  0000001143       
  356  000  IDW  0000001155       
  356  000  IDW  0000001162       
  356  000  IDW  0000001164       
  356  000  IDW  0000001164       

 NUMBER OF LINES IN THE REPORT = 0012


Please help!!
Thanks in Advance
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Aug 21, 2008 4:34 am
Reply with quote

Hello,

What should happen when there are 100 lines of data and multiple sets of headers for each of the 3 pages needed and some of the data from page 3 needs to be presented on the re-sorted page 1??
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 Aug 21, 2008 4:38 am
Reply with quote

It's not clear what the input report looks like. You show one page, but imply that it's more than one page and that the header lines appear on every page and the trailer lines appear on the last page only. Are you trying to sort the data on all of the pages and keep the header and the same number of data lines on each page as was originally there, or are you trying to sort the data on each page independently, or what?

Please show a better example of input and expected output with multiple pages with records on the last page that sort before records on the first page. That will illustrate what you actually want to do.

Also, give the RECFM and LRECL of the input file.

It appears there's something in each header and trailer record that can identify it, e.g. 'REPORT' starting in position 2, 'PAGE:' in position 31, etc. Is that true?
Back to top
View user's profile Send private message
bharath_gct2002

New User


Joined: 08 Oct 2007
Posts: 27
Location: Dallas, TX

PostPosted: Thu Aug 21, 2008 5:06 am
Reply with quote

Ok.. I am sorry for not making this clear. If there are multiple pages of data, then all the data in all the pages should be sorted and based on the sort the output will be like:

Page 1:
--------
1. Header (5 lines)
2. The first 66 lines after the sorting is done on all the data on all the pages.

Page 2:
----------
1. Header (5 lines)
2. The next 66 lines after the sorting is done on all the data on all the pages.


.
.
.
.
.
.
.
.
.

Last Page:
----------
1. Header (5 lines)
2. The next 66 lines after the sorting is done on all the data on all the pages.
3. Trailer (2 lines).

And Frank, as you said it contains the word REPORT in Column 2 and Page in col 31. The LRECL is 40 and RECFM is Fixed Block.

Let me know if this helps.
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 Aug 21, 2008 6:10 am
Reply with quote

I believe this DFSORT job will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/40)
//SYMHD DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYMTRL DD DSN=&&S2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//DATA DD DSN=&&D1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=DATA,
   OMIT=(2,5,CH,EQ,C'REPORT',OR,
     31,5,CH,EQ,C'PAGE:',OR,
     3,3,CH,EQ,C'FLD',OR,
     3,4,CH,EQ,C'NO.1',OR,
     3,4,CH,EQ,C'----',OR,
     1,10,CH,EQ,C' ',OR,
     2,9,CH,EQ,C'NUMBER OF')
  OUTFIL FNAMES=SYMHD,ENDREC=5,
   IFOUTLEN=80,
   IFTHEN=(WHEN=(2,5,CH,EQ,C'REPORT'),
        BUILD=(C'HLN1,''',1,40,C'''')),
   IFTHEN=(WHEN=(31,5,CH,EQ,C'PAGE:'),
        BUILD=(C'HLN2,''',1,36,C'''')),
   IFTHEN=(WHEN=(3,3,CH,EQ,C'FLD'),
        BUILD=(C'HLN3,''',1,40,C'''')),
   IFTHEN=(WHEN=(3,4,CH,EQ,C'NO.1'),
        BUILD=(C'HLN4,''',1,40,C'''')),
   IFTHEN=(WHEN=(3,4,CH,EQ,C'----'),
        BUILD=(C'HLN5,''',1,40,C''''))
  OUTFIL FNAMES=SYMTRL,
    INCLUDE=(1,10,CH,EQ,C' ',OR,
     2,9,CH,EQ,C'NUMBER OF'),
   IFOUTLEN=80,
   IFTHEN=(WHEN=(1,10,CH,EQ,C' '),
        BUILD=(C'TLN1,''',1,40,C'''')),
   IFTHEN=(WHEN=(2,9,CH,EQ,C'NUMBER OF'),
        BUILD=(C'TLN2,''',1,40,C''''))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//         DD DSN=&&S2,DISP=(OLD,PASS)
//SORTIN DD DSN=&&D1,DISP=(OLD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(3,4,ZD,A,18,10,ZD,A)
  OUTFIL LINES=71,REMOVECC,
    HEADER2=(HLN1,/,HLN2,PAGE=(EDIT=(TTTT)),/,HLN3,/,
      HLN4,/,HLN5),
    TRAILER1=(TLN1,/,TLN2)
/*
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
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top