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

Multiple sort fields within multiple reports within a file


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

New User


Joined: 05 Jul 2013
Posts: 34
Location: India

PostPosted: Mon Jul 08, 2013 12:21 pm
Reply with quote

Hi all,

Thanks for providing support for all MF Queries.Now i would like to know about sort using ICETOOL.

I have a PS file RECFM=FB,LRECL=172. file has many company reports within itself.
Each company report has 3 header and no trailer.

In the first company report, in the first header, we have first sort field 'company id' (numeric field) and in the same row we have the second sort field 'date'. In second and third header no sort fields. after third header, records for the first company starts with first field is numeric field. after all records for the first company, then first header for the second company starts. and so on.
this is how reports for all company is written in that file.


Here i have a doubt in ICETOOL, can i sort the file within each company in the below order ?
1. company id
2. date
3. records of that company

i.e.,each company will be first sorted on company id and then date and then records for that company in ascending.

i know i can sort it in COBOL using SORT keyword.

i am little confused on sort using icetool. Can we sort it for the above criteria using DATASORT . If so please let me know

please findd the attachment.

Regards,
BV
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Jul 08, 2013 1:37 pm
Reply with quote

What is the release level of sort that you are using, please run the JCL provided below and post the sresults including the message codes.

RECFM is
LRECL is
Key fields are where, howlong, which format

Code:

//SORT01   EXEC PGM=SORT
//SYSOUT   DD SYSOUT=* 
//SORTOUT  DD SYSOUT=* 
//SORTIN   DD *         
RECORD                 
/*                     
//SYSIN    DD *         
  SORT     FIELDS=COPY 
Back to top
View user's profile Send private message
bvarun.

New User


Joined: 05 Jul 2013
Posts: 34
Location: India

PostPosted: Mon Jul 08, 2013 1:50 pm
Reply with quote

expat,

we use DFSORT V1R12

RECFM=FB,
LRECL=172.

Order of key fields on which file has to be sorted
1. company id - 7,7,ZD
2. date - 72,8,ZD
3. records of that company - 1,2,ZD

i have attached file layout for your reference within this post.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Jul 08, 2013 2:43 pm
Reply with quote

Assuming that the posted screenshot is accurate you can use INREC IFTHEN

UNTESTED CODE - just a suggestion
Code:

 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'COMP'),
       PUSH=(173:7,7,180:72,8))

 SORT FIELDS=(173,15,CH,A,1,2,CH,A)


You will have to search the forum / manuals on how to chop the addition fields off as I am a bit busy at the moment to go looking, probably OUTFIL OUTREC=
Back to top
View user's profile Send private message
bvarun.

New User


Joined: 05 Jul 2013
Posts: 34
Location: India

PostPosted: Mon Jul 08, 2013 2:49 pm
Reply with quote

expat,

Thank you very much for your prompt response..

i will let you know on the updates
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Jul 08, 2013 3:05 pm
Reply with quote

bvarun

Please learn to use the code tags rather than using attachments, as
a) Not evryone will be able to open some attachments
b) Not everybody will want to open some attachments

Using attachments just cuts down on the numbers of those able or willing to help.
Back to top
View user's profile Send private message
bvarun.

New User


Joined: 05 Jul 2013
Posts: 34
Location: India

PostPosted: Mon Jul 08, 2013 3:16 pm
Reply with quote

I tried ... clicking Img button and url of the screenshot and again img button

but in vain..
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon Jul 08, 2013 3:35 pm
Reply with quote

bvarun. wrote:
I tried ... clicking Img button and url of the screenshot and again img button

but in vain..

Do not use the "Img" button, but the "Code" button.
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: Mon Jul 08, 2013 4:49 pm
Reply with quote

Why do you think you need to use ICETOOL?

DATASORT works where there is a file-header or file-trailer (or both) on a file. I think you have a different situation.

If you know how to get your answer using the COBOL SORT verb, then you can do the same thing with DFSORT.

expat has given you a good start. The format of your date is not "natural" for sorting, and lines two and three of each group will confuse things as they have different data than the numerics you want to sort on for the detail lines.

If you are still stuck, show us how you'd do it in COBOL and we can assist in applying that with SORT Control Cards.
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: Mon Jul 08, 2013 5:57 pm
Reply with quote

expat, you were too harsh on yourself. If it had been in the Code tags, we could at least have seen it easily... I've deepsixed it :-)
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 08, 2013 9:48 pm
Reply with quote

expat wrote:
Assuming that the posted screenshot is accurate you can use INREC IFTHEN

UNTESTED CODE - just a suggestion
Code:

 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'COMP'),
       PUSH=(173:7,7,180:72,8))

 SORT FIELDS=(173,15,CH,A,1,2,CH,A)


You will have to search the forum / manuals on how to chop the addition fields off as I am a bit busy at the moment to go looking, probably OUTFIL OUTREC=



Expat you got it almost right. OP's header records had(CO,FI and PR) in postions 1 and 2 and your detail records have numeric data. So you should be ok as characters get sorted first and then numeric data. But if they have different values then you may need to sequence the group records and preserve the first 3 as is.

btw this is similar to the smart DFSORT trick "Sort detail records between headers and trailers" which can be found here

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094
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: Tue Jul 09, 2013 12:29 am
Reply with quote

Is sorting the data going in to the report possible?

If not, use expat's suggestion, swapping the date into "sort" order (76,4,74,2,72,2).

Take note of what Kolusu said. If your first three lines are always like that, then there will be no harm in sorting on 1,2, as the letters will always come before numbers, and the letters are in order. If you can have different text per heading in those first three lines, then there is a little more to do.

To "cut the record down" again, after the SORT

Code:
  OUTREC BUILD=(1,172)
Back to top
View user's profile Send private message
bvarun.

New User


Joined: 05 Jul 2013
Posts: 34
Location: India

PostPosted: Tue Jul 09, 2013 8:56 am
Reply with quote

Thanks for patronage.

However today morning i was so irritated icon_evil.gif that client requested for the layout change.

But im going to try myself icon_rolleyes.gif on this format to get it sorted.
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 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
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top