# COBOL ASSIGNMENT HELP!

Greetings!

First, I would like to add...it would be nice for this site to have a 'COBOL' section. Since, it doesn't I really didn't know where to ask my question.

Problem, I just started this COBOL class last week and I have no previous experience in programming what so ever. My instructor has given us our first assignment to write a COBOL program that prepares a credit report. Here are the instructors details:

INSTRUCTIONS
A credit report is to be prepared. Write the COBOL program to prepare this report. Use data set 2248DATA.TXT.

INPUT
Input consists of Credit Records that contain the account number, customer name, balance, and purchases. The format of the Credit Record is illustrated below.

Credit Record
Field Name      Position      Length      Dec      Attribute
UNUSED                      1 - 6        6                      Alphanumeric
Account Number      7 - 12      6      0      Numeric
Customer Name      13 - 32      20             Alphanumeric
UNUSED                      33 - 53      21             Alphanumeric
Balance                      54 - 59      6      2      Numeric
Purchases                      60 - 65      6      2      Numeric
UNUSED                      66 - 67      2             Alphanumeric
Record Length:  67

OUTPUT
Output consists of a Credit Report listing the account number, customer name, balance, purchases, credit limit, and available credit. To calculate available credit, add balance and purchases and subtract the result from the credit limit. The credit limit for all customers is \$1500.00. Account number, balance, purchases and credit limit are to be zero suppressed. Available credit is to be printed using a floating dollar sign. The printer spacing chart for the report is available in SpCharts.xls.

Intructor's tips:

Programming Tips for Program 2

This file is intended to provide you with some additional help in solving problems associated with program 2.  You should be able to use program 1 as a guide for the straightforward movement of data from the input record to the output record, but there are a couple of new concepts to mention.

First, this program has two input fields that must be used in a calculation; therefore, they must be defined as numeric fields.  Second, these fields have decimal positions.  If you examine the input file that we use, you will find that decimals are not stored.  We read this data in using an implied decimal, designated with the letter V.  Lastly, you are told that the length of these fields is 6 with 2 decimal places.  This means the field itself is 6 in length, with 2 of those 6 positions on the right side of the decimal.  The pictures of these two fields should appear as follows (you can give the fields any name you choose, not necessary to name them what I name them):

05      IN-BALANCE      PIC 9999V99.
05      IN-PURCHASES      PIC 9999V99.

You also have a requirement in this program to do a calculation for each record and include the results in your detail line.

a.  Declare the following items in WORKING-STORAGE:

01      WS-LIMIT            PIC 9999V99 VALUE 1500.00.
01      WS-AVAILABLE      PIC 9999V99.

b.  The program instructions tell you that available credit is calculated by adding BALANCE and PURCHASES and subtracting from the credit limit.  The line of code to accomplish this can be done in several ways.  One example is as follows:

COMPUTE WS-AVAILABLE = WS-LIMIT – (IN-BALANCE + IN-PURCHASES)

Remember, this calculation is done for each detail line, and WS-AVAILABLE represents the last field that is to be displayed on each detail line.  Once again, remember that in order to use a variable in an arithmetic expression, it cannot be numeric edited.  That means no dollar signs, periods, commas, etc. - only 9 or V (an S also if you need to identify that the number could be negative, but you won’t need to do that for this program).

This is what I got so far....I am completely lost on the 'procedure division'. I can't find any examples that will help me understand how to complete this last part. This is my source code:

IDENTIFICATION DIVISION.
PROGRAM-ID.  PROGRAM2.
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CREDITRECORD-FILE
ASSIGN TO "2248DATA.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT REPORT-FILE
ASSIGN TO "CRPROG2.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
*
DATA DIVISION.
FILE SECTION.
FD  CREDITRECORD-FILE
RECORD CONTAINS 67 CHARACTERS
LABEL RECORDS ARE OMITTED
DATA RECORD IS CREDITRECORD-RECORD.
01  CREDITRECORD-RECORD.
05  FILLER                       PIC     X(6).
05  ACCOUNT-NUMBER      PIC     9(6).
05  CUSTOMER-NAME       PIC     X(20).
05  FILLER                        PIC     XX.
05  IN-BALANCE                PIC     9999V99.
05  IN-PURCHASES            PIC     9999V99.
05  FILLER                        PIC     XX.
FD  REPORT-FILE
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS REPORT-RECORD.
01  REPORT-RECORD.
WORKING-STORAGE SECTION.
01  WS-LIMIT                   PIC     9999V99 VALUE 1500.00.
01  WS-AVAILABLE            PIC     9999V99.
05  FILLER                    PIC     X       VALUE "\$".
*
PROCEDURE DIVISION.
*
MAIN-ROUTINE.
OPEN INPUT CREDITRECORD-FILE
OUTPUT REPORT-FILE
AT END MOVE "

Thanks

BTW, is there a way to upload files on here?

###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
>>BTW, is there a way to upload files on here?
Unfortunately no.

http://www.experts-exchange.com/help.jsp#hi56
http://www.experts-exchange.com/help.jsp#hi105

It has been too long since I did any COBOL but the basic idea will be

Loop
Calculate the value
Write a record
Until out of data

mlmcc

0
Commented:
It looks like your assignment was a few weeks ago, and this might be a bit late.

You should look into structured programming..

eg.   1000-Main
open files.
perform 2000-processing until EOF.
perform 8000-output.
close files
1000-exit.
2000-processing

process logic goe here for each rec
perform 8000-ouptut

2000-exit. exit.
8000-output.
print format of line
check for lines on page and redo headers if needed.
8000-exit.
8100-exit.
9000-exit.

Keep functions simple.   8000 range for common output
9000 range for common inputs
arranging numerically helps you look for it in the right sequence.
Use EJECT to have paragraphs start on new pages when you print out listings..
It has been about 10 years since I touched this stuff.
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Mainframe Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.