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

A Specific and tricky sort query


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

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Mon Dec 27, 2010 11:53 am
Reply with quote

Hi,

I have a very specific condition here.
My data has a 9 byte field followed by four 1 byte fields as 9+1+1+1+1 Bytes. The 9 byte field can have repetitions and the four 1 byte field are (Y/N) indicator values. Now as per my requirement, I would like to consolidate all the 9 byte column(to avoid repetitions) and if there is atleast one 'Y' in my 1 byte column my final report should have 'Y', else it will carry a 'N' (for that particular 1 byte field only) . This is applicable for all the four 1 byte columns. Please have a look at the example below.


Example:

Input File:

AAAAAAAAANNNN
BBBBBBBBBNNNN
BBBBBBBBBNNNN
BBBBBBBBBYNNN
BBBBBBBBBNNNN
BBBBBBBBBNNNN
BBBBBBBBBNNYN
CCCCCCCCCNYNN
CCCCCCCCCNYYN

Final Report:

AAAAAAAAANNNN
BBBBBBBBBYNYN
CCCCCCCCCNYYN

Would it be possible to achieve this in a single sort step? May sound over ambitious...but please advice.. icon_cry.gif
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: Mon Dec 27, 2010 9:43 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for in one step/pass:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=...  output file
//TOOLIN   DD   *
SPLICE FROM(IN) TO(OUT) ON(1,9,CH) KEEPNODUPS WITHANY -
  WITH(10,1) WITH(11,1) WITH(12,1) WITH(13,1) USING(CTL1)
/*
//CTL1CNTL DD   *
  OPTION COPY
  INREC FINDREP=(STARTPOS=10,ENDPOS=13,INOUT=(C'N',C' '))
  OUTFIL FNAMES=OUT,
    FINDREP=(STARTPOS=10,ENDPOS=13,INOUT=(C' ',C'N'))
/*
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Tue Dec 28, 2010 11:27 am
Reply with quote

Frank,

Thank you very much for the timely help 36_8_11.gif

But there are two conditions that I thought I can handle once this is ready but for the moment not able to add to the sort step you gave me.

My conditions are
1. I have a header on the file and would like to stay as the first record and free from manipulation
2. There are delimiters between each of the 5 fields(9+1+1+1+1 fields) that I had mentioned earlier that I would like to carry over to my report without any change.

Please advice how I would have to go about handling it.

Thanks,
Ashwin.
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: Tue Dec 28, 2010 8:27 pm
Reply with quote

Hello,

Rather than posting additions to the requirement as solutions are provided, suggest you show a complete example of your input and the actual output you want when your proces is run. . .

Why should people work on multiple solutions when one would be sufficient if all of the requirement was posted initially. . . icon_neutral.gif
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: Tue Dec 28, 2010 11:15 pm
Reply with quote

Ashwin,

Please provide a better example of input and output as Dick suggests.

Also, what is the RECFM and LRECL of the input file?

Can the header be identified in some way (e.g. H in position 1) aside from being the first record?
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Wed Dec 29, 2010 8:15 am
Reply with quote

Frank/Dick,

My Apologies. I thought I can build it further from the solution provided, but wasnt able to.. icon_sad.gif

The LRECL=98 bytes ( This is to accomodate the header though my data is only 18 bytes long), RECFM=FB.

Yes, the header is static and can be identified with 'XXXX' in position 1 to 4.

Example:
Sample Input:

Code:
XXXXMYHEADER INFORMATIONXXX
AAAAAAAAA!N!N!N!N!
BBBBBBBBB!N!N!N!N!
BBBBBBBBB!N!N!N!N!
BBBBBBBBB!Y!N!N!N!
BBBBBBBBB!N!N!N!N!
BBBBBBBBB!N!N!N!N!
BBBBBBBBB!N!N!Y!N!
CCCCCCCCC!N!Y!N!N!
CCCCCCCCC!N!Y!Y!N!


Final Report:

Code:
XXXXMYHEADER INFORMATIONXXX
AAAAAAAAA!N!N!N!N!
BBBBBBBBB!Y!N!Y!N!
CCCCCCCCC!N!Y!Y!N!
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: Wed Dec 29, 2010 8:40 am
Reply with quote

Hello,

Suggest you become familiar/comfortable with the "Code" Tag. Your last post has been "Code"d.

What happens if later in the data is a record like:
Code:
XXXXXXXXX!N!Y!N!N!
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Wed Dec 29, 2010 10:06 am
Reply with quote

Thanks for the suggestion Dick. ll Follow from here on..

I can assure you that the file wouldn't have 'XXXX' in position 1 to 4 except on the header record.
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: Wed Dec 29, 2010 10:40 pm
Reply with quote

Here's a DFSORT job for your revised requirements:

Code:

//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=...  output file
//TOOLIN   DD   *
SPLICE FROM(IN) TO(OUT) ON(1,9,CH) KEEPNODUPS WITHANY -
  WITH(11,1) WITH(13,1) WITH(15,1) WITH(17,1) USING(CTL1)
/*
//CTL1CNTL DD   *
  OPTION COPY
  INREC FINDREP=(STARTPOS=10,ENDPOS=17,INOUT=(C'!N',C'! '))
  OUTFIL FNAMES=OUT,
    FINDREP=(STARTPOS=10,ENDPOS=17,INOUT=(C'! ',C'!N'))
/*
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Thu Dec 30, 2010 3:18 pm
Reply with quote

Thank you very much Frank. It worked! icon_biggrin.gif

I would really appreciate if you could guide me in getting a few materials from where I can start learning a few things on ICETOOL.

Thanks,
Ashwin.
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: Fri Dec 31, 2010 12:26 am
Reply with quote

Ashwin,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Fri Dec 31, 2010 10:54 am
Reply with quote

Thanks Frank.
I really appreciate the great work you guys are putting with DFSORT...it really has brought down the time spent on developing and testing a cobol program. I think many who have worked on both would agree with me.
Great going... icon_wink.gif

Thanks again for all the help.
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: Sun Jan 02, 2011 12:42 am
Reply with quote

Thanks for the kind words.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts RC query -Time column CA Products 3
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top