Search code examples
cobol

Writing an output on an input line in Cobol


Customer ID Name Order Date

......................................................................................Year Month Day

123456789 Johnny Smith

234567890 Mary Campbell

345678901 Ed Bilewicz

456789012 Tim Rahmen

567890123 Cheryl Graham

678901234 Robert Thomas McGill

So i have a .dat file that i am working on. I was provided with the ID's and the Names only and have managed to format the .out file like this (that didn't appear to be an issue). What i would like to know is how would i go about adding the Day, Month, and Year to this .out file while keeping them on the same lines as the names and ID's. I'm really new to Cobol so theres a lot of terms i don't understand yet. i tried writing variables in my inline-file (eg il-id), assigning the number with a move command then transfer out to a variable in my outline-file (ol-id) then write the outline-file but it didn't appear to work. though it's not out of the realm of possibility that i simply did it wrong. Any help with what im supposed to do would be very appreciated. and again, im new to this so the less complex terms the easier i might be able to understand. thanks so much.


Solution

  • Actually Data definition concept in COBOL look like flat file class associates to serialization or entity class associates to persistent mapping in modern programming language.

    Here is a sample of Data Definition (in DATA DIVISION):

    WORKING-STORAGE SECTION.
    ...
    02 OL-ID.
       05 CUSTOMER-ID    PIC X(10).
       05 CUSTOMER-NAME  PIC X(20).
       05 ORDER-DATE.
          10 YEAR   PIC X(4).
          10 FILLER PIC X(1) VALUE '-'.
          10 MONTH  PIC X(2).
          10 FILLER PIC X(1) VALUE '-'.
          10 DAY    PIC X(2).
    

    Hope this helps.