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 

Sort - Excluding groups based on condition

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


Joined: 29 Jun 2017
Posts: 6
Topics: 6

PostPosted: Fri Oct 06, 2017 8:49 am    Post subject: Sort - Excluding groups based on condition Reply with quote

Input file:
Code:

1ABC-001
   ABC TOTAL 1
0  12,300
   ABC TOTAL 2
0  13,345
1ABC-002                         
   ABC TOTAL 1
0  16,300
   ABC TOTAL 2
0  17,345
   ABC TOTAL 3
0  14,395

Output file :
Code:

12,300
13,345
14,395

Description :
Input is report file containing 133 length and output is flat file containing 133 length.
Scenario :
1) If 'ABC TOTAL 1' found in report 'ABC-001',then amount should be populated in output file.
The 'ABC TOTAL 1' in report 'ABC-002' should be skipped/excluded.
2) If 'ABC TOTAL 2' found in report 'ABC-001',then amount should be populated in output file.
The 'ABC TOTAL 2' in report 'ABC-002' should be skipped/excluded.
3) If 'ABC TOTAL 3' found in report 'ABC-001',then amount should be populated in output file.
The 'ABC TOTAL 3' in report 'ABC-002' should be skipped/excluded.
4) If 'ABC TOTAL 1' is not found in report 'ABC-001',then amount has to be picked from 'ABC TOTAL 1' in report 'ABC-002'.
5) If 'ABC TOTAL 2' is not found in report 'ABC-001',then amount has to be picked from 'ABC TOTAL 2' in report 'ABC-002'.
6) If 'ABC TOTAL 3' is not found in report 'ABC-001',then amount has to be picked from 'ABC TOTAL 3' in report 'ABC-002'.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Oct 08, 2017 5:00 am    Post subject: Reply with quote

sublak123,

Try these untested DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DISP=SHR,DSN=your input FBA  LRECL 133 file
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'1ABC'),       
          PUSH=(134:1,8)),                                 
        IFTHEN=(WHEN=GROUP,BEGIN=(4,9,CH,EQ,C'ABC TOTAL'), 
          PUSH=(142:4,11),RECORDS=2)                   
   
  SORT FIELDS=(142,11,CH,A,                                 
               134,08,CH,A),EQUALS                         

  OUTFIL INCLUDE=(1,1,CH,EQ,C'0'),NODETAIL,BUILD=(133X),   
  REMOVECC,SECTIONS=(142,11,HEADER3=(1,133))               
//*                                                         

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

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


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Sun Oct 08, 2017 9:47 pm    Post subject: Reply with quote

kolusu wrote:
sublak123,

Try these untested DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DISP=SHR,DSN=your input FBA  LRECL 133 file
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'1ABC'),       
          PUSH=(134:1,8)),                                 
        IFTHEN=(WHEN=GROUP,BEGIN=(4,9,CH,EQ,C'ABC TOTAL'), 
          PUSH=(142:4,11),RECORDS=2)                   
   
  SORT FIELDS=(142,11,CH,A,                                 
               134,08,CH,A),EQUALS                         

  OUTFIL INCLUDE=(1,1,CH,EQ,C'0'),NODETAIL,BUILD=(133X),   
  REMOVECC,SECTIONS=(142,11,HEADER3=(1,133))               
//*                                                         


Hi Kolusu,

I think it should be 4,130?
Code:

REMOVECC,SECTIONS=(142,11,HEADER3=(4,130))   


Thanks
Magesh
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Oct 09, 2017 8:50 am    Post subject: Reply with quote

Magesh_J wrote:


Hi Kolusu,

I think it should be 4,130?
Code:

REMOVECC,SECTIONS=(142,11,HEADER3=(4,130))   


Thanks
Magesh


Op wanted the output to be 133 bytes. So i just wrote out the entire record. He can change accordingly.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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