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

Sort a file excluding page headers ?


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

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Wed Jun 15, 2011 1:01 pm
Reply with quote

Hi,

I have a following requirement in sorting records in a file.

I have a file with DATE, member id along with page headers in between.

Sample Layout as shown below

Code:
PAGE HEADER1    PAGE NO: 1 TIME:XXXX DATE XXX
MEMID4  20020101
MEMID2  20020501
MEMID3  20020501
MEMID1  20020102
PAGE HEADER2    PAGE NO: 2 TIME:XXXX DATE XXX
MEMID7  20020104
MEMID9  20040501
MEMID3  20020501
MEMID2  20060102


I want to sort the file based on date keeping the headers intact.

Can this be achieved using DFSORT?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 1:05 pm
Reply with quote

Certainly. Would you like to decide what you want it sorted on? Does the sort take place within the page? Otherwise keeping the headers is a bit of a nonsense. Why don't you sort the data going in to the report?
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Wed Jun 15, 2011 1:58 pm
Reply with quote

I want to sort the file based on date keeping the headers intact.
The input data(The records along with the headers) is coming from a separate system so we do not have the liberty to sort the data going in to the report. We only have the report as input to us unfortunately icon_sad.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 15, 2011 2:06 pm
Reply with quote

Frank, Kolusu
(or any of the members here that write DFSORT control statements for free)

will need some details.

Record Type,
Record Length
Identifying characteristics of a 'Header'.
field assignment (position, datatype)
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Wed Jun 15, 2011 2:37 pm
Reply with quote

Thanks..

The record type is FB and with LRECL = 300
The date that is to be sorted is of length 8 bytes starting at position 25.
After sorting the record based on DATEIN field the headers/trailers should be intact.

The sample file content is as below

Code:
06/04/11          WELCOME TO ABC CORP     page 1     
03:55                                   
-----------------------------------------
MEMBER ID     DATE IN
-----------------------------------------
abcf123       20050501
def1122       20030401
gihi545       20070401

06/04/11          WELCOME TO ABC CORP     page 2     
03:55                                   
-----------------------------------------
MEMBER ID     DATE IN
-----------------------------------------
abcf456       20000501
def1666       20040401
gihi111       20020401
--------end of report----------------------
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 2:46 pm
Reply with quote

seahawk789 wrote:
I want to sort the file based on date keeping the headers intact.
The input data(The records along with the headers) is coming from a separate system so we do not have the liberty to sort the data going in to the report. We only have the report as input to us unfortunately icon_sad.gif


To confirm, by "keeping the headers intact" you want the data sorted within the existing report page.

You will have to be able to reliably identify the headings where they start and end. What about blank lines?

What does it look like when it goes-over-a-page with the same grouping? Do you want them sorted across the group as a whole, or on the actual existing pages when there is an inconvenient page-break? What is the existing report grouped on?
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Wed Jun 15, 2011 3:03 pm
Reply with quote

Yes , by "keeping the headers intact" I want the data sorted within the existing report page.

I want them sorted across the group as a whole. i.e it should seem like the file was initially sorted based on the whole based on date(pos 80,leng10) and then headers were inserted.

The headers start at pos 1 and end at 80
Header description is as follows
The Line one of headers will always have 'welcome' at position 40.
LINE2 will have 'REPORT' at POSITION 35. (I have not shown that above)
LINE3 will contain '-------' in first 50 positions
Line4 will contain 'MEMBERID' starting at position 1.
LINE5 will contain '-------' in first 50 positions
Also lines having spaces in first 5 positions also should be considered as part of the header (that should not be considered for sorting either).
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 3:18 pm
Reply with quote

I still don't see in your example what has cause the "break" to make a new page between your first two sample pages.

This might be needed if you have, say, 80 items which are within a "break", so would print on two pages, but need to be sorted so that different data can appear on 1st/2nd page than appeared before. That'll be the tricky part of the problem.

Apart from that, if you turn-it-upside-down. The identification of the non-data-lines is complex. So, can the data-lines be reliably idenfitied (like date starting with "20")? Then there is non-data, retain original sequence, data, for instance set all in group to seq number of first data line, then sort on date. Then sort whole kit-and-kaboodle on sequence and date (can be set to zero, or whatever, for all non-data).

But, you have that tricky bit. Without knowing the control information which has caused the break and which hasn't caused the 2nd-type-of-break, which was just the page filling up.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Wed Jun 15, 2011 4:09 pm
Reply with quote

ohh its getting complicated..
Do u have any examples where u don't include certain records for sorting but include them in the sort output?
I mean if u use omit condition, it will be excluded completely, but I want it to be excluded only from sorting logic but has to be present in the output?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 4:17 pm
Reply with quote

It is not too complicated. Except for the lack of control information for when it crosses a page. That can be the killer.

Otherwise, I'm sure the wizards can do if you don't manage it yourself. Look through the forum, you'll see aparently complex things which can be dealt with.

But, lacking control information (not used to seeing a report with nothing to indicate why it paginates like that, personally) then you'd have to go back to the report producer to get reliable output, I think.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 15, 2011 4:24 pm
Reply with quote

from the overall wording the detail sort should take place only within the current layout of pages,
and leave the overall report aspect the same
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 4:34 pm
Reply with quote

Yes, enrico, but...

If you have a group of data with 80 items, it gets the page-break for being a new group of data and a page-break for filling up the page. Items on the second page of the group might, if you were able to sort, appear on the first page logically, and vice versa. What if there are 300 lines in a logical group?

OK, not what the TS asked for, but I bet the user won't be happy with "Oh, and if the page is full, just have a quick check on the next page(s) as well".

Other than this problem, I think it is fairly straightforward.

Even with the control information it would increase the complexity. With the control information, and if too complex, I'd go for extracting the data from this report and doing a new report from that data.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 15, 2011 4:42 pm
Reply with quote

Yep...
but, as You have noticed already, people around here are concerned only about the lowly technicalities ,
not about logical application/organization/common_practce wise solutions !

and as long as they get a ready to run solution they do not care about anything else
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 15, 2011 4:47 pm
Reply with quote

seahawk789,

you are not consistant with your header information.

I would suggest that you
  • provide an accurate description (cut&paste) of the headers - you have several.
  • accurate description of the detail lines


by looking at your Report it appears to be a listing of people and a date.
the afore talked-about control breaks appear to be number of lines.

if the above is true, one solution would be
  1. toolstep1
    • save the first n number of lines - as they are headers to temp1 file
    • omit all headers, writing all detail to temp2
  2. sort the detail (temp2) giving temp3
  3. merge modified versions of temp1 with temp3
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 5:09 pm
Reply with quote

's why I asked about necessity to keep data within page originally appeared on. Confirmed by TS. Only sense I can see to that is that it is some part of a "group". If not, then I'd go back to this:

Quote:
The identification of the non-data-lines is complex. So, can the data-lines be reliably idenfitied (like date starting with "20")? Then there is non-data, retain original sequence, data, for instance set all in group to seq number of first data line, then sort on date. Then sort whole kit-and-kaboodle on sequence and date (can be set to zero, or whatever, for all non-data).


Although, if not in groups, not necessary to be on original page, so the above would be fine as well. Unless the user of the original contacts the user of the new and talks about "I have this item on page 17..."
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Jun 15, 2011 5:19 pm
Reply with quote

This requirement is a lot of crap. The TS shows input that is clearly output
of a utility. That utility can not be used to reproduce the output sorted on date? Or to sort the input of that utility on date?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 5:29 pm
Reply with quote

Been there Peter. It is from an external source. Certainly worth a go at getting it changed, even if "external" has to do it.

Then they post here...
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Wed Jun 15, 2011 5:55 pm
Reply with quote

Bill, for me its not in groups, and its not necessary to be on original page. only thing I want to insert the respective page headers after 80 lines. That is page 1 header should be placed after first set of 80 lines and page2 header after 180 lines and so on..
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 6:29 pm
Reply with quote

seahawk789 wrote:
Yes , by "keeping the headers intact" I want the data sorted within the existing report page.

I want them sorted across the group as a whole. i.e it should seem like the file was initially sorted based on the whole based on date(pos 80,leng10) and then headers were inserted.

[...]


Mmmm... I missed the second paragraph. To me, contradicts the first, but I probably wasn't clear enough.

dbz got it. Either approach sh/would work.

Without the example dbz has asked for, you'll just have to change positions from any provided solutions.

So, data-lines copied out, sorted on date, acquires sequence number. Original data-lines aquire sequence number. Re-insert sorted into original (with report headings, blank lines, end of report, and everything already on it), based on generated sequence numbers. Drop generated sequence numbers.

Cake anyone?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jun 15, 2011 7:43 pm
Reply with quote

seahawk789,
See if below works... I have tried to create header records matching all 6 of your header conditions but if you have more you need to add them in the 3rd IFTHEN condition.

For future reference, please try to provide sample test data matching all of your condition.
Code:
//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
HEADER COND1                           WELCOME                 
HEADER COND2                      REPORT                       
--------------------------------------------------HEADER COND3
MEMBERID HEADER COND4                                         
--------------------------------------------------HEADER COND5
     HEADER COND6                                             
MEMID4                  20020101                               
MEMID4                  20020101                               
MEMID2                  20020501                               
MEMID3                  20020501                               
MEMID1                  20020102                               
HEADER COND1                           WELCOME                 
HEADER COND2                      REPORT                       
--------------------------------------------------HEADER COND3
MEMBERID HEADER COND4                                         
--------------------------------------------------HEADER COND5
     HEADER COND6                                             
MEMID7                  20020104                               
MEMID9                  20040501                               
MEMID9                  20040501                               
MEMID3                  20020501                               
MEMID2                  20060102                               
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(40,07,CH,EQ,C'WELCOME'),   
                            PUSH=(301:ID=8)),                 
      IFTHEN=(WHEN=INIT,OVERLAY=(309:25,8)),                   
      IFTHEN=(WHEN=((40,07,CH,EQ,C'WELCOME'),OR,               
                    (35,06,CH,EQ,C'REPORT'),OR,               
                    (01,50,CH,EQ,C'-'),OR,                     
                    (01,08,CH,EQ,C'MEMBERID'),OR,             
                    (01,05,CH,EQ,C' ')),OVERLAY=(309:8C'0'))   
   SORT FIELDS=(301,8,ZD,A,309,8,ZD,A),EQUALS                 
   OUTFIL BUILD=(1,300)                                       
//*                                                           

OUTPUT
Code:
HEADER COND1                           WELCOME                 
HEADER COND2                      REPORT                       
--------------------------------------------------HEADER COND3
MEMBERID HEADER COND4                                         
--------------------------------------------------HEADER COND5
     HEADER COND6                                             
MEMID4                  20020101                               
MEMID4                  20020101                               
MEMID1                  20020102                               
MEMID2                  20020501                               
MEMID3                  20020501                               
HEADER COND1                           WELCOME                 
HEADER COND2                      REPORT                       
--------------------------------------------------HEADER COND3
MEMBERID HEADER COND4                                         
--------------------------------------------------HEADER COND5
     HEADER COND6                                             
MEMID7                  20020104                               
MEMID3                  20020501                               
MEMID9                  20040501                               
MEMID9                  20040501                               
MEMID2                  20060102                               

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 8:32 pm
Reply with quote

sqlcode,

I've been trying to make this easy to do :-)

Why don't you like "identify the data lines/leave everything else alone"? Positions, content, artistic style of everything except the data lines becomes irrelevant. Copy 'em out. Sort 'em. Stick 'em back where a data-line was originally.

I've even been thinking I could code it, using enrico's duplicate-matching code.

Don't worry, only thinking.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jun 15, 2011 8:50 pm
Reply with quote

Bill Woodger,
The logic here in the code I gave, identifies HEADER records and populate sort key values in such a way so that HEADER records are kept together and at the top for every group starting with given HEADER conditions.

Sure, we may approach "identify the data lines/leave everything else alone", but unless, I am missing some of OP's remarks here, I don't see a way to identify "detail" records.

One way to achieve the same would be to use below conditions,which checks for "NUM"erics on 25th position,but I am not sure if that will suffice OP's requirement. This would fail if one of the header conditions has numbers at 25th position.
Code:
//SYSIN    DD *                                             
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(40,07,CH,EQ,C'WELCOME'),
                            PUSH=(301:ID=8)),               
         IFTHEN=(WHEN=INIT,OVERLAY=(309:25,8)),             
         IFTHEN=(WHEN=(25,8,FS,NE,NUM),OVERLAY=(309:8C'0'))
   SORT FIELDS=(301,8,ZD,A,309,8,ZD,A),EQUALS               
   OUTFIL BUILD=(1,300)                                     
//*                                                         

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 15, 2011 8:59 pm
Reply with quote

sqlcode, you are right. Didn't get an answer to "reliably identify" and still no actual example of the data.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Jun 15, 2011 9:10 pm
Reply with quote

I think the issue may have been resolved earlier if there had been sample output to go with the sample input - then we could have seen if data lines changed pages or not - there could be a lot of language problem here.

One of the replies from OP suggests that the data lines should be extracted, sorted and headers re-inserted every 80 lines (page of A4?) except the every 80 lines was line 80, 180 etc (but that could have been a typo and should have been 80, 160,240 etc.)
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jun 16, 2011 5:44 pm
Reply with quote

seahawk789, anything for sqlcode1 on this one, before you move on to the next?
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
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
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top