COBOL Mainframe Interview Questions - Part 2

  1. What is the difference between CONTINUE & NEXT SENTENCE ?
    CONTINUE is like a null statement (do nothing) , while NEXT SENTENCE transfers control to the next sentence (!!) (A sentence is terminated by a period)
  2. What does EXIT do ?
    Does nothing ! If used, must be the only sentence within a paragraph.
  3. Can I redefine an X(100) field with a field of X(200)?
    Yes. Redefines just causes both fields to start at the same location. For example:

    01 WS-TOP PIC X(1)

    01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).

    If you MOVE '12' to WS-TOP-RED,

    DISPLAY WS-TOP will show 1 while

    DISPLAY WS-TOP-RED will show 12.
  4. Can I redefine an X(200) field with a field of X(100) ?
    Yes.
  5. What do you do to resolve SOC-7 error?
    Basically you need to correcting the offending data.

    Many times the reason for SOC7 is an un-initialized numeric item. Examine that possibility first.

    Many installations provide you a dump for run time abends ( it can be generated also by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL.

    If none of these are helpful, use judgement and DISPLAY to localize the source of error.

    Some installtion might have batch program debugging tools. Use them.
  6. How is sign stored in Packed Decimal fields and Zoned Decimal fields?
    Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage.

    Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite.
  7. How is sign stored in a comp-3 field?
    It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is -102 etc...
  8. How is sign stored in a COMP field ?
    In the most significant bit. Bit is on if -ve, off if +ve.
  9. What is the difference between COMP & COMP-3 ?
    COMP is a binary storage format while COMP-3 is packed decimal format.
  10. What is COMP-1? COMP-2?
    COMP-1 - Single precision floating point. Uses 4 bytes.

    COMP-2 - Double precision floating point. Uses 8 bytes.
  11. How do you define a variable of COMP-1? COMP-2?
    No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
  12. How many bytes does a S9(7) COMP-3 field occupy ?
    Will take 4 bytes. Sign is stored as hex value in the last nibble.

    General formula is INT((n/2) + 1)), where n=7 in this example
  13. How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?
    Will occupy 8 bytes (one extra byte for sign).
  14. How many bytes will a S9(8) COMP field occupy ?
    4 bytes
  15. What is the maximum value that can be stored in S9(8) COMP?
    99999999
  16. What is COMP SYNC?
    Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT.

    For binary data items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4. You might see some wastage of memory, but the access to this computational field is faster.
  17. What is the maximum size of a 01 level item in COBOL I? in COBOL II?
    In COBOL II: 16777215
  18. How do you reference the following file formats from COBOL programs:
    Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0 .

    Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS

    Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4

    Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4.

    ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL.

    KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS

    RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS

    Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).
  19. What are different file OPEN modes available in COBOL?
    Open for INPUT, OUTPUT, I-O, EXTEND.
  20. What is the mode in which you will OPEN a file for writing?
    OUTPUT, EXTEND
  21. In the JCL, how do you define the files referred to in a subroutine ?
    Supply the DD cards just as you would for files referred to in the main program.
  22. Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?
    Can rewrite(record length must be same), but not delete.
  23. What is file status 92?
    Logic error. e.g., a file is opened for input and an attempt is made to write to it.
  24. What is file status 39 ?
    Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You will get file status 39 on an OPEN.
  25. What is Static,Dynamic linking ?
    In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).

    A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.
  26. What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? ( applicable to only MVS/ESA Enterprise Server).

    These are compile/link edit options.

    AMODE - Addressing mode. RMODE - Residency mode.

    AMODE(24) - 24 bit addressing. AMODE(31) - 31 bit addressing. AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE.

    RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only).

    RMODE(ANY) - Can reside above or below 16 Meg line.
  27. What compiler option would you use for dynamic linking?
    DYNAM.
  28. What is SSRANGE, NOSSRANGE ?
    These are compiler options w.r.t subscript out of range checking. NOSSRANGE is the default and if chosen, no run time error will be flagged if your index or subscript goes out of the permissible range.
  29. How do you set a return code to the JCL from a COBOL program?
    Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.
  30. How can you submit a job from COBOL programs?
    Write JCL cards to a dataset with

    //xxxxxxx SYSOUT=(A,INTRDR) where 'A' is output class, and dataset should be opened for output in the program. Define a 80 byte record layout for the file.
  31. What are the differences between OS VS COBOL and VS COBOL II?
    OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can run either in 24 bit or 31 bit addressing modes.

    Report writer is supported only in OS/VS Cobol.

    USAGE IS POINTER is supported only in VS COBOL II.

    Reference modification eg: WS-VAR(1:2) is supported only in VS COBOL II.

    EVALUATE is supported only in VS COBOL II.

    Scope terminators are supported only in VS COBOL II.

    OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.

    Under CICS Calls between VS COBOL II programs are supported
  32. What are the steps you go through while creating a COBOL program executable?
    DB2 precompiler (if embedded sql used), CICS translator (if CICS pgm), Cobol compiler, Link editor.
    If DB2 program, create plan by binding the DBRMs
  33. Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
    In non-CICS environment, it is possible. In CICS, this is not possible.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...