Using COBOL to Add An Email Address Field to the Customer Information Screen
Using COBOL to Add An Email Address Field to the Customer Information Screen
Enhancement Overview
In this enhancement, a new Email Address field is added to the Customer Information Screen. This feature allows users to store and view customer email addresses directly in the system, improving communication and accessibility.
This enhancement involves modifying the screen layout, updating the COBOL program, and ensuring the database structure supports the new field.
Screen Layout
The updated Customer Information Screen:
---------------------------
Customer ID : 54321
Name : Jane Smith
Address : 456 Oak Street
City : Metropolis
State : NY
Zip Code : 10001
Phone : 555-987-6543
Email : jane.smith@example.com
---------------------------
New Field: Email Address
This added field captures and displays the customer’s email address. This field is editable.COBOL Code Changes
1. Data Division:
Define the new CUSTOMER-EMAIL
field in the WORKING-STORAGE
section.
05 CUSTOMER-ID PIC 9(5).
05 CUSTOMER-NAME PIC A(30).
05 CUSTOMER-ADDRESS PIC A(50).
05 CUSTOMER-CITY PIC A(20).
05 CUSTOMER-STATE PIC A(2).
05 CUSTOMER-ZIP PIC 9(5).
05 CUSTOMER-PHONE PIC X(12).
05 CUSTOMER-EMAIL PIC A(50).
2. Display Logic:
Update the screen to display and accept the new email address field.
DISPLAY "---------------------------".
DISPLAY "Customer ID : " CUSTOMER-ID.
DISPLAY "Name : " CUSTOMER-NAME.
DISPLAY "Address : " CUSTOMER-ADDRESS.
DISPLAY "City : " CUSTOMER-CITY.
DISPLAY "State : " CUSTOMER-STATE.
DISPLAY "Zip Code : " CUSTOMER-ZIP.
DISPLAY "Phone : " CUSTOMER-PHONE.
DISPLAY "Email : " CUSTOMER-EMAIL.
3. Database Interaction:
Ensure the SQL operations include the EMAIL
field.
Retrieving Data:
SELECT
CUSTOMER_ID, :CUSTOMER-ID,
CUSTOMER_NAME, :CUSTOMER-NAME,
CUSTOMER_ADDRESS, :CUSTOMER-ADDRESS,
CUSTOMER_CITY, :CUSTOMER-CITY,
CUSTOMER_STATE, :CUSTOMER-STATE,
CUSTOMER_ZIP, :CUSTOMER-ZIP,
CUSTOMER_PHONE, :CUSTOMER-PHONE,
CUSTOMER_EMAIL :CUSTOMER-EMAIL
FROM
CUSTOMER_TABLE
WHERE
CUSTOMER_ID = :CUSTOMER-ID
END-EXEC.
Updating Data:
UPDATE CUSTOMER_TABLE
SET
CUSTOMER_EMAIL = :CUSTOMER-EMAIL
WHERE
CUSTOMER_ID = :CUSTOMER-ID
END-EXEC.
Image: This Is Engineering from Pixabay
Comments
Post a Comment