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
 

 

A Specific and tricky sort query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 73
Location: Boston

PostPosted: Mon Dec 27, 2010 11:53 am    Post subject: A Specific and tricky sort query
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Dec 27, 2010 9:43 pm    Post subject:
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: 73
Location: Boston

PostPosted: Tue Dec 28, 2010 11:27 am    Post subject:
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

Site Director


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

PostPosted: Tue Dec 28, 2010 8:27 pm    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Dec 28, 2010 11:15 pm    Post subject:
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: 73
Location: Boston

PostPosted: Wed Dec 29, 2010 8:15 am    Post subject:
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

Site Director


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

PostPosted: Wed Dec 29, 2010 8:40 am    Post subject:
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: 73
Location: Boston

PostPosted: Wed Dec 29, 2010 10:06 am    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Dec 29, 2010 10:40 pm    Post subject:
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: 73
Location: Boston

PostPosted: Thu Dec 30, 2010 3:18 pm    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Dec 31, 2010 12:26 am    Post subject:
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:

http://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: 73
Location: Boston

PostPosted: Fri Dec 31, 2010 10:54 am    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sun Jan 02, 2011 12:42 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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