MainframeMaster

COBOL Tutorial

COBOL SOURCE-COMPUTER Clause - Quick Reference

The SOURCE-COMPUTER clause in COBOL is used to specify the computer system where the source program was written. It provides documentation about the development environment and can be used for compilation and deployment considerations.

Primary Use

Specify development computer environment

Division

ENVIRONMENT DIVISION

Section

CONFIGURATION SECTION

Status

Optional clause

Overview

The SOURCE-COMPUTER clause is part of the CONFIGURATION SECTION in the ENVIRONMENT DIVISION. It identifies the computer system where the COBOL source program was developed or written. This information is primarily used for documentation purposes and can help with program maintenance, portability considerations, and cross-platform development.

Syntax

cobol
1
2
3
4
5
6
7
8
9
ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. computer-name [WITH DEBUGGING MODE]. * Examples: SOURCE-COMPUTER. IBM-3090. SOURCE-COMPUTER. VAX-11/780. SOURCE-COMPUTER. HP-3000. SOURCE-COMPUTER. IBM-3090 WITH DEBUGGING MODE.

Practical Examples

Basic SOURCE-COMPUTER Usage

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
* Basic SOURCE-COMPUTER clause example IDENTIFICATION DIVISION. PROGRAM-ID. SOURCE-COMPUTER-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-3090. OBJECT-COMPUTER. IBM-3090. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-MESSAGE PIC X(50) VALUE "Hello from IBM-3090". PROCEDURE DIVISION. MAIN-LOGIC. DISPLAY WS-MESSAGE DISPLAY "Source Computer: IBM-3090" DISPLAY "Object Computer: IBM-3090" STOP RUN.

Explanation: This example demonstrates basic usage of the SOURCE-COMPUTER clause. The program specifies that it was developed on an IBM-3090 mainframe computer. The SOURCE-COMPUTER clause is paired with OBJECT-COMPUTER to show both the development and execution environments.

SOURCE-COMPUTER with Debugging Mode

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
* SOURCE-COMPUTER with debugging mode IDENTIFICATION DIVISION. PROGRAM-ID. DEBUG-SOURCE-COMPUTER-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-3090 WITH DEBUGGING MODE. OBJECT-COMPUTER. IBM-3090. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-DEBUG-FLAG PIC X(1) VALUE 'Y'. 01 WS-COUNTER PIC 9(3) VALUE ZERO. 01 WS-RESULT PIC 9(5). PROCEDURE DIVISION. MAIN-LOGIC. * Debugging mode allows for conditional compilation IF WS-DEBUG-FLAG = 'Y' DISPLAY "Debug mode enabled" DISPLAY "Source Computer: IBM-3090 WITH DEBUGGING MODE" END-IF * Perform some calculations PERFORM VARYING WS-COUNTER FROM 1 BY 1 UNTIL WS-COUNTER > 5 COMPUTE WS-RESULT = WS-COUNTER * 10 IF WS-DEBUG-FLAG = 'Y' DISPLAY "Counter: " WS-COUNTER " Result: " WS-RESULT END-IF END-PERFORM DISPLAY "Processing completed" STOP RUN.

Explanation: This example shows SOURCE-COMPUTER with the WITH DEBUGGING MODE option. This enables conditional compilation features that can be used for debugging purposes. The debugging mode allows for additional diagnostic output and conditional compilation of debug statements.

Cross-Platform Development Example

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
* Cross-platform development with different source and object computers IDENTIFICATION DIVISION. PROGRAM-ID. CROSS-PLATFORM-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. * Program developed on IBM mainframe SOURCE-COMPUTER. IBM-3090. * Program will run on different platforms OBJECT-COMPUTER. IBM-3090. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-PLATFORM-INFO. 05 WS-SOURCE-PLATFORM PIC X(20) VALUE "IBM-3090". 05 WS-OBJECT-PLATFORM PIC X(20) VALUE "IBM-3090". 05 WS-COMPATIBILITY PIC X(1) VALUE 'Y'. 01 WS-SYSTEM-CHECK. 05 WS-MEMORY-SIZE PIC 9(8). 05 WS-STORAGE-TYPE PIC X(10). 05 WS-COMPILER-VERSION PIC X(15). PROCEDURE DIVISION. MAIN-LOGIC. * Display platform information DISPLAY "Cross-Platform Development Information:" DISPLAY "Source Computer: " WS-SOURCE-PLATFORM DISPLAY "Object Computer: " WS-OBJECT-PLATFORM DISPLAY "Compatibility: " WS-COMPATIBILITY * Perform platform-specific checks PERFORM CHECK-PLATFORM-COMPATIBILITY DISPLAY "Platform check completed" STOP RUN. CHECK-PLATFORM-COMPATIBILITY. * Check if source and object platforms are compatible IF WS-SOURCE-PLATFORM = WS-OBJECT-PLATFORM MOVE 'Y' TO WS-COMPATIBILITY DISPLAY "Platforms are compatible" ELSE MOVE 'N' TO WS-COMPATIBILITY DISPLAY "Platform compatibility check required" END-IF.

Explanation: This example demonstrates how SOURCE-COMPUTER can be used in cross-platform development scenarios. The program was developed on an IBM-3090 but includes logic to check platform compatibility. This is useful when programs need to be developed on one platform but deployed on another, requiring careful consideration of platform-specific features and limitations.

Legacy System Migration Example

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
* Legacy system migration with source computer documentation IDENTIFICATION DIVISION. PROGRAM-ID. LEGACY-MIGRATION-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. * Original development platform (legacy system) SOURCE-COMPUTER. IBM-360. * Current execution platform (modern system) OBJECT-COMPUTER. IBM-3090. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-MIGRATION-INFO. 05 WS-ORIGINAL-SOURCE PIC X(20) VALUE "IBM-360". 05 WS-CURRENT-TARGET PIC X(20) VALUE "IBM-3090". 05 WS-MIGRATION-DATE PIC X(8) VALUE "20231201". 05 WS-MIGRATION-STATUS PIC X(1) VALUE 'C'. * P = Pending, C = Complete, F = Failed 01 WS-COMPATIBILITY-CHECKS. 05 WS-DATA-FORMAT-OK PIC X(1) VALUE 'Y'. 05 WS-MEMORY-SIZE-OK PIC X(1) VALUE 'Y'. 05 WS-STORAGE-ACCESS-OK PIC X(1) VALUE 'Y'. PROCEDURE DIVISION. MAIN-LOGIC. * Display migration information DISPLAY "Legacy System Migration Information:" DISPLAY "Original Source Computer: " WS-ORIGINAL-SOURCE DISPLAY "Current Object Computer: " WS-CURRENT-TARGET DISPLAY "Migration Date: " WS-MIGRATION-DATE DISPLAY "Migration Status: " WS-MIGRATION-STATUS * Perform compatibility checks PERFORM CHECK-MIGRATION-COMPATIBILITY * Display compatibility results DISPLAY "Compatibility Check Results:" DISPLAY "Data Format: " WS-DATA-FORMAT-OK DISPLAY "Memory Size: " WS-MEMORY-SIZE-OK DISPLAY "Storage Access: " WS-STORAGE-ACCESS-OK IF WS-DATA-FORMAT-OK = 'Y' AND WS-MEMORY-SIZE-OK = 'Y' AND WS-STORAGE-ACCESS-OK = 'Y' DISPLAY "Migration compatibility verified" ELSE DISPLAY "Migration compatibility issues detected" END-IF STOP RUN. CHECK-MIGRATION-COMPATIBILITY. * Check data format compatibility * (Simplified checks for demonstration) IF WS-ORIGINAL-SOURCE = "IBM-360" AND WS-CURRENT-TARGET = "IBM-3090" MOVE 'Y' TO WS-DATA-FORMAT-OK MOVE 'Y' TO WS-MEMORY-SIZE-OK MOVE 'Y' TO WS-STORAGE-ACCESS-OK END-IF.

Explanation: This example shows how SOURCE-COMPUTER can be used in legacy system migration scenarios. The program documents that it was originally developed on an IBM-360 but is now running on an IBM-3090. The program includes migration status tracking and compatibility checks to ensure the program works correctly on the new platform while maintaining documentation of its original development environment.

Best Practices and Considerations

Important Considerations

  • SOURCE-COMPUTER is optional and can be omitted if not needed
  • Use consistent computer naming conventions across your organization
  • Consider using WITH DEBUGGING MODE for development environments
  • Update SOURCE-COMPUTER when migrating to new development platforms
  • Document any platform-specific features or limitations

Advantages

  • Provides clear documentation of development environment
  • Helps with program maintenance and portability
  • Supports cross-platform development
  • Enables debugging mode when needed
  • Facilitates legacy system migration

Limitations

  • Optional clause that may be omitted
  • Limited impact on program execution
  • Requires maintenance when platforms change
  • May not be supported in all COBOL implementations
  • Primarily documentation purpose

Best Practices

  • • Use consistent computer naming conventions
  • • Include SOURCE-COMPUTER in cross-platform projects
  • • Update when migrating development environments
  • • Use WITH DEBUGGING MODE for development builds
  • • Document platform-specific considerations

Test Your Knowledge

1. What is the primary purpose of the SOURCE-COMPUTER clause in COBOL?

  • To specify the target computer
  • To specify the computer where the source program was written
  • To specify the computer architecture
  • To specify the computer memory

2. In which COBOL division is the SOURCE-COMPUTER clause typically used?

  • IDENTIFICATION DIVISION
  • ENVIRONMENT DIVISION
  • DATA DIVISION
  • PROCEDURE DIVISION

3. What is the relationship between SOURCE-COMPUTER and OBJECT-COMPUTER?

  • They are the same thing
  • SOURCE-COMPUTER specifies development environment, OBJECT-COMPUTER specifies execution environment
  • SOURCE-COMPUTER is obsolete, OBJECT-COMPUTER is modern
  • They cannot be used together

4. Can SOURCE-COMPUTER be omitted from a COBOL program?

  • No, it is required
  • Yes, it is optional
  • No, it is mandatory
  • Only in some implementations

5. What information does SOURCE-COMPUTER typically specify?

  • Memory size
  • Computer name and model
  • Operating system
  • All of the above