Thursday, 3 January 2019

VSAM Intro

VSAM - Virtual Storage Access Method

A VSAM cluster is a logical definition for a VSAM data set and has one or two components. viz.,
Index component - Contains pointers to all data records to access them
Data component - Contains actual records


VSAM commands:

All the following operations (including CREATE and DELETE) should be done through IDCAMS utility.

ALTER - To modify the attributes of VSAM file.
REPRO - To load the data into VSAM data set (from sequential file to VSAM file), to copy the data from one VSAM file to another VSAM file.
LISTCAT - To get the catalog information of a VSAM dataset like dataset attributes, allocation information, volume information...  
EXAMINE - Checks the structural integrity of a given KSDS cluster. It checks index and data components and reports if there are any issues.
VERIFY - Checks and fix VSAM files which are not closed properly after an error

An Alternate Index provides access to records using more than one key. The key of an alternate Index can be a unique/non-unique key. We define alternate index for a given VSAM cluster.

Sunday, 26 August 2018

DB2 LOAD error : INPUT FIELD 'field-name' NOT ENTIRELY WITHIN INPUT RECORD

Whenever you get an error 'INPUT FIELD 'field-name' NOT ENTIRELY WITHIN INPUT RECORD' while LOADing the data to a DB2 table,

Please check whether the length of the field-name in DB2 table is equal to the length of the corresponding field-name in LOAD file. The length of both the fields SHOULD match. 



COBOL cheat sheet


  1. ENVIRONMENT DIVISION is optional.
  2. DATA DIVISION is optional.
  3. In IDENTIFICATION DIVISION, except PROGRAM-ID. everything else is optional.
  4. From Column 8-11, we call AREA-A where we should code DIVISIONS, SECTIONS, PARAGRAPHS and 01 group level items.
  5. From column 12-72, we call AREA-B where we will code rest of the Cobol statements other than DIVISIONS, SECTIONS, PARAGRAPHS and 01 group level items.
  6. If you specify SELECT OPTIONAL file ASSIGN TO filename, and if filename is not present physically then the program will NOT abend. Files with OPTIONAL can be opened with EXTEND, I/O or INPUT mode so that the file will be created else it return status code 35.
  7. FILE STATUS is used to identify the status of each operation performed against the file. FILE STATUS IS ws-status, where ws-status can be declared in working storage section with length of 2 bytes.  
  8. SELECT empfile ASSIGN TO empfileo where empfile is a logical file and empfileo is physical file. Inside the cobol program, for any operation on this file we have to use logical file name which is empfile and later all these operations will be reflected in physical file empfileo.
  9. If you are passing data from JCL to cobol program using PARM parameter, please declare two variables in linkage section viz., one is to store length of the data and the other one for actual data.
  10. Main program will have 'PROCEDURE DIVISION' where as sub-program or called program will have 'PROCEDURE DIVISION using [data-items]...
  11. USAGE clause reduce the storage space indirectly increasing the efficiency of the program. The default usage is DISPLAY and its not applicable for 66,77 and 88 level items. 
  12. COMP-1 => Left most 8 bits for exponent and remaining 24 bits for mantissa. COMP-2 => Left most 12 bits for exponent and 52 bits for mantissa. Both of the items store data in the format of Mantissa and exponent.
  13. Comp-3 => also called as packed decimal form where the data will be stored in memory as BCD (Binary Coded Decimal) format. Two digits can be stored in each byte and the number of bytes required for a variable is calculated using formula (n+1)/2. The low nybble of the least significant byte contains a sign. So even though we didn't define sign variable for COMP-3, a nibble is reserved for it. 
    Examples: 

    PIC S9(7) COMP-3.     Byte size = (7 + 1) / 2 = 4

    PIC S9(5)V99 COMP-3.  Byte size = (5 + 2 + 1) / 2 = 4

    PIC S9(6) COMP-3.     Byte size = (6 + 1) / 2 = 3.5, rounded to 4
Comp-3 fields reserve a nybble for the sign, even for "unsigned" values, so the following fields are still 4 bytes:
    PIC 9(7) COMP-3.     Byte size = (7 + 1) / 2 = 4
    PIC 9(6) COMP-3.     Byte size = (6 + 1) / 2 = 3.5, rounded to 4

You can also use the the formula (N/2) + 1, but just consider integer part as total number of bytes.
For instance, 
PIC S9(7) COMP-3   => Byte size = 7/2  + 1 => 3.5 + 1 => 4.5 => integer part means, 4.


14. START command is used in DYNAMIC mode to read the KSDS file. It will set the pointer to the next read for reading the record.
     START file-name KEY <relational-operator> <data-name>
             [INVALID KEY statements]
             [NOT INVALID KEY statements]
     END-EVALUATE.
     First key-value will be moved to data name and once START commands executes, the pointer will be placed at the starting of matched record.

15. READ NEXT is used to read the records sequentially after the record to which pointer was set by the START command based on key value.




       

Thursday, 2 November 2017

SYNCPOINT

SYNCPOINT divides a long-running task into smaller units of work. 

It specifies that all  the changes made by the task since its last syncpoint are to be committed. 

SYNCPOINT ROLLBACK

It specifies that all the changes made to recoverable resources by the task since its last syncpoint are to be backed out.

In order to reset all CICS recoverable resources because the transaction is not finished, we back out the current unit of work (UOW) by performing the following command

EXEC CICS SYNCPOINT ROLLBACK
END-EXEC

Monday, 30 October 2017

WHENEVER Clause


WHENEVER specifies the host language statement to be executed when an exception condition occurs.

Three types of WHENEVER :-

1.WHENEVER NOT FOUND

Example:

go to the label ENDDATA for any statement does not return

EXEC SQL
     WHENEVER NOT FOUND
        GO TO ENDDATA
END-EXEC.

NOT FOUND => Identifies any condition that results in an SQLCODE of +100.

2.WHENEVER SQLERROR

Go to label handler for any statement that produces an error

EXEC SQL
     WHENEVER SQLERROR
     GO TO HANDLER
END-EXEC.

SQLERROR => Identifies any condition that results in negative SQLCODE.

3.WHENEVER SQLWARNING 

Continue the processing when any statement produces a warning

EXEC SQL
     WHENEVER SQLWARNING
     CONTINUE
END-EXEC.

SQLWARNING => Identifies any condition that results in warning condition (SQLWARN0 is W) or that results in Positive SQLCODE other than +100.

Tuesday, 1 August 2017

IEBCOMPR Utility

IEBCOMPR utility is used to

  • Compare two PS (Physical Sequential) Datasets
  • Compare two PDS (Partitioned Data Set)/PDSE (Partitioned Data Set Extended)

If we want to compare two PS files using this utility, both must have same record length. 

Ex. Comparing two PS files

//STEP1  EXEC PGM=IEBCOMPR
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=PSFILE1,DISP=SHR
//SYSUT2 DD DSN=PSFILE2,DISP=SHR
//SYSIN   DD *
  COMPARE TYPORG=PS
/*

The two PS files which are to be compared must be given in SYSUT1 and SYSUT2

COMPARE TYPORG=PS specifies that the input data sets are PS files.

If they are PDS/PDSE files, then we should give COMPARE TYPORG=PO

Ex. Comparing two PDS files

//STEP1  EXEC PGM=IEBCOMPR
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=PDSFILE1,DISP=SHR
//SYSUT2 DD DSN=PDSFILE2,DISP=SHR
//SYSIN   DD *
  COMPARE TYPORG=PO
/*


Monday, 24 July 2017

MVS Abbrevations


MVS - Multiple Virtual Storage, is an operating system from IBM that runs on system/370 and system/390 IBM mainframe computers.

TSO - Time Sharing Option, lets remote terminal users invoke MVS facilities interactively.

ISPF - Interactive System Productivity Facility, runs a part of TSO and utilizes full screen capability of 3270 terminals.

PDF - Program Development Facility, part of the ISPF.

RACF - Resource Access Control Facility, identifies both users and resources.

SMF - System Management Facility, facilitates billing and monitoring.
           Ex. CPU time used, amount of DASD etc..

SMS - Storage Management Subsystem, automates data management services of             MVS.

JES - Job Entry Subsystem, provides job management facilities on MVS.

DASD - Direct Access Storage Device