Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program that Declares data to the compiler

Posted By: Toby Evans     Category: Cobol     Views: 1977

Program that Declares data to the compiler.

Code for Program that Declares data to the compiler in Cobol

IDENTIFICATION DIVISION.
PROGRAM-ID. TEST_DATA_DEF.

DATA DIVISION.
WORKING-STORAGE SECTION.
77 ALPHA                    PIC X(10) VALUE "ABCDEFGHIJ".

77 NUM-01                   PIC 9(13)V9(2) VALUE 1234567890123.45.
77 NUM-02                   PIC S9(3)V9(2) VALUE -123.45.
77 NUM-03                   PIC S9(3)V9(2) COMP VALUE -123.45.

01 DESCARTES_BIRTHDAY.
   05 MM                    PIC 9(2) VALUE 3.
   05 FILLER                PIC X VALUE '/'.
   05 DD                    PIC 9(2) VALUE 31.
   05 FILLER                PIC X VALUE '/'.
   05 YYYY                  PIC 9(4) VALUE 1596.

01 DATA_A.
   05 DATA_AA               PIC X(3) VALUE "HOW".
   05 DATA_AB.
      10 DATA_ABA.
         15 DATA_ABAA       PIC X(1) VALUE " ".
         15 DATA_ABAB       PIC X(2) VALUE "DO".
      10 DATA_ABB           PIC X(1) VALUE " ".
      10 DATA_ABC           PIC X(3) VALUE "YOU".
      10 DATA_ABD           PIC X(1) VALUE " ".
   05 DATA_AC               PIC X(3) VALUE "DO?".

01 DATA_B.
   05 DATA_AA               PIC X(4) VALUE "VERY".
   05 DATA_AB               PIC X    VALUE " ".
   05 DATA_AC               PIC X(4) VALUE "WELL".

01 DATA_C.
   05 MM.
      10 DATA_AA.
         15 DATA_AAA        PIC X(5) VALUE "THANK".
   05 DATA_AB               PIC X    VALUE " ".
   05 DATA_AC               PIC X(3) VALUE "YOU".
   05 DATA_CD.
      10 DATA_AA.
         15 DATA_AAAC       PIC X(1) VALUE ".".

01 TAX-DATA.
   05 SOC-SEC-NUM           PIC 9(9) VALUE 987654321.
   05 NAME.
      10 FIRST-NAME         PIC X(10) VALUE "Olivier".
      10 MIDDLE-INITIAL     PIC XX    VALUE "R.".
      10 LAST-NAME          PIC X(15) VALUE "THILL".
   05 FULL-NAME REDEFINES NAME PIC X(27).
   05 REDEF-NAME REDEFINES NAME.
      10 A                  PIC X(5).
      10 B                  PIC X(22).
   05 DATA_AB.
      10 DATA_ABA.
         15 DATA_FOO        PIC X(3) VALUE "FOO".
         15 DATA_BAR        PIC X(3) VALUE "BAR".
   66 NON-STATE-TAX RENAMES LAST-NAME THRU DATA_FOO.

77 FLAG_OK                  PIC X(10).
   88 OK                    VALUE "OK", "GOOD", "001" THRU "009".
   88 KO                    VALUE "KO", "900" THROUGH "999",
                                  "FAILURE", "ERROR".
01 TABLES.
   02 T1 OCCURS 4 PIC X(4).

   02 T2 OCCURS 2.
      05 T2_A          PIC X(4).
      05 T2_B          PIC 9(2).
      05 T2_C OCCURS 3.
         10 T2_CA      PIC X(4).
         10 T2_CB OCCURS 4 PIC X(3).
         10 T2_CC PIC X(3) OCCURS 2.

   02 DAYS PIC X(21) VALUE "MonTueWenThiFriSatSun".
   02 T3 REDEFINES DAYS PIC X(3) OCCURS 7.

PROCEDURE DIVISION.
MAIN.

    DISPLAY ALPHA "."
    DISPLAY ALPHA(3:5) "."  ALPHA(6:) "."
    DISPLAY NUM-01 "."
    DISPLAY NUM-02 "."
    DISPLAY NUM-03 "."
    DISPLAY DESCARTES_BIRTHDAY "."

    DISPLAY DATA_A " " DATA_B " " DATA_C "."
    DISPLAY DATA_AA OF MM OF DATA_C "."
    DISPLAY DATA_AAA OF DATA_AA OF MM OF DATA_C (2:4) "."

    DISPLAY NAME ". "
    DISPLAY FULL-NAME "."
    DISPLAY B OF REDEF-NAME(2:5) "."
    DISPLAY NON-STATE-TAX "."

    MOVE "abcd" TO T1(3)
    DISPLAY T1(3) "."
    DISPLAY T1(3) (2:2) "."
    MOVE "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"
         TO T2(2)
    DISPLAY T2(2) "."
    DISPLAY T2_B(2) "."
    DISPLAY T2_C(2,2) "."
    DISPLAY T2_CC(2,2,1) "."

    STOP RUN
    .
* =================================================================

* The result is:

* ABCDEFGHIJ.
* CDEFG.FGHIJ.
* 123456789012345.
* -12345.
* -12345.
* 03/31/1596.
* HOW DO YOU DO? VERY WELL THANK YOU..
* THANK.
* HANK.
* Olivier   R.THILL          .
* Olivier   R.THILL          .
* r   R.
* THILL          FOO.
* abcd.
* bc.
* abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789            .
* ef.
* DEFGHIJKLMNOPQRSTUVWXY.
* TUV.
  
Share: 


Didn't find what you were looking for? Find more on Program that Declares data to the compiler Or get search suggestion and latest updates.

Toby Evans
Toby Evans author of Program that Declares data to the compiler is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!