Thursday, 16 May 2013

COMP and its types in COBOL

COMP .

              It is a Binary storage format. In most significant bit, Bit is on if -ve, off if +ve.
no of bytes in COMP = (n/2)
Data Length                                           Length in COBOL
S9(1) to S9(4)                                         2 bytes
S9(5) to S9(9)                                         4 bytes
S9(10) to S9(18)                                     8 bytes

For example: S9(8) COMP  occupy how many bytes. = 4 bytes

COMP-1 and COMP-2.

          COMP-1 - Single precision floating point. Uses 4  byte
          COMP-2 - Double precision floating point. Uses 8 byte.
here for COMP-1 and COMP-2 no PIC clause is given

for example: 01 WS-VAL USAGE COMP-1.
                      01 WS-VAL USAGE COMP-2.

COMP-3.

            COMP-3 is an packed decimal format.

Packed decimal format: Sign stored as a HEX value in the last nibble (4bits) of the storage.

            In COMP-3 the sign is stored in last nibble. For example if your number is +100, it stores HEX 0C in the last byte same if the number is -102 then HEX 2D.
General formula for COMP-3 is INT((n/2)+1)

for example: if S9(7) COMP-3  will take 4 bytes
here n=7 so INT((7/2)+1) = 4 byte

COMP-4.

            Same as COMP.

Types of level in COBOL....

Level Numbers available are    

01-49      Group or elementary items
66           Renames clause
77           Independent elementary      data items
88           Condition names

77 level

 Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.

Syntax:
77 VAL        PIC X(4).

88 level 

88 level is used for condition names.
The level 88 in the Data Division can be used to give condition names to the values that a field contains. A condition name entry specifies either a single value or a set of values for the condityional variable. When this level is specified you can use the condition name instead of is =equal to in the IF statement. Condition name should be specified under Level 88 immediately following the field description.
 
syntax:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 COND            PIC X.
     88 ACCEPT    VALUE 'Y'.
     88 REJECT     VALUE 'N'.   
 77 WS-VAL         PIC X.

PROCEDURE DIVISION.  
          ACCPET  WS-VAL.
          IF ( ACCEPT )
              PROCEED
          END-IF.
          IF ( REJECT )
              ROLL BACK
          END-IF. 
          STOP RUN.

01-49 LEVEL.

Used to describe a record.

Syntax:
01 INREC.
     02 ID          PIC X(3).
          03 P-ID             PIC X(3).

66 level. 

Renames clause
It is used for regrouping of elementary data items in a record. It should be declared at 66 level.

syntax:
01 WS-REC
        05 WS-NAME          PIC X(03).
        05 WS-VALUE         PIC X(04).
        66 ADD-NAME  RENAMES WS-NAME.


Most common and most frequently and very Basic question asked in many interviews.....

COBOL - Common Business Oriented Language.

Divisions in COBOL.
           There are 4 divisions in COBOL. They are

1. IDENTIFICATION DIVISION
2. ENVIRONMENT DIVISION
3. DATA DIVISION
4. PROCEDURE DIVISION.

Different data types in COBOL.
            There are 3 data types in COBOL. They are

1. Numeric ( 9() )
2. Alpha-Numeric ( X() )
3. Alphabetic ( A() )


FAQ File handling error codes in COBOL

1      when at END condition fails

10  - end of file

2      This error will occur when Index key Fails

22  - Duplicate key
23  - Record not found

3      permanent Open Error Occurs

35  - Open statement attempted on a non-optional file that was not present.
37  - Open statement attempted on a file that would not support open mode.
39  - Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL.

4      Logic Error in Opening / Closing / Deleting etc 

42  - A CLOSE was attempted for a file not in the open mode.
47  - A READ was attempted for a file not open in the input or I-O mode.
48  - A WRITE was attempted on a file not open in the I-O, output, or extend mode.

9      Implementator Defined

92  - Logic error
93  - VSAM resource not available


Types of perform in COBOL.....

IN-LINE perform :
                   in an in-line perform the paragraph name is omitted and it should be delimited by the END-PERFORM phrase.

syntax:

PROCEDURE DIVISION.
          PERFORM .......
                STATEMENT 1
                ....                  2
                ....                  3
          END-PERFORM.

 Here all the statements under the perform will get executed till the END-PERFORM phrase is reached.

The PERFORM statement formats are:
1.  Basic PERFORM
2.  TIMES phrase PERFORM
3.  UNTIL phrase PERFORM
4.  VARYING phrase PERFORM

Basic PERFORM.
                PERFORM para-1 thru para-2
               
                PERFORM
                      imperative statement
                END-PERFORM.

 PERFORM with UNTIL phrase
                PERFORM procedure-1 thru procedure-2 until condition-1.

If the condition is true the PERFORM statement is initiated, the specified procedures are not executed.

PERFORM with VARYING phrase
                PERFORM para-1 thru para-3 varying N from 1 by 1 until N > 5.

In the above example Para-1 thru Para-3 will be executed 5 times.   

DD statement with parameter explanation...

DD STATEMENT :

The DD statement (Data Definition), is used to identify the source of input 
and the placement of output information


Syntax  ->  //ddname  DD  < positional / keyword parameters >

            ddname must be unique in the job

      
            Positional parameters -  *
                                                       DATA
                                                       DUMMY
                                                       DYNAM

            Keyword Parameters   -  DSN
                                                       DISP
                                                       UNIT
                                                       SPACE
                                                       DCB
                                                       VOLUME   

Wednesday, 15 May 2013

How to CREATE GDG and use it in next step...?

Here in JCL first we are creating an GDG (+1) and using it in the next step what will be the generation number...?

//STEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=CMAP054.TEST.GDGROUP(+1),
//       DISP=(NEW,CATLG,DELETE),
//       SPACE=(TRK,5),
//       DCB=(LRECL=80,RECFM=FB,BLKSIZE=800)
//STEP2 EXEC PGM=IEBGENER
//SYSUT1 DD DSN=  INPUT DATASET NAME,DISP=SHR
//SYSUT2 DD DSN= CMAP054.TEST.GDGGROUP(+1),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
/*
//

Expense Handler Application with advance technologies

Budget Planner  One of the application developed with Ionic 4 and Python-Flask.  Ionic 4 code:  https://github.com/logeshbuiltin/Expense...