#COBOL #Topictrick #Db2 #CICS
COBOL Data types are an important part of COBOL programming. Data Types in COBOL are of three types COBOL numeric data types, COBOL alphanumeric data types, and COBOL alphabetic data types. Also, the numeric edited data type in COBOL and alphanumeric Edit in COBOL use for formatting data. Let's get started.
► Index Details ◄
0:00 Welcome to COBOL Data types.
0:45 Introduction to data types in COBOL.
2:16 COBOL Variable, COBOL Literal, COBOL Constant.
3:24 COBOL Data name or Varaibles.
4:10 COBOL Coding rules.
5:12 COBOL Level Numbers.
6:11 COBOL Picture Clause.
7:09 COBOL Value Clause.
10:34 COBOL Edited Picture Clause.
13:14 COBOL Program Examples.
15:44 Mainframe Tutorial Ends.
What is a Data Type?
In laymen term, a data type is an attribute of data which tell the compiler or interpreter how the programmer intends to use the data. In COBOL, there are only three types of data types: Numeric, Alphanumeric (text/string), and Alphabetic. Edited Numeric and Edited Alphanumeric are two subcategories of data types used for reporting.
#COBOL Variable.
A variable is a data item; its value can change during a program. The values are restricted, however, to the data type that you define when you give the variable a name and a length.
Example: 01 Customer-Name Pic X(20).
#COBOL Literals.
A literal is a character string whose value is given by the characters themselves.
Example: MOVE “MURPHY” TO Customer-Name
#COBOL Constants.
A constant is a data item that has only one value. COBOL does not define a construct specifically for constants.
Example: 01 Interest PIC 9(02) VALUE 10.
#COBOL Data-Name or Variable.
Data names or variables are user-defined words. These are memory locations that are defined in the Data Division and Procedure Division.
To define a data-name you need Level Number, PICTURE Clause and VALUE Clause.
#COBOL Edited Picture Clause:
Edited picture clauses are special picture clause that format data in the desired format (i.e. for screen or a printer or report.
There are two general methods of editing in a PICTURE clause:
Edit Symbol Editing Type
-------------- -----------------------------------
, B 0 / Simple insertion
. Special insertion
+ - CR DB $ Fixed insertion
+ - $ Floating insertion
Z * Suppression and replacement
Insertion: Where you include special symbol such as currency symbol ($, €, *, CR, DR etc).
Suppression and Replacement: Where you are required to either replace or suppress certain value on reports.
Sample COBOL Program:
IDENTIFICATION DIVISION.
PROGRAM-ID. PGMDSP01.
AUTHOR. Topictrick.
INSTALLATION. Topictrick.
DATE-WRITTEN. 06/17/2020.
DATE-COMPILED. 06/17/2020.
*
* PROJ DESC: SAMPLE COBOL PROGRAM TO DISPLAY DATA
* : USING VARIOUS EDIT PICTURE CLAUSE.
*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
DATA DIVISION.
*
FILE SECTION.
*
WORKING-STORAGE SECTION.
*
01 WS-EMP-NAME.
05 WS-FNAME PIC X(15) VALUE SPACE.
05 FILLER PIC X(01) VALUE SPACE.
05 WS-LNAME PIC X(20) VALUE SPACE.
01 WS-EDIT-PIC.
05 WS-SAL-AMT PIC ZZZ,ZZZ.
05 WS-CHK-AMT PIC $***,***.
05 WS-DTE-FMT PIC 99/99/9999.
05 WS-RTE-DEC PIC 999.999.
05 WS-PLS-SIG PIC +999.999.
05 WS-INS-BLK PIC X(05)BBX(05).
*
PROCEDURE DIVISION.
*
000-MAIN-LOGIC.
PERFORM 005-PRT-EMP-DATA
STOP RUN.
*
*
005-PRT-EMP-DATA SECTION.
010-MOVE-DATA.
MOVE 'ROGGER' TO WS-FNAME.
010-EXIT.
EXIT.
020-EXIT.
EXIT.
►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. ◄
Also, Please visit below mention the link to stay connected with Topictrick on -
► Official Website : [ Ссылка ]
► Youtube : topictrick
► Follow us on Twitter : [ Ссылка ]
► Facebook : [ Ссылка ]
► Linkedin : [ Ссылка ]
► Reddit : [ Ссылка ]
► Mainframe Blog : [ Ссылка ]
► Medium Blog : [ Ссылка ]
Thank you for your support.
Topictrick™
![](https://i.ytimg.com/vi/5vHC0W0bL8g/maxresdefault.jpg)