COBOL ⭐ Featured
👁 0

Q: What is the difference between COMP and COMP-3 in COBOL?

Answer:

COMP (COMPUTATIONAL) - Pure binary format

  • Stored in binary (base-2)
  • Used for subscripts and counts
  • Efficient for arithmetic operations
  • PIC S9(4) COMP = 2 bytes
  • PIC S9(9) COMP = 4 bytes

COMP-3 (PACKED DECIMAL)

  • Each digit takes 4 bits (nibble)
  • Last nibble holds sign
  • Used for business calculations
  • PIC S9(5) COMP-3 = 3 bytes
  • Formula: (n+1)/2 rounded up

When to use:

  • COMP - Array subscripts, counters, loops
  • COMP-3 - Money, quantities, business data
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.

DB2 ⭐ Featured
👁 0

Q: How to handle CLOB in COBOL?

Answer:
Declare: 01 CLOB-VAR SQL TYPE IS CLOB(1M). Or use LOB locator: 01 CLOB-LOC SQL TYPE IS CLOB_LOCATOR. FREE LOCATOR releases. DBMS_LOB procedures for manipulation. Large CLOBs need special handling.
COBOL ⭐ Featured
👁 0

Q: How to handle EBCDIC/ASCII conversion?

Answer:
COBOL on mainframe uses EBCDIC natively. For ASCII conversion: use INSPECT CONVERTING, or file translation (JCL), or LE functions. NATIONAL-OF and DISPLAY-OF for Unicode. Different collating sequences affect SORT and comparisons.
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: Explain EXEC SQL statements

Answer:
EXEC SQL marks embedded DB2 SQL. EXEC SQL SELECT col INTO :host-var FROM table WHERE key = :key-var END-EXEC. Colon prefix for host variables. SQLCODE in SQLCA indicates result. Precompiler converts to COBOL calls.
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.
VSAM ⭐ Featured
👁 0

Q: What causes file status 48?

Answer:
Status 48 is OPEN failure, file already open. Check logic - may have duplicate OPEN. CLOSE before re-OPEN. COBOL FILE-STATUS check important. May be another job has exclusive access.
COBOL ⭐ Featured
👁 0

Q: What is LOCAL-STORAGE SECTION?

Answer:
LOCAL-STORAGE SECTION is reinitialized each invocation. Unlike WORKING-STORAGE which retains values. Each thread gets own copy. Useful for recursive programs and threaded environments. COBOL-85+ feature. Not all compilers support equally.
VSAM ⭐ Featured
👁 0

Q: How to handle variable length KSDS?

Answer:
Define with RECORDSIZE(avg max). Read/write variable length records. COBOL RECORD VARYING clause. Key position fixed. Read returns actual length. Write length implicit from record.
COBOL ⭐ Featured
👁 0

Q: What is XML GENERATE?

Answer:
XML GENERATE creates XML from data. XML GENERATE output FROM data-item. Optional: COUNT IN length, WITH ENCODING, WITH XML-DECLARATION. Generates element for each field. Names from data names. COBOL 5+ feature.
COBOL ⭐ Featured
👁 0

Q: How to define FILE-CONTROL?

Answer:
SELECT file-name ASSIGN TO ddname. ORGANIZATION IS INDEXED. ACCESS MODE IS DYNAMIC. RECORD KEY IS key-field. ALTERNATE RECORD KEY IS alt-key. FILE STATUS IS ws-status. Maps COBOL file to physical dataset.
VSAM ⭐ Featured
👁 0

Q: Explain MASSINSERT?

Answer:
MASSINSERT optimizes bulk sequential inserts. System defers CI splits. Better performance for loads. Implicit with REPRO. COBOL can hint with APPLY WRITE-ONLY style.
VSAM ⭐ Featured
👁 0

Q: How to handle VSAM in batch?

Answer:
Define cluster with IDCAMS. JCL DD statement references cluster. COBOL SELECT maps to DD. ACCESS MODE matches operations. Close properly. STATUS check after operations.
CICS ⭐ Featured
👁 0

Q: What is BMS?

Answer:
BMS (Basic Mapping Support) handles screen I/O. Map defines screen layout. DFHMSD macro creates mapset. SEND MAP displays screen. RECEIVE MAP gets input. Symbolic map in COBOL copybook. Physical map in load library.
CICS ⭐ Featured
👁 0

Q: What is EIB?

Answer:
EIB (Execute Interface Block) contains execution info. EIBCALEN=COMMAREA length. EIBTRNID=transaction. EIBAID=attention key. EIBDATE/EIBTIME=date/time. EIBRESP/EIBRESP2=response codes. Automatically available in COBOL.
CICS ⭐ Featured
👁 0

Q: What is CICS Liberty?

Answer:
CICS Liberty embeds Java server. Run Java apps in CICS. RESTful services. Modern application development. Coexists with COBOL. Container environment.
DB2 ⭐ Featured
👁 0

Q: Explain NULL handling in DB2

Answer:
NULL means unknown/missing value. NULL != NULL returns unknown. Use IS NULL, IS NOT NULL. COALESCE(col, default) substitutes. NULL in arithmetic yields NULL. Indicator variables detect NULL in COBOL. NVL function alternative.
DB2 ⭐ Featured
👁 0

Q: What is indicator variable?

Answer:
Indicator variable detects NULL values. Declare: 01 col-var. 01 col-ind PIC S9(4) COMP. Use: INTO :col-var:col-ind. If col-ind < 0, value is NULL. Set indicator negative to insert NULL. Required for nullable columns.
DB2
👁 0

Q: What is DCLGEN?

Answer:
DCLGEN generates COBOL declarations from table. DCLGEN TABLE(name) LIBRARY(dataset) STRUCTURE(host-struct-name). Creates copybook with field definitions. Essential for maintaining table-program consistency.
COBOL
👁 0

Q: What is EVALUATE statement and when to use it?

Answer:
EVALUATE is COBOL's case/switch construct. Syntax: EVALUATE TRUE WHEN condition-1 statement WHEN OTHER default END-EVALUATE. More readable than nested IF for multiple conditions. Can evaluate multiple subjects and use THRU for ranges.
COBOL
👁 0

Q: What is CORRESPONDING in COBOL?

Answer:
CORRESPONDING (CORR) operates on fields with matching names. MOVE CORRESPONDING record-1 TO record-2 moves all matching fields. ADD CORRESPONDING does arithmetic. Reduces code but requires careful naming. Not recommended for performance-critical code.
DB2
👁 0

Q: Explain host variable rules

Answer:
Host variables prefixed with : in SQL. Declare in WORKING-STORAGE. Must be compatible types. Use indicator for NULL. Cannot use in dynamic object names. VARCHAR needs two-part structure in COBOL.
COBOL
👁 0

Q: What is SORT and MERGE in COBOL?

Answer:
SORT orders records: SORT SORT-FILE ON ASCENDING KEY-FIELD USING INPUT-FILE GIVING OUTPUT-FILE. INPUT/OUTPUT PROCEDURE allows processing during sort. MERGE combines pre-sorted files: MERGE SORT-FILE ON KEY USING FILE-1 FILE-2 GIVING OUTPUT-FILE.
COBOL
👁 0

Q: What are nested programs?

Answer:
Nested programs are contained within another COBOL program. Defined between IDENTIFICATION DIVISION and END PROGRAM. Can access outer program's data with GLOBAL clause. COMMON attribute allows access from sibling programs. Promotes modular design.
COBOL
👁 0

Q: How to use intrinsic functions?

Answer:
COBOL-85 intrinsic functions: FUNCTION LENGTH(field), FUNCTION CURRENT-DATE, FUNCTION UPPER-CASE(field), FUNCTION NUMVAL(field), FUNCTION MOD(a,b), FUNCTION INTEGER-OF-DATE(date). Use in expressions or with COMPUTE. Return values only, no side effects.
VSAM
👁 0

Q: How to read VSAM sequentially?

Answer:
OPEN INPUT file. START if positioning needed. READ NEXT repeatedly until status 10 (end of file). CLOSE file. START optional - defaults to beginning. READ NEXT gets records in key sequence for KSDS.
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.
VSAM
👁 0

Q: How to delete records from KSDS?

Answer:
READ record with key. DELETE record-name. Status 00 if successful. In COBOL, DELETE uses primary key. Can delete current record after READ. Cannot delete from ESDS.
COBOL
👁 0

Q: What is CURSOR IS clause?

Answer:
In Screen Section, CURSOR IS field-name positions cursor. ACCEPT screen-name WITH CURSOR. Runtime positions to specified field. Can set dynamically. Used in interactive COBOL (CICS typically handles cursor differently).
COBOL
👁 0

Q: Explain JSON GENERATE

Answer:
JSON GENERATE creates JSON from data. JSON GENERATE output FROM data-item. NAME clause for custom keys. SUPPRESS clause omits fields. COUNT IN length. COBOL V6+ feature. Generates name-value pairs from structure.