Search

Showing posts with label DFSORT. Show all posts
Showing posts with label DFSORT. Show all posts

Tuesday, October 20, 2015

DFSORT - To search for the string from the file when position is not known

Search for a string when its position not known in the file records          

To Search for a particular string within a file when the exact position of that string within a record is not known and to write that record in the Output file, the following SORT card can be used.

//SYSIN    DD  *                                   
        SORT FIELDS=COPY                           
        INCLUDE COND=(1,80,SS,EQ,C'PQ2222222222')  
/*                                                 

Here,
 SS        -   Sub string,
 1         -   Starting position of the range
 80       -   Width of the search range
 EQ      -   Comparison operators

Note:
  1. Only EQ & NE can be used for comparison.
  2. We can even use OMIT COND instead of INCLUDE

Consider input files:

ABC.SORTIN
PQ000003 1000001 PQ2222222222 123                  
PQ000002 1000002 EF1111111111                   
PQ000004 1000002 AB3333333333 530 PQ2222222222    
PQ000003 1000001 CD5555555555 005                  
PQ000001 1000004 RQ1111111111         

PQR.SORTOUT
PQ000003 1000001 PQ2222222222 123              
PQ000004 1000002 AB3333333333 530 PQ2222222222        

We can also use AND/OR to combine conditions

//SYSIN    DD  *                                      
        SORT FIELDS=COPY                              
        INCLUDE COND=(1,80,SS,EQ,C'PQ2222222222',AND, 
                      1,80,SS,EQ,C'AB3333333333')     
/*                    
                               
XYZ.SORTOUT
PQ000004 1000002 AB3333333333 530 PQ2222222222

Sunday, October 28, 2012

ICETOOL Example - Matching and non matching records

Create files with matching and non-matching records

There are two input files containing lists of records, as follows:

Input File1

V
F
C
H
D

Input File2

K
H
C
V
M

How can we create output files for the following?

  • The records that appear in both File1 and File2
  • The records that appear only in File1
  • The records that appear only in File2

Below is an ICETOOL job that can do this match by using the SPLICE operator. SPLICE operator in ICETOOL helps to perform various file join and match operations.