Tuesday, 12 February 2013

JCL to Run simple cobol program - 

//YSWATEST JOB (GENERAL),'RUN JCL',CLASS=A,                 
//         MSGCLASS=Q,                                      
//         NOTIFY=&SYSUID,                                  
//         TIME=(2)                                         
//*                                                         
//  JCLLIB ORDER=YSWA.DEV.JCLLIB                            
//*                                                         
//STEP2    EXEC IGYWCLG,MEM=TCOB1                           
//COBOL.SYSIN DD DSN=YSWA.DEV.TEST.SOURCE(&MEM),            
//             DISP=SHR                                     
//LKED.SYSLMOD DD DSN=YSWA.DEV.COB.LOADLIB(&MEM),           
//             DISP=SHR                                     
//*                                                         
Job to take unload of table - 

//YSWATEST JOB (GENERAL),'DB2 UNLOAD',                      
//         CLASS=A,                                         
//         MSGCLASS=Q,                                      
//         NOTIFY=&SYSUID,                                  
//         MSGLEVEL=(1,1),                                  
//         TIME=(0,1),                                      
//         PRTY=8                                           
//*                                                         
//STEP1    EXEC  PGM=IKJEFT01                               
//SYSTSPRT DD    SYSOUT=*                                   
//SYSPRINT DD    SYSOUT=*                                   
//SYSOUT    DD    SYSOUT=*                                   
//SYSIN      DD    *                                          
    SELECT *                                                
     FROM EMP_TABLE                                         
     WHERE EMP_NAME  = 'SANDIP'                                 
    WITH UR;                                                
//*                                                         
//SYSTSIN  DD    *                                          
   DSN SYSTEM(DBG2)                                         
   RUN PROGRAM(DSNTIAUL) PLAN(DSNTIAUL) PARMS('SQL')        
//*  DATA FILE                                              
//SYSREC00 DD    DSN=YSWA.DEV.DATA1X,                       
//             DISP=(NEW,CATLG,DELETE),                     
//             UNIT=SYSDA,SPACE=(CYL,(1,1))                 
//*  CTRL FILE                                              
//SYSPUNCH DD    DSN=YSWA.DEV.CTRL1X,                       
//             DISP=(NEW,CATLG,DELETE),                     
//             UNIT=SYSDA,SPACE=(CYL,(1,1))                 
//*                                                         

Monday, 11 February 2013

CICS Commands to add program in PCT, PPT, RCT, FCT


Define entry in PPT for program TSTPRG grp TSTGRP


CEDA DEF PROG(TSTPRG) GROUP(TSTGRP)

CEDA INSTALL PROG(TSTPRG) GROUP(TSTGRP)




Define entry in PCT for program TSTPRG grp TSTGRP and transaction TRN1

CEDA DEF TRANS(TRN1) PROG(TSTPRG) GROUP(TSTGRP)  

CEDA INSTALL TRANS(TRN1) PROG(TSTPRG) GROUP(TSTGRP)



Command to reflect new changes made to program.

CEMT SET PROG(TSTPRG) NEWCOPY





Command to add entry of MAPSET in PPT

CEDA DEF MAPSET(TSTMAP) GROUP(TSTGRP)

CEDA INSTALL MAPSET(TSTMAP) GROUP(TSTGRP)

CECI SEND MAP(TSTINFO) MAPSET(TSTMAP) 





Define file name in FCT Filename - TSTFILE DSNAME - NA7384A.CICS.INPUT

CEDA DEF FILE(TSTFILE) GROUP(TSTGRP) DSNAME(NA7384A.CICS.INPUT)




Command to open file 
CEMT SET FILE(TSTFILE) OPEN ENA

ENA - Enabled 


Command to close file 

CEMT SET FILE(TSTFILE) CLOSE DIS

DIS - Disabled




Define CICS-DB2 program 

CEDA DEF DB2ENTRY(TRN1) TRANS(TRN1) PLAN(TSTPLAN) GROUP(TSTGRP)

CEDA INSTALL DB2ENTRY(TRN1) TRANS(TRN1) PLAN(TSTPLAN) GROUP(TSTGRP)



Sunday, 10 February 2013

FIND Command in Dataset


FIND Command :

1) F ALL P'¬'   -- Gives count of non-space characters
2) F ALL P'='   -- find outs any chacter
3) F ALL
P'@'  -- Alphabetic characters
4) F ALL P'-'   -- Non-numeric characters
5) F ALL P'#'   -- Numeric characters

=  any character
.   non-displayable characters
@ alphabetic characters
-  non-numeric characters
# numeric characters
< lower case alphabetics
$  special characters
> upper case alphabetics
¬ non-blank characters

Saturday, 9 February 2013

Easytrieve to copy data from file

Easytrieve to copy data from file :

//STEP020     EXEC  PGM=EZTPA00                         
//EZTVFM    DD    SPACE=(CYL,(3,3)),UNIT=SYSDA        
//SYSPRINT DD    SYSOUT=*                            
//SYSOUT    DD    SYSOUT=*                            
//INFILE       DD    *                                   
21400 SANDIP 55555                                   
//OUTFILE  DD    DSN=NA7384A.TEST.OUT1,DISP=OLD      
//SYSIN    DD    *
                                   
*                                                    
  FILE INFILE                                        
    INREC           01   80  A                       
      EID              01   05  A                       
      ENAME      07   06  A                       
      ESAL          14   05  N                       
*                                                    
  FILE OUTFILE                                       
    OUTREC       01   80  A                       
      EIDO           01   05  A                       
      ENAMEO   07   06  A                       
      ESALO       14   05  N                       
*                                                    
  JOB INPUT NULL                                     
*                                                    
  GET INFILE                                         
*                                                    
    IF EOF INFILE                                    
       DISPLAY ' END HAS REACHED '                   
    STOP                                             
    END-IF                                           
       EIDO           = EID                                
       ENAMEO   = ENAME                              
       ESALO       = ESAL + 3333                       
       PUT OUTFILE                                   

Friday, 8 February 2013

Easytrieve to fetch data from table


Easytrieve to fetch data from table :

/*ROUTE XEQ DB2D                                       
//*                                                    
//STEP010  EXEC  UCC11RMS,TYPRUN='F'                   
//*                                                    
//STEP020  EXEC  PGM=EZTPA00                           
//EZTVFM   DD    SPACE=(CYL,(3,3)),UNIT=SYSDA          
//SYSPRINT DD    SYSOUT=*                              
//SYSOUT   DD    SYSOUT=*                              
//INFILE    
DD                                        
111111111111                                           
222222222222                                           
//OUTFILE  DD    DSN=XX7384A.TEST.OUT1,DISP=OLD        
//SYSIN      DD    *                                     
*                                                      
    PARM SSID(DB2D)    -                               
    SQLSYNTAX(FULL)                                    
*                                                      
  FILE INFILE                                          
     CM-N1    01  12  A                               
*                                                      
  FILE OUTFILE                                         
     CM-N2    01  12  A                               
     R-PRG    14  06  A                               
     S-CD       22  01  A                               
*                                                      
     WS-CM-N    W   12   A                              
     WS-RB-CD  W   06   A                              
     WS-ST-CD  W   01   A                              
*                                                      
   SQL DECLARE CUR1 CURSOR FOR       +                 
       SELECT CM_N,                                +                 
                  PG_CD,                                   +                 
                  ST_CD                                     +                 
       FROM GRABC.XXXYY_ZZ_ABCD     +                 
       WHERE CM_N = : WS-CM-N           +                 
       WITH UR                                         
*                       
   JOB INPUT INFILE                                   
*                                                     
    WS-CM-N  =  CM-N1                               
*                                                     
   SQL OPEN CUR1                                      
*                                                     
   DO UNTIL SQLCODE NE 0                              
     SQL FETCH CUR1           +                           
     INTO : WS-CM-N,          +                        
               : WS-RB-CD,         +                           
               : WS-ST-CD                                  
*                                                     
     IF SQLCODE = 0                                   
         CM-N2  =  WS-CM-N                          
         R-PRG   =  WS-RB-CD                          
         S-CD     =  WS-ST-CD                          
         PUT OUTFILE                                  
     ELSE                                             
        IF SQLCODE = 100                              
          DISPLAY ' ROW NOT FOUND '                   
        ELSE                                          
          DISPLAY ' OTHER ERROR ' SQLCODE             
        END-IF                                        
     END-IF                                           
   END-DO                                             
*                                                     
   SQL CLOSE CUR1                                     
*

Thursday, 7 February 2013

Compare two files using Easytrieve


Compare two files using Easytrieve -

//STEP020    EXEC  PGM=EZTPA00                                     
//EZTVFM    DD    SPACE=(CYL,(3,3)),UNIT=SYSDA                    
//SYSPRINT DD    SYSOUT=*                                        
//SYSOUT    DD    SYSOUT=*                                        
//INFILE1     DD    *
                                               
21400 SANDIP 11111                                               
21500 MANDIP 22222                                               
21600 RANDIP 33333                                               
21700 BALDIP 44444
                                               
//INFILE2   DD    *                                               
21500 PUNE                                                       
21600 MUMBAI                                                     
21800 CHENAI                                                     
21900 HYDERABAD
                                                  
//OUTFILE  DD    DSN=XX7384A.TEST.OUT1,DISP=OLD                  
//SYSIN       DD    *                                               
*                                                                
  FILE INFILE1                                                   
    EID1             01  05  A                                         
    ENAME1     07  06  A                                         
    ESAL1         14  05  N                                         
*                                                                
  FILE INFILE2                                                   
    EID2            01  05  A                                         
    ECITY2       07  10  A                                         
*                                                                
  FILE OUTFILE                                                   
    EIDO           01  05  A                                         
    ENAMEO    07  06  A                                         
    ESALO        15  05  N                                         
    ECITYO       22  10  A                                         
*                                                                
    WS-COUNT   W   04  N                                         
*                                                                
  JOB INPUT (INFILE1 KEY(EID1)    +                              
                        INFILE2 KEY(EID2))   +                              
            NAME PLAMATCH FINISH DISP-RTN                        
  IF MATCHED                                
         EIDO          = EID1                      
         ENAMEO  = ENAME1                    
         ESALO      = ESAL1                     
         ECITYO    = ECITY2                    
         PUT OUTFILE                        
         WS-COUNT = WS-COUNT + 1            
  END-IF                                    
  DISP-RTN. PROC.                           
     DISPLAY ' RECORDS MATCHED ' WS-COUNT   
  END-PROC.
      

Output :
21500 MANDIP  22222  PUNE    
21600 RANDIP  33333  MUMBAI
  

Wednesday, 6 February 2013

Compare two files in cobol


1) Compare two files & write matching records to output file.

Option1: 
This program will degrade the performance but for understanding the logic this option has given. Option2 is efficient. It is explained below option1 program. 

       IDENTIFICATION DIVISION.                                        
       PROGRAM-ID. FILCMPR                                           
       ENVIRONMENT DIVISION.                                          
       CONFIGURATION SECTION                                       
       OBJECT-COMPUTER. IBM-390.                                  
       SOURCE-COMPUTER. IBM-390                                
       INPUT-OUTPUT SECTION.                                           
       FILE-CONTROL                                                  
           SELECT INFILE ASSIGN TO DD1                     
           FILE STATUS IS FS1.                                        
           SELECT OUTFILE ASSIGN TO DD2                
           FILE STATUS IS FS2.                                       
           SELECT MCHFILE ASSIGN TO DD3               
           FILE STATUS IS FS3.                                       
       DATA DIVISION.                                                 
       FILE SECTION.                                                   
       FD INFILE.                                                      
       01 INREC.                                                       
           05 EID1                  PIC X(05).                    
           05 FILLER              PIC X(01).                      
           05 ENAME1          PIC X(06).                       
           05 FILLER              PIC X(01).                      
           05 ESAL1              PIC 9(05).                      
           05 FILLER             PIC X(62).                      
       FD OUTFILE.                                                   
       01 OUTREC.                                                   
           05 EID2                 PIC X(05).                       
           05 FILLER              PIC X(01).                      
           05 EADD2             PIC X(10).                    
           05 FILLER              PIC X(64).                      
       FD MCHFILE.                                                  
       01 MCHREC.                                                  
           05 EIDO                 PIC X(05).                      
           05 FILLER               PIC X(01).                      
           05 ENAMEO          PIC X(06).                 
           05 FILLER               PIC X(01).                      
           05 ESALO               PIC 9(05).                     
           05 FILLER               PIC X(01).                      
           05 EADDO             PIC X(10).                   
           05 FILLER               PIC X(51).                      
       WORKING-STORAGE SECTION.                   
       01 FS1                       PIC X(02).                        
       01 FS2                       PIC X(02).                        
       01 FS3                       PIC X(02).                        
       01 SWITCH1             PIC X(01).                  
           88 EOF1                 VALUE 'Y'.                     
           88 NOT-EOF1        VALUE 'N'.               
       01 SWITCH2              PIC X(01).                 
           88 EOF2                  VALUE 'Y'.                    
           88 NOT-EOF2         VALUE 'N'.              
       01 WS-EID                   PIC X(05).                   
       PROCEDURE DIVISION.                               
           SET NOT-EOF1 TO TRUE                         
           PERFORM OPEN-PARA.                          
           PERFORM READ-PARA UNTIL EOF1.    
           PERFORM CLOSE-PARA.                         
           STOP RUN.                                                
       OPEN-PARA.                                                 
           OPEN INPUT INFILE                                 
           OPEN OUTPUT MCHFILE.                       
           DISPLAY ' INFILE  OPEN STATUS ' FS1
           DISPLAY ' MCHFILE OPEN STATUS ' FS3.                        
       READ-PARA.                                                      
           IF FS1 = '00'                                               
              READ INFILE                                            
                AT END                                                  
                   SET EOF1 TO TRUE                           
                NOT AT END                                         
                   MOVE EID1 TO WS-EID                                 
                    SET NOT-EOF2 TO TRUE                          
                     PERFORM OPEN-OUT-PARA                  
                     PERFORM READ-OUT-PARA UNTIL EOF2                  
                     PERFORM CLOSE-OUT-PARA                            
              END-READ                                                 
           END-IF.                                                     
       OPEN-OUT-PARA.                                        
           OPEN INPUT OUTFILE                             
           DISPLAY ' OUTFILE OPEN STATUS ' FS2.
       READ-OUT-PARA.                                          
           IF FS2 = '00'                                               
             READ OUTFILE                                         
              AT END                                                   
                SET EOF2 TO TRUE                              
              NOT AT END                                           
                IF WS-EID = EID2                                 
                   MOVE EID1 TO EIDO                       
                   MOVE ENAME1 TO ENAMEO        
                   MOVE ESAL1 TO ESALO                  
                   MOVE EADD2 TO EADDO               
                   WRITE MCHREC                                
                END-IF                                                  
             END-READ.                                             
       CLOSE-OUT-PARA.                                      
           CLOSE OUTFILE                                               
           DISPLAY ' OUTFILE CLOSE STATUS ' FS2.     
       CLOSE-PARA.                                                     
           CLOSE INFILE                                                
           CLOSE MCHFILE.                                           
           DISPLAY ' INFILE  CLOSE STATUS ' FS1.     
           DISPLAY ' MCHFILE CLOSE STATUS ' FS3. 

JCL to Execute above cobol program -
//STEP010    EXEC  IGYWCLG,MEM=FILCMPR                             
//SYSPRINT DD  SYSOUT=*                                          
//COBOL.SYSIN  DD  DSN=XX7384A.JCLLIB.SELFTEST.Y2013.COB(&MEM),  
//                             DISP=SHR                                                 
//GO.DD1      DD          *
                                                    
21400 SANDIP 33333                                               
21500 MANDIP 44444                                               
21600 RANDIP 99999                                               
21700 BALDIP 66666
                                               
//GO.DD2      DD         *                                                    
21500 PUNE                                                       
21600 MUMBAI                                                     
21900 CHENAI                                                     
22000 HYDERABAD
                                                  
//GO.DD3      DD          SYSOUT=*                                             
//LKED.SYSLMOD DD  DSN=XX7384A.COBOL.LOADLIB(&MEM),DISP=SHR      
//*
                                                              

Output :
21500 MANDIP 44444 PUNE      
21600 RANDIP 99999 MUMBAI
    


Above program will degrade the performance so this is not advisable.
Option2 program is efficient. 

Option2:
NOTE: Both the files are sorted on key and duplicates are removed from both input files.

IDENTIFICATION DIVISION.
PROGRAM-ID. COMPFIL.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT INFILE1 ASSIGN TO DD1.
  SELECT INFILE2 ASSIGN TO DD2.
  SELECT INFILEB ASSIGN TO DD3.
  SELECT INFILE1O ASSIGN TO DD4.
  SELECT INFILE2O ASSIGN TO DD5.
DATA DIVISION.
FILE SECTION.
FD INFILE1.
01 INREC1.
    05 ID1   PIC 9(03).
    05 FILLER PIC X(77).
FD INFILE2.
01 INREC2.
    05 ID2      PIC 9(03).
    05 FILLER PIC X(77).
FD INFILEB.
01 INRECB.
    FILLER      PIC X(80).
FD INFILE1O.
01 INREC1O.
     FILLER     PIC X(80).
FD INFILE2O.
01 INREC2O.
     FILLER     PIC X(80).
WORKING-STORAGE SECTION.
01 WS-VAR.
     05 SWT1             PIC X(01).
         88 EOF1          VALUE 'Y'.
         88 NOT-EOF1   VALUE 'N'.
     05 SWT2             PIC X(01).
         88 EOF2          VALUE 'Y'.
         88 NOT-EOF2   VALUE 'N'.
     05 WS-ID1          PIC 9(03).
     05 WS-ID2          PIC 9(03).
PROCEDURE DIVISION
     SET NOT-EOF1 TO TRUE
     SET NOT-EOF2 TO TRUE
     OPEN INPUT INFILE1
                       INFILE2
     OPEN OUTPUT INFILEB
                          INFILE1O
                          INFILE2O   
     PERFORM READ-FILE1 
     PERFORM READ-FILE2
     PERFORM MTCH-PARA
     PERFORM CLOS-PARA.
READ-FILE1.
     READ INFILE1 
           AT END 
                SET EOF1 TO TRUE
           NOT AT END
                MOVE ID1 TO WS-ID1
     END-READ.
READ-FILE2.
     READ INFILE2 
           AT END 
                SET EOF2 TO TRUE
           NOT AT END
                MOVE ID2 TO WS-ID2
     END-READ.
MTCH-PARA.
    IF EOF1 AND EOF2
        GO TO CLOS-PARA
    END-IF
    IF EOF1 AND NOT-EOF2
        PERFORM READ-FILE2
        INITIALIZE INREC2O
        MOVE INREC2 TO INREC2O
        WRITE INREC2O
        GO TO MTCH-PARA
   END-IF
   IF NOT-EOF1 AND EOF2
       PERFORM READ-FILE1 
       INITIALIZE INREC1O
       MOVE INREC1 TO INREC1O
       WRITE INREC1O 
   END-IF
   IF WS-ID1 = WS-ID2
       INITIALIZE INRECB
       MOVE INREC1 TO INRECB
       WRITE INRECB
       PERFORM READ-FILE1
       PERFORM READ-FILE2
       GO TO MTCH-PARA
   ELSE
       IF WS-ID1 < WS-ID2
           INITIALIZE INREC1 
           MOVE INREC1 TO INREC1O
           WRITE INREC1O
           PERFORM READ-FILE1
           GO TO MTCH-PARA
      ELSE
           INITIALIZE INREC2O
           MOVE INREC2 TO INREC2O
           WRITE INREC2O
           PERFORM READ-FILE2
           GO TO MTCH-PARA
      END-IF
   END-IF.
CLOS-PARA.
   CLOSE INFILE1
             INFILE2
             INFILEB
             INFILE1O
             INFILE2O.
   STOP RUN.              

JCL to run this program:
//AB7384A JOB (ACCT,U,A),'COMPFIL',CLASS=B,
//            MSGCLASS=O,NOTIFY=&SYSUID
//*
//   JCLLIB ORDER=AB7384A.SOURCE.PROCLIB
//STEP1 EXEC IGYWCLG,MEM=COMPFIL
//COBOL.SYSIN DD DSN=AB7384A.SOURCE.COBOL(&MEM),DISP=SHR
//GO.DD1 DD DSN=AB7384A.TEST.IN1,DISP=SHR
//GO.DD2 DD DSN=AB7384A.TEST.IN2,DISP=SHR
//GO.DD3 DD DSN=AB7384A.TEST.IN3,DISP=OLD
//GO.DD4 DD DSN=AB7384A.TEST.IN4,DISP=OLD
//GO.DD5 DD DSN=AB7384A.TEST.IN5,DISP=OLD 
//LKED.SYSLMOD DD DSN=AB7384A.COBOL.LOADLIB(&MEM),DISP=SHR
//GO.SYSIN DD *
//*

Input File1:
080
100
125
150
175
200

Input File2:
020
040
080
090
095
100
150
160
170
175
200
210
220

Match file:
080
100
150
175
200

Nomch file1:  (No Match Data from file1) 
125

Nomch file2:  (No Match Data from file2) 
020
040
090
160
170
210
220