Explore BrainMass

Explore BrainMass

    COBOL program

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Need aCOBOL program from the specs in cobol1.jpg. customer data is attatched. Can pay more if needed. if can't be done need to knoe asap. Thanks

    © BrainMass Inc. brainmass.com March 4, 2021, 5:36 pm ad1c9bdddf
    https://brainmass.com/computer-science/files/cobol-program-customer-data-2104

    Attachments

    Solution Preview

    Hi,

    Here I send you 8 very good examples similar to your question. If you can understand these examples, you can finish your question no problem.

    Best regards!

    Sort Example: USING and GIVING
    ________________________________________
    IDENTIFICATION DIVISION.
    PROGRAM-ID. SORT-1.
    AUTHOR. Your Name

    * An example of the USING and GIVING options of the SORT verb:
    * The unsorted input file is used to create the sorted output
    * file.

    ENVIRONMENT DIVISION.
    INPUT-OUTPUT SECTION.
    FILE-CONTROL.
    SELECT IN-FILE
    ASSIGN TO 'C:PCOBWINEXAMPLEUNSORTED.TXT'
    ORGANIZATION IS LINE SEQUENTIAL.
    SELECT OUT-FILE
    ASSIGN TO 'C:PCOBWINEXAMPLESORTED1.TXT'
    ORGANIZATION IS LINE SEQUENTIAL.
    SELECT SORT-FILE
    ASSIGN TO 'C:PCOBWINEXAMPLEWORK.TMP'.

    DATA DIVISION.
    FILE SECTION.
    FD IN-FILE
    DATA RECORD IS IN-RECORD.
    01 IN-RECORD.
    02 IN-ID PIC 9(5).
    02 IN-LAST-NAME PIC X(15).
    02 IN-FIRST-NAME PIC X(10).
    02 IN-CITY PIC X(12).
    02 IN-STATE PIC X(2).

    FD OUT-FILE
    DATA RECORD IS OUT-RECORD.
    01 OUT-RECORD.
    02 OUT-ID PIC 9(5).
    02 OUT-LAST-NAME PIC X(15).
    02 OUT-FIRST-NAME PIC X(10).
    02 OUT-CITY PIC X(12).
    02 OUT-STATE PIC X(2).

    SD SORT-FILE
    DATA RECORD IS SORT-RECORD.
    01 SORT-RECORD.
    02 SORT-ID PIC 9(5).
    02 SORT-LAST-NAME PIC X(15).
    02 SORT-FIRST-NAME PIC X(10).
    02 SORT-CITY PIC X(12).
    02 SORT-STATE PIC X(2).

    WORKING-STORAGE SECTION.

    PROCEDURE DIVISION.
    MAINLINE.
    SORT SORT-FILE
    ON ASCENDING KEY SORT-LAST-NAME
    USING IN-FILE
    GIVING OUT-FILE.
    STOP RUN.
    Input
    91163Dube Jason Chicago IL
    61535King Adriane Cincinnati OH
    45636Holtz Rachel Newport KY
    10216Gehl Bryan Louisville KY
    52158Flynn Ashley Muskegon MI
    22277Theis Hanah Norwood OH
    38551Solpa Mac Lansing MI
    78496McCoy Amanda Brookfield WI
    65720Read Sean Springfield BF
    94000Waymel Bradley Kalamazoo MI
    42966Vilella Reza Urbana IL
    04928Streeter Farhad Toledo OH
    69216Steele Karen Covington KY
    56913Moreno Jan Dayton OH
    34932Vogel Sandra Grand RapidsMI
    Output (sorted by last name)
    91163Dube Jason Chicago IL
    52158Flynn Ashley Muskegon MI
    10216Gehl Bryan Louisville KY
    45636Holtz Rachel Newport KY
    61535King Adriane Cincinnati OH
    78496McCoy Amanda Brookfield WI
    56913Moreno Jan Dayton OH
    65720Read Sean Springfield BF
    38551Solpa Mac Lansing MI
    69216Steele Karen Covington KY
    04928Streeter Farhad Toledo OH
    22277Theis Hanah Norwood OH
    42966Vilella Reza Urbana IL
    34932Vogel Sandra Grand RapidsMI
    94000Waymel Bradley Kalamazoo MI

    Sort Example: Multiple Sort Keys
    ________________________________________
    IDENTIFICATION DIVISION.
    PROGRAM-ID. SORT-1A.
    AUTHOR. Your Name

    * Sorting on 2 keys

    ENVIRONMENT DIVISION.
    INPUT-OUTPUT SECTION.
    FILE-CONTROL.
    SELECT IN-FILE
    ASSIGN TO 'C:PCOBWINEXAMPLEUNSORTED.TXT'
    ORGANIZATION IS LINE SEQUENTIAL.
    SELECT OUT-FILE
    ASSIGN TO 'C:PCOBWINEXAMPLESORTED1A.TXT'
    ORGANIZATION IS LINE SEQUENTIAL.
    SELECT SORT-FILE
    ASSIGN TO 'C:PCOBWINEXAMPLEWORK.TMP'.

    DATA DIVISION.
    FILE SECTION.
    FD IN-FILE
    DATA RECORD IS IN-RECORD.
    01 IN-RECORD.
    02 IN-ID PIC 9(5).
    02 IN-LAST-NAME PIC X(15).
    02 IN-FIRST-NAME PIC X(10).
    02 IN-CITY PIC X(12).
    02 IN-STATE PIC X(2).

    FD OUT-FILE
    DATA RECORD IS OUT-RECORD.
    01 OUT-RECORD.
    02 OUT-ID PIC 9(5).
    02 OUT-LAST-NAME PIC X(15).
    02 OUT-FIRST-NAME PIC X(10).
    02 OUT-CITY PIC X(12).
    02 OUT-STATE PIC X(2).

    SD SORT-FILE
    DATA RECORD IS SORT-RECORD.
    01 SORT-RECORD.
    02 SORT-ID PIC 9(5).
    02 SORT-LAST-NAME PIC X(15).
    02 SORT-FIRST-NAME PIC X(10).
    02 SORT-CITY PIC X(12).
    02 SORT-STATE PIC X(2).

    WORKING-STORAGE SECTION.

    PROCEDURE DIVISION.
    MAINLINE.
    SORT SORT-FILE
    ON ASCENDING KEY SORT-STATE
    ON ASCENDING KEY SORT-LAST-NAME
    USING IN-FILE
    GIVING OUT-FILE.
    STOP RUN.
    Input
    91163Dube Jason Chicago IL
    61535King Adriane Cincinnati OH
    45636Holtz Rachel Newport KY
    10216Gehl Bryan Louisville KY
    52158Flynn Ashley Muskegon MI
    22277Theis Hanah Norwood OH
    38551Solpa Mac Lansing MI
    78496McCoy Amanda Brookfield WI
    65720Read Sean Springfield BF
    94000Waymel Bradley Kalamazoo MI
    42966Vilella Reza Urbana IL
    04928Streeter Farhad Toledo OH
    69216Steele Karen Covington KY
    56913Moreno Jan Dayton OH
    34932Vogel Sandra Grand RapidsMI
    Output (sorted by state then by name)
    65720Read Sean Springfield BF
    91163Dube Jason Chicago IL
    42966Vilella Reza Urbana IL
    10216Gehl Bryan Louisville KY
    45636Holtz Rachel Newport KY
    69216Steele Karen Covington KY
    52158Flynn Ashley Muskegon MI
    38551Solpa Mac Lansing MI
    34932Vogel Sandra Grand RapidsMI
    94000Waymel Bradley Kalamazoo MI
    61535King Adriane Cincinnati OH
    56913Moreno Jan Dayton OH
    04928Streeter Farhad Toledo OH
    22277Theis Hanah Norwood OH
    78496McCoy Amanda Brookfield WI

    Sort Example: INPUT PROCEDURE
    ________________________________________
    IDENTIFICATION DIVISION.
    PROGRAM-ID. SORT-2.
    AUTHOR. BILL ROGERS.

    * In this example we use the INPUT PROCEDURE option instead of
    * USING because we want to verify that the state code in the
    * input record is valid.

    ENVIRONMENT DIVISION.
    INPUT-OUTPUT SECTION.
    FILE-CONTROL.
    SELECT IN-FILE
    ASSIGN TO 'C:PCOBWINROGERSUNSORTED.TXT'
    ORGANIZATION IS LINE SEQUENTIAL.
    SELECT OUT-FILE
    ASSIGN TO 'C:PCOBWINROGERSSORTED2.TXT'
    ORGANIZATION IS LINE SEQUENTIAL.
    SELECT SORT-FILE
    ASSIGN TO 'C:PCOBWINROGERSWORK.TMP'.

    DATA DIVISION.
    FILE SECTION.
    FD IN-FILE
    DATA RECORD IS IN-RECORD.
    01 IN-RECORD.
    02 IN-ID PIC 9(5).
    02 IN-LAST-NAME PIC X(15).
    02 IN-FIRST-NAME PIC X(10).
    02 IN-CITY PIC X(12).
    02 IN-STATE PIC X(2).
    88 VALID-STATE-CODE VALUES 'AK'
    'AL' 'AR' 'AZ' 'CA' 'CO' 'CT' 'DC' 'DE' 'FL' 'GA'
    'HI' 'IA' 'ID' 'IL' 'IN' 'KS' 'KY' 'LA' 'MA' 'MD'
    'ME' 'MI' 'MN' 'MO' 'MS' 'MT' 'NC' 'ND' 'NE' 'NH'
    'NJ' 'NM' 'NV' 'NY' 'OH' 'OK' 'OR' 'PA' 'RI' 'SC'
    'SD' 'TN' 'TX' 'UT' 'VA' 'VT' 'WA' 'WI' 'WV' 'WY'.

    FD OUT-FILE
    DATA RECORD IS OUT-RECORD.
    01 OUT-RECORD.
    02 OUT-ID PIC 9(5).
    02 OUT-LAST-NAME PIC X(15).
    02 OUT-FIRST-NAME PIC X(10).
    02 OUT-CITY PIC X(12).
    02 OUT-STATE PIC X(2).

    SD SORT-FILE
    DATA RECORD IS SORT-RECORD.
    01 SORT-RECORD.
    02 SORT-ID PIC 9(5).
    02 SORT-LAST-NAME PIC X(15).
    02 SORT-FIRST-NAME PIC X(10).
    02 SORT-CITY PIC X(12).
    02 SORT-STATE PIC X(2).

    WORKING-STORAGE SECTION.

    01 EOF-SWITCH PIC X VALUE 'N'.
    88 NO-MORE-INPUT-RECORDS VALUE 'Y'.

    PROCEDURE DIVISION.
    MAIN-LOGIC.
    SORT SORT-FILE
    ON ASCENDING KEY SORT-LAST-NAME
    INPUT PROCEDURE IS INPUT-LOGIC
    GIVING OUT-FILE.
    STOP RUN.

    INPUT-LOGIC.
    OPEN INPUT IN-FILE.
    READ IN-FILE
    AT END ...

    Solution Summary

    COBOL program help is provided.

    $2.49

    ADVERTISEMENT