Search

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

Wednesday, October 14, 2015

KSDS VSAM file creation in read-only mode


KSDS VSAM file can be made read only By using INHIBIT along with ALTER command

Example:

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
ALTER -
READ1.KSDS.DATA -
INHIBIT
ALTER -
READ1.KSDS.INDEX -
INHIBIT
/*
//

Notice that the ALTER command is used with DATA and INDEX and not with the cluster.

List possible compiler diagnostic messages



Use of Compiler diagnostic messages


A complete listing of compiler diagnostic messages can be generated with their explanations, by compiling a program with the program-id of ERRMSG specified in the PROGRAM-ID paragraph.

Example:

IDENTIFICATION DIVISION
PROGRAM-ID.ERRMSG.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
STOP RUN.