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
 

 

Sort a file excluding page headers ?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 47
Location: Cochin

PostPosted: Wed Jun 15, 2011 1:01 pm    Post subject: Sort a file excluding page headers ?
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 1:05 pm    Post subject: Reply to: Sort a file excluding page headers ?
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: 47
Location: Cochin

PostPosted: Wed Jun 15, 2011 1:58 pm    Post subject:
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    Post subject:
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: 47
Location: Cochin

PostPosted: Wed Jun 15, 2011 2:37 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 2:46 pm    Post subject:
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: 47
Location: Cochin

PostPosted: Wed Jun 15, 2011 3:03 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 3:18 pm    Post subject:
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: 47
Location: Cochin

PostPosted: Wed Jun 15, 2011 4:09 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 4:17 pm    Post subject: Reply to: Sort a file excluding page headers ?
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jun 15, 2011 4:24 pm    Post subject: Reply to: Sort a file excluding page headers ?
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 4:34 pm    Post subject: Reply to: Sort a file excluding page headers ?
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jun 15, 2011 4:42 pm    Post subject: Reply to: Sort a file excluding page headers ?
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 5:09 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Jun 15, 2011 5:19 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 5:29 pm    Post subject: Reply to: Sort a file excluding page headers ?
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: 47
Location: Cochin

PostPosted: Wed Jun 15, 2011 5:55 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jun 15, 2011 6:29 pm    Post subject:
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: 578
Location: USA

PostPosted: Wed Jun 15, 2011 7:43 pm    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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