COBOL ⭐ Featured
👁 0

Q: What are the four divisions of a COBOL program?

Answer:
  1. IDENTIFICATION DIVISION - Program identification (PROGRAM-ID)
  2. ENVIRONMENT DIVISION - Hardware/software environment, file assignments
  3. DATA DIVISION - Data definitions (FILE, WORKING-STORAGE, LINKAGE SECTION)
  4. PROCEDURE DIVISION - Executable code and business logic

Only IDENTIFICATION and PROCEDURE DIVISION are mandatory.

COBOL ⭐ Featured
👁 0

Q: What is the difference between SECTION and PARAGRAPH in COBOL?

Answer:

SECTION:

  • Contains one or more paragraphs
  • Ends with next SECTION or end of program
  • Used for logical grouping
  • Can be performed as a unit

PARAGRAPH:

  • Basic unit of code
  • Named block of statements
  • Ends at next paragraph name or SECTION

PERFORM SECTION-NAME executes all paragraphs in the section.

PERFORM PARA-NAME executes only that paragraph.

COBOL ⭐ Featured
👁 0

Q: Explain REDEFINES clause with an example.

Answer:

REDEFINES allows the same storage area to be referenced by different data names with different definitions.

Rules:

  • Must be at same level as item being redefined
  • Cannot redefine item with OCCURS
  • Redefined item must appear first
  • Lengths should match or redefining should be shorter
01 WS-DATE.
   05 WS-DATE-NUM    PIC 9(8).
01 WS-DATE-X REDEFINES WS-DATE.
   05 WS-YEAR        PIC 9(4).
   05 WS-MONTH       PIC 9(2).
   05 WS-DAY         PIC 9(2).

Same 8 bytes can be accessed as single number or individual components.

COBOL ⭐ Featured
👁 0

Q: What is a copybook and why is it used?

Answer:

A copybook is a reusable code file that can be included in multiple programs using the COPY statement.

Uses:

  • Standard record layouts
  • Common working storage definitions
  • Reusable paragraphs
  • Ensures consistency across programs

Syntax:

COPY EMPREC.
COPY EMPREC REPLACING ==EMP== BY ==WS-EMP==.

Benefits:

  • Reduces code duplication
  • Easier maintenance
  • Standard definitions across team
JCL ⭐ Featured
👁 0

Q: What is the difference between PARM and SYSIN for passing parameters?

Answer:

PARM (EXEC statement):

  • Limited to 100 characters
  • Passed in memory to program
  • Accessed via LINKAGE SECTION
  • Good for small, simple parameters

SYSIN (DD statement):

  • No practical size limit
  • Read as a file by program
  • Can contain multiple records
  • Good for control cards, complex input
// PARM example
//STEP1 EXEC PGM=MYPROG,PARM='PARAM1,PARAM2'

// SYSIN example
//SYSIN DD *
CONTROL OPTION1
DATE=20231215
LIMIT=1000
/*
DB2 ⭐ Featured
👁 0

Q: What is SQLCODE and what are common values?

Answer:

SQLCODE is a return code in SQLCA indicating the result of SQL execution.

Common SQLCODE values:

0Successful execution
100No data found / End of cursor
-803Duplicate key on insert
-811Multiple rows returned for singleton SELECT
-904Unavailable resource
-911Deadlock/timeout
-922Authorization failure
-927DB2 not available

Negative = Error, 0 = Success, 100 = No data

DB2 ⭐ Featured
👁 0

Q: Explain the difference between INNER JOIN and LEFT OUTER JOIN.

Answer:

INNER JOIN:

  • Returns only matching rows from both tables
  • If no match, row is excluded

LEFT OUTER JOIN:

  • Returns all rows from left table
  • Matching rows from right table
  • NULL for right table if no match
-- INNER JOIN
SELECT E.NAME, D.DEPT_NAME
FROM EMPLOYEE E
INNER JOIN DEPARTMENT D
ON E.DEPT_ID = D.DEPT_ID;

-- LEFT OUTER JOIN
SELECT E.NAME, D.DEPT_NAME
FROM EMPLOYEE E
LEFT OUTER JOIN DEPARTMENT D
ON E.DEPT_ID = D.DEPT_ID;

Use LEFT JOIN when you want all employees even those without department.

CICS ⭐ Featured
👁 0

Q: What is the purpose of COMMAREA in CICS?

Answer:

COMMAREA (Communication Area) is used to pass data between programs or between transactions in pseudo-conversational programming.

Uses:

  • Pass data between LINK/XCTL programs
  • Save data between pseudo-conversational transactions
  • Maximum size: 32KB

How it works:

  1. Calling program: COMMAREA option on LINK/XCTL/RETURN
  2. Called program: DFHCOMMAREA in LINKAGE SECTION
  3. Check EIBCALEN for length (0 = no COMMAREA)
* Calling program
EXEC CICS LINK
    PROGRAM('SUBPROG')
    COMMAREA(WS-DATA)
    LENGTH(100)
END-EXEC.

* Called program
LINKAGE SECTION.
01 DFHCOMMAREA PIC X(100).

IF EIBCALEN > 0
    MOVE DFHCOMMAREA TO WS-DATA
END-IF.