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: 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
COBOL ⭐ Featured
👁 0

Q: Explain SECTION vs PARAGRAPH

Answer:
SECTION groups related paragraphs, terminated by next SECTION or end of program. PARAGRAPH is a named block of code, terminated by next paragraph/section. PERFORM SECTION executes all paragraphs within. SECTION needed for segmentation, PARAGRAPH for simple procedures.
COBOL ⭐ Featured
👁 0

Q: How to use EXIT PERFORM?

Answer:
EXIT PERFORM immediately exits current PERFORM loop. EXIT PERFORM CYCLE skips to next iteration. COBOL 2002+ feature. Previously used GO TO with OUT-OF-PARAGRAPH technique. Makes loop control cleaner without extra flags.
COBOL ⭐ Featured
👁 0

Q: What is PERFORM recursion limit?

Answer:
COBOL doesn't traditionally support recursion; same paragraph in PERFORM stack causes error. RECURSIVE clause in PROGRAM-ID enables it. Recursive programs need local storage. Stack depth limited by system resources. Usually avoid in COBOL.
COBOL ⭐ Featured
👁 0

Q: What is OBJECT-COMPUTER paragraph?

Answer:
OBJECT-COMPUTER describes execution machine. OBJECT-COMPUTER. IBM-3090. MEMORY SIZE clause deprecated. PROGRAM COLLATING SEQUENCE for sort order. SEGMENT-LIMIT for overlay. Mostly documentation now; compiler usually ignores.
COBOL ⭐ Featured
👁 0

Q: What is READY TRACE?

Answer:
READY TRACE turns on paragraph tracing. Shows paragraph names as executed. RESET TRACE turns off. Must compile with debugging option. Output goes to SYSOUT. Replaced by better debuggers but useful for quick flow analysis.
COBOL ⭐ Featured
👁 0

Q: How to use PERFORM EXIT?

Answer:
EXIT statement marks paragraph end. PERFORM PROCESS-DATA THRU PROCESS-EXIT. Process-exit paragraph contains only EXIT. Ensures consistent exit point. Can also GO TO exit paragraph. EXIT PROGRAM in subprogram returns to caller.
COBOL
👁 0

Q: Explain PERFORM VARYING with example

Answer:
PERFORM VARYING executes a paragraph while incrementing a counter. Syntax: PERFORM para-name VARYING WS-IDX FROM 1 BY 1 UNTIL WS-IDX > 10. The counter is initialized, tested, and incremented automatically. Can have nested VARYING with AFTER clause.
COBOL
👁 0

Q: How does PERFORM THRU work?

Answer:
PERFORM para-1 THRU para-2 executes from para-1 through para-2 inclusive. Paragraphs must be contiguous. Common: PERFORM 1000-INIT THRU 1000-EXIT where EXIT paragraph has only EXIT. Ensures cleanup code always runs.
COBOL
👁 0

Q: Explain SPECIAL-NAMES paragraph

Answer:
SPECIAL-NAMES maps system names to COBOL names. DECIMAL-POINT IS COMMA for European notation. CURRENCY SIGN IS '$'. SYMBOLIC CHARACTERS name = value. ALPHABET for custom collating. CLASS for character groups.