MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Filter Logic on Sort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Thu Feb 17, 2011 4:14 am    Post subject: Filter Logic on Sort Reply with quote

Hi,

There was an urgent requirement for filtering records. I have proceeded to code a new Program for this but clients are requesting us to go with Sort

Account Number : Pos 3 - 8
Lot : Pos 9 - 13

Code:

02ACCT01LOT01DEL 
02ACCT01LOT01ADJ
02ACCT01LOT01NEW
02ACCT01LOT02NEW
02ACCT01LOT02NEW
02ACCT02LOT03NEW
02ACCT02LOT04NEW
02ACCT02LOT05NEW
02ACCT03LOT06NEW
02ACCT01LOT01DEL



Requirement :

For a same Account, Lot
If (NEW and DEL) or (NEW, ADJ, DEL) comes we need to filter that.

Can this be done?
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Feb 17, 2011 8:10 am    Post subject: Reply with quote

Arvind,

there is an amazing amount of 'filtering' (INCLUDEing and EXCLUDEing) that can be accomplished by DFSORT.

BUT, my friend, I am lost after reading your description.

provide some input (which would contain alls possible situations)
and provide your expected output.

attempt a better explaination, (short of that, and explanation of the different fields in your record).
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Thu Feb 17, 2011 8:24 am    Post subject: Reply with quote

Im sorry.

Hope this is better

Fields

Rec Id : 1 - 2
Account Number : Pos 3 - 8
Lot : Pos 9 - 13
Lot Type : Pos 14 - 16

Code:

----+----1----+----2----+----3----+----4
02ACCT01LOT01DEL                        1
02ACCT01LOT01ADJ                        2
02ACCT01LOT01NEW                        3
02ACCT01LOT02NEW                        4
02ACCT01LOT13NEW                        5
02ACCT02LOT03ADJ                        6
02ACCT02LOT04NEW                        7
02ACCT02LOT03DEL                        8
02ACCT03LOT06ADJ                        9
02ACCT01LOT02DEL                        10


Filter Req

For an Account number and a particular Lot
a. If there is a NEW, ADJ, DEL ( based on Lot Type ) we need to filter that. In this example First 3 should be filtered.
b. If there is a New, DEL - filter ( Records 4 and 10 )
c. If there is a Adj and DEL - filter ( Records 6 and 8 )

Final output for the above

Code:

----+----1----+----2----+----3----+----4
02ACCT01LOT13NEW                        5
02ACCT02LOT04NEW                        7
02ACCT03LOT06ADJ                        9


Thanks
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Feb 17, 2011 11:42 am    Post subject: Reply with quote

arvibala,

Unless I am mistaken isn't it a simple case of removing duplicate records?

Assuming you don't have more than 1 row of same lot-type , the following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                           
//TOOLMSG  DD SYSOUT=*                                 
//DFSMSG   DD SYSOUT=*                                 
//IN       DD *                                       
----+----1----+----2----+----3----+----4----+----5----+
02ACCT01LOT01DEL                        1             
02ACCT01LOT01ADJ                        2             
02ACCT01LOT01NEW                        3             
02ACCT01LOT02NEW                        4             
02ACCT01LOT13NEW                        5             
02ACCT02LOT03ADJ                        6             
02ACCT02LOT04NEW                        7             
02ACCT02LOT03DEL                        8             
02ACCT03LOT06ADJ                        9             
02ACCT01LOT02DEL                        10             
//OUT      DD SYSOUT=*                                 
//TOOLIN   DD *                                       
  SELECT FROM(IN) TO(OUT) ON(1,13,CH) NODUPS           
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Fri Feb 18, 2011 12:45 am    Post subject: Reply with quote

Thanks Kolusu.

But I am sorry for not giving correct requirements.

If there are a NEW and ADJ ( No DEL ), it should not filter.

One more req came today is If there are only NEW and ADJ for a particular Acct and lot, the NEW record shud have 30 at position 25 and ADJ record shud have 40 at position 25. ( is this too much for a utility )


Thanks
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Fri Feb 18, 2011 11:35 am    Post subject: Reply with quote

arvibala,

*Sigh* I feel like a dentist trying to pull teeth. How hard is it provide all the details? You have been on this board for 3 years and by now you should be able to explain your requirements clearly. We canNOT read your mind or your data. Please provide detailed/complete information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.

You changed the requirement and you did not even provide a sample output.

What is the LRECL and RECFM of the file?
What happens if you have a records with just NEW and DEL ? Do you need to keep it or delete it ? If you need to keep it , what other values need to populated?
Cover all the possible scenarios and last minute requirement changes and explain them so that we can provide an optimal solution.

Quote:
( is this too much for a utility )


DFSORT has now become *almost* equivalent to a programming language instead just being an utility , so it can do a lot more than you think.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Fri Feb 18, 2011 1:00 pm    Post subject: Reply with quote

Kolusu,

I just added the requirements and the original requirements remains same. I am consolidating my requirements and tried to put here as best as i can.

Fields

Rec Id : 1 - 2
Account Number : Pos 3 - 8
Lot : Pos 9 - 13
Lot Type : Pos 14 - 16

Inout
Code:

----+----1----+----2----+----3----+----4
02ACCT01LOT01DEL                        1
02ACCT01LOT01ADJ                        2
02ACCT01LOT01NEW                        3
02ACCT01LOT02NEW                        4
02ACCT01LOT13NEW                        5
02ACCT02LOT03ADJ                        6
02ACCT02LOT04NEW                        7
02ACCT02LOT04ADJ                        8
02ACCT02LOT03DEL                        9
02ACCT03LOT06ADJ                        10
02ACCT01LOT02DEL                        11


Output
Code:

----+----1----+----2----+----3----+----4
02ACCT01LOT13NEW                        5
02ACCT02LOT04NEW        30              7
02ACCT02LOT04ADJ        40              8
02ACCT03LOT06ADJ                        10


Filter Req

For an Account number and a particular Lot
a. If there is a NEW, ADJ, DEL ( based on Lot Type ) we need to filter that. In this example First 3 should be filtered.
b. If there is a New, DEL - filter ( Records 4 and 10 )
c. If there is a Adj and DEL - filter ( Records 6 and 8 )


If there are matchin NEW and ADJ ( No DEL ), it should not filter, The NEW record shud have 30 at position 25 and ADJ record shud have 40 at position 25.
unmatched NEW, ADJ and DEL records should be retained.


LRECL = 850, RECFM=FB
Only for NEW and DEL we need to populate values at position 25. Others just retails the original record values.

Thanks
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Fri Feb 18, 2011 1:01 pm    Post subject: Reply with quote

Pls note Values at position 41 is just to denote the record numbers .... they are not part of data
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Fri Feb 18, 2011 7:07 pm    Post subject: Reply with quote

arvibala,

Use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//INA      DD DSN=Your input file FB 850 lrecl,DISP=SHR
//INB      DD DSN=Same input file FB 850 lrecl,DISP=SHR
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  JOINKEYS F1=INA,FIELDS=(3,11,A)                               
  JOINKEYS F2=INB,FIELDS=(1,11,A)                               
  JOIN UNPAIRED                                                 
  REFORMAT FIELDS=(F1:1,850,?,F2:15,3)   
                       
  OUTFIL IFOUTLEN=850,                                           
  INCLUDE=(851,4,SS,EQ,C'B001,B010,B100,B110'),                 
  IFTHEN=(WHEN=(851,4,CH,EQ,C'B110',AND,14,3,CH,EQ,C'NEW'),     
  OVERLAY=(25:C'30')),                                           
  IFTHEN=(WHEN=(851,4,CH,EQ,C'B110',AND,14,3,CH,EQ,C'ADJ'),     
  OVERLAY=(25:C'40'))                                           
//*                                       
//JNF2CNTL DD *                                                 
  INREC IFTHEN=(WHEN=INIT,BUILD=(3,14,3C'0')),                   
  IFTHEN=(WHEN=(12,3,CH,EQ,C'NEW'),OVERLAY=(15:C'1')),           
  IFTHEN=(WHEN=(12,3,CH,EQ,C'ADJ'),OVERLAY=(16:C'1')),           
  IFTHEN=(WHEN=(12,3,CH,EQ,C'DEL'),OVERLAY=(17:C'1'))           
  SUM FIELDS=(15,1,16,1,17,1),FORMAT=ZD                         
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Tue Feb 22, 2011 2:00 am    Post subject: Reply with quote

Thank you
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group