Sort a FB file with two sort conditions.



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Sort a FB file with two sort conditions.

Postby Surabhi » Thu May 18, 2017 12:07 pm

Hello,

I have a FB input file as mentioned below :-

Type         Code
10000      12345
11000      12345
30000      12345
20000      12345
11000      45624
25000      45624
34000      33669
30000      33669
 

I have a requirement, if first 5 bytes (1,5) of Type is 30000, then for the corresponding code all types should be written to the output file.

Output file:-
Type         Code
10000      12345
11000      12345
30000      12345
20000      12345
34000      33669
30000      33669
 

Could anyone help me with this.

Thank you.

code' d
Surabhi
 
Posts: 47
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Sort a FB file with two sort conditions.

 

Re: Sort a FB file with two sort conditions.

Postby NicC » Thu May 18, 2017 3:48 pm

I do not see any sort conditions here but one selection condition. And no code tags used - why?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2675
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 102 times

Re: Sort a FB file with two sort conditions.

Postby Aki88 » Wed May 31, 2017 10:43 pm

Hello,

Here is a solution; it has been copied from another forum - and the source is as authentic as it can get at least in DFSORT world :D

I'd been trying to work a solution for this for a while with various IFTHEN methods trying to emulate a COBOL working storage variable to hold the values in question but missed the basic idea that JOINKEYS gives me that function as a default; sometimes, we as programmers tend to overthink a problem which is very-very harmful 'cause we overlook the simple things:



//STEP0100 EXEC PGM=SORT              
//SYSOUT   DD SYSOUT=*                
//INA      DD *                        
10000      12345                      
11000      12345                      
30000      12345                      
20000      12345                      
11000      45624                      
25000      45624                      
34000      33669                      
30000      33669                      
//INB      DD *                        
10000      12345                      
11000      12345                      
30000      12345                      
20000      12345                      
11000      45624                      
25000      45624                      
34000      33669                      
30000      33669                      
//SORTOUT  DD SYSOUT=*                
//SYSIN    DD *                        
  OPTION COPY                          
  JOINKEYS F1=INA,FIELDS=(12,5,A)      
  JOINKEYS F2=INB,FIELDS=(01,5,A)      
  REFORMAT FIELDS=(F1:1,80)            
//*                                    
//JNF2CNTL DD *                        
  INCLUDE COND=(1,5,CH,EQ,C'30000')    
  INREC BUILD=(12,5)                  
//*
 
Aki88
 
Posts: 369
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 35 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post