-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
COBOLExercise includes COBOL codeExercise includes COBOL code
Description
Working with legacy code can be challenging for developers, especially when the code is complex or not well-documented. In such cases, it can be helpful to use Copilot Chat to explain unclear or complex code to other developers or to document it for future reference.
Example scenario
The block of COBOL below connects to a database and inserts a record. The code lacks documentation, which makes it difficult to understand what it does and how it works.
IDENTIFICATION DIVISION.
PROGRAM-ID. INSERT-RECORD.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-STATUS-FLAGS.
05 WS-DB-STATUS PIC X(2).
88 WS-SUCCESS VALUE "00".
05 WS-SQLCODE PIC S9(9) COMP.
05 WS-ERROR-MSG PIC X(50).
LINKAGE SECTION.
01 LS-PARAMETERS.
05 LS-PERSON-RECORD.
10 PERSON-ID PIC 9(6).
10 PERSON-NAME PIC X(50).
10 PERSON-AGE PIC 9(3).
05 LS-RESULT PIC X.
88 SUCCESS VALUE 'T'.
88 FAILED VALUE 'F'.
PROCEDURE DIVISION USING LS-PARAMETERS.
PERFORM INSERT-AND-VALIDATE
GOBACK
.
INSERT-AND-VALIDATE.
EXEC SQL
INSERT INTO persons (id, name, age)
VALUES (:PERSON-ID, :PERSON-NAME, :PERSON-AGE)
END-EXEC
IF SQLCODE = 0
EXEC SQL COMMIT END-EXEC
SET SUCCESS TO TRUE
ELSE
EXEC SQL ROLLBACK END-EXEC
SET FAILED TO TRUE
STRING "DB Error: " SQLCODE
DELIMITED BY SIZE
INTO WS-ERROR-MSG
DISPLAY WS-ERROR-MSG
END-IF
.Example prompt
Document this code
Source: https://docs.github.com/en/copilot/copilot-chat-cookbook/documenting-code/documenting-legacy-code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
COBOLExercise includes COBOL codeExercise includes COBOL code