Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WORK-AREA

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hELLO, CAN SOMEONE please LOOK AT THIS PROGRAM AND EXPLAIN THE WORK-AREA to me, why is the month, day and yeaar there twice? thanks!



IDENTIFICATION DIVISION.
************************

PROGRAM-ID. CH3EX-2.
AUTHOR.
INSTALLATION.
DATE-WRITTEN. NOV. 28, 2001.
DATE-COMPILED.
******************************************************************
* PROGRAM NARRATIVE *
* *
* *
* THIS PROGRAM READS ALL RECORDS IN THE CUSTOMER FILE FOR THE *
* ABC DEPARTMENT STORE AND DISPLAYS A DETAIL LINE CONTAINING *
* AN ACCOUNT NUMBER, CUSTOMER NAME, BALANCE, PURCHASES, AND *
* CREDIT LIMIT. A RECORD COUNT IS PROVIDED AT THE END OF THE *
* REPORT. *
* *
* INPUT: CUSTOMER.DAT - CUSTOMER INPUT FILE *
* *
* OUTPUT: SCREEN - CUSTOMER PURCHASES REPORT *
* *
******************************************************************

ENVIRONMENT DIVISION.
**********************

INPUT-OUTPUT SECTION.
**********************

FILE-CONTROL.

SELECT CUSTOMER-FILE
ASSIGN TO "A:\CUSTOMER.DAT".

/
DATA DIVISION.
***************

FILE SECTION.
**************

******************************************************************
* *
* INPUT-FILE - CUSTOMER FILE *
* *
******************************************************************

FD CUSTOMER-FILE.

01 CUSTOMER-RECORD.
02 PIC X(8).
02 CR-ACCOUNT-NUMBER PIC X(6).
02 CR-CUSTOMER-NAME PIC X(20).
02 PIC X(21).
02 CR-BALANCE PIC S9(4)V99.
02 CR-PURCHASES PIC 9(4)V99.
02 CR-CREDIT-LIMIT PIC 9(5).
02 PIC XX.
/
WORKING-STORAGE SECTION.
************************

******************************************************************
* *
* Switches *
* *
******************************************************************

01 SWITCHES.

02 SW-END-OF-FILE PIC X.
88 END-OF-FILE VALUE "Y".

******************************************************************
* *
* Accumulators *
* *
******************************************************************

01 ACCUMULATORS.

02 AC-LINE-COUNT PIC 999.
02 AC-PAGE-COUNT PIC 999.
02 AC-RECORD-COUNT PIC 9(5).
/
******************************************************************
* *
* Work Area Fields *
* *
******************************************************************

01 WORK-AREA.

02 WA-TODAYS-DATE-TIME.
03 WA-TODAYS-DATE.
04 WA-TODAYS-YEAR PIC 9(4).
04 WA-TODAYS-MONTH PIC 99.
04 WA-TODAYS-DAY PIC 99.
03 WA-TODAYS-TIME.
04 WA-TODAYS-HOUR PIC 99.
04 WA-TODAYS-MINUTES PIC 99.
03 PIC X(9).

02 WA-DATE.
03 WA-MONTH PIC 99.
03 WA-DAY PIC 99.
03 WA-YEAR PIC 9(4).

02 WA-RUN-DATE REDEFINES
WA-DATE PIC 9(8).

02 WA-SCREEN-HOLD PIC X.
02 WA-HYPHENS PIC X(20) VALUE ALL "-". /
/
SCREEN SECTION.
***************

******************************************************************
* *
* Report Headings for the Customer Purchases Report *
* *
******************************************************************

01 HEADING-LINES.
02 BLANK SCREEN.
02 LINE 1 COLUMN 1 VALUE "DATE".
02 COLUMN 6 PIC Z9/99/9999 FROM WA-RUN-DATE.
02 COLUMN 22 VALUE "ABC DEPARTMENT STORE".
02 COLUMN 57 VALUE "PAGE ".
02 COLUMN 62 PIC ZZ9 FROM AC-PAGE-COUNT.
02 LINE 2 COLUMN 20 VALUE "CUSTOMER PURCHASES REPORT".
02 LINE 4 COLUMN 1 VALUE "ACCOUNT".
02 COLUMN 57 VALUE "CREDIT".
02 LINE 5 COLUMN 1 VALUE "NUMBER".
02 COLUMN 9 VALUE "CUSTOMER NAME".
02 COLUMN 31 VALUE "BALANCE".
02 COLUMN 44 VALUE "PURCHASES".
02 COLUMN 57 VALUE "LIMIT".
02 LINE 6 COLUMN 1 PIC X(7) FROM WA-HYPHENS.
02 COLUMN 9 PIC X(20) FROM WA-HYPHENS.
02 COLUMN 31 PIC X(11) FROM WA-HYPHENS.
02 COLUMN 44 PIC X(9) FROM WA-HYPHENS.
02 COLUMN 57 PIC X(8) FROM WA-HYPHENS.
/
******************************************************************
* *
* Detail Line for the Customer Purchases Report *
* *
******************************************************************

01 DETAIL-LINE.

02 LINE AC-LINE-COUNT.
02 COLUMN 1 PIC X(6) FROM CR-ACCOUNT-NUMBER.
02 COLUMN 9 PIC X(20) FROM CR-CUSTOMER-NAME.
02 COLUMN 31 PIC $$,$$$.99CR FROM CR-BALANCE.
02 COLUMN 44 PIC $$,$$$.99 FROM CR-PURCHASES.
02 COLUMN 56 PIC ZZ,ZZ9.99 FROM CR-CREDIT-LIMIT.
/
******************************************************************
* *
* Summary Lines for the Customer Purchases Report *
* *
******************************************************************

01 SUMMARY-LINES.

02 SL-LINE-1.
03 LINE AC-LINE-COUNT.
03 COLUMN 11 VALUE
"TOTAL NUMBER OF RECORDS DISPLAYED = ".
03 COLUMN 47 PIC ZZZZ9 FROM AC-RECORD-COUNT.

02 SL-LINE-2.
03 LINE AC-LINE-COUNT.
03 COLUMN 24 VALUE "END OF REPORT".
/
PROCEDURE DIVISION.
*******************
******************************************************************
* *
* MAIN-PROGRAM - THIS IS THE MAIN PARAGRAPH OF THIS PROGRAM *
* *
******************************************************************

MAIN-PROGRAM.

PERFORM A-100-INITIALIZATION.
PERFORM B-100-PROCESS-FILE.
PERFORM C-100-WRAP-UP.
STOP RUN.

******************************************************************
* *
* THE INITIALIZATION PARAGRAPH FOLLOWS *
* *
******************************************************************

A-100-INITIALIZATION.

MOVE ZERO TO AC-PAGE-COUNT
AC-LINE-COUNT
AC-RECORD-COUNT.

MOVE FUNCTION CURRENT-DATE TO WA-TODAYS-DATE-TIME.
MOVE WA-TODAYS-MONTH TO WA-MONTH.
MOVE WA-TODAYS-DAY TO WA-DAY.
MOVE WA-TODAYS-YEAR TO WA-YEAR.

OPEN INPUT CUSTOMER-FILE.
/
******************************************************************
* *
* FILE PROCESSING CONTROL PARAGRAPH *
* *
******************************************************************

B-100-PROCESS-FILE.

MOVE "N" TO SW-END-OF-FILE.
READ CUSTOMER-FILE
AT END MOVE "Y" TO SW-END-OF-FILE.

PERFORM B-200-PROCESS-RECORD
UNTIL END-OF-FILE.
ADD 1 TO AC-LINE-COUNT.
DISPLAY SL-LINE-1.
ADD 1 TO AC-LINE-COUNT.
DISPLAY SL-LINE-2.
/
******************************************************************
* *
* DISPLAY HEADINGS AND DETAIL LINES *
* *
******************************************************************

B-200-PROCESS-RECORD.

IF AC-LINE-COUNT = 0
ADD 1 TO AC-PAGE-COUNT
DISPLAY HEADING-LINES
MOVE 7 TO AC-LINE-COUNT.

DISPLAY DETAIL-LINE.
ADD 1 TO AC-LINE-COUNT.
ADD 1 TO AC-RECORD-COUNT.

IF AC-LINE-COUNT > 20
DISPLAY " "
DISPLAY "PLEASE PRESS THE ENTER KEY TO CONTINUE"
ACCEPT WA-SCREEN-HOLD
MOVE ZERO TO AC-LINE-COUNT.

READ CUSTOMER-FILE
AT END MOVE "Y" TO SW-END-OF-FILE.
/
******************************************************************
* *
* END OF JOB PARAGRAPH *
* *
******************************************************************

C-100-WRAP-UP.

DISPLAY " ".
DISPLAY " ".
DISPLAY "PLEASE PRESS THE ENTER KEY TO CONTINUE".
ACCEPT WA-SCREEN-HOLD.
CLOSE CUSTOMER-FILE.
DISPLAY " ".
DISPLAY "CUSTOMER PURCHASES REPORT PROGRAM HAS TERMINATED".
DISPLAY " ".
/
 
Hi UC,

By moving the date from one field to the other, he changes the format from YYYYMMDD to MMDDYYYY.

Jack
 
Thanks slade,
I am a freshamn in college studyiing to be a programmer like you. My project is to analyze and explain the Daata Division of this program, is there any advice you can give me or is there a site where i can get more info on the data division so i can do a GREAT job. Again thanks for your reply!
 
Hi UC,

I don't know what compiler you're using for your class, but at the level you're now studying, the concepts are the same for all.

You could try the manuals tab at and click the COBOL line. From there, go to bottom of page and select the Reference Manual closest to the bottom. Find the index and look for DDiv items.

Good luck, Jack.

P.S. Don't ask ques there; they're pretty rough w/newbies.
 
Hi Slade,

The MVSHELP boys are not that rough. They expect newbies to look things up before they ask questions which they could have answered themselves by finding them on the site or looking it up an a manual.

I would prefer this professional attitude on this site also. Than we can have some real discussions, not repeating manual-talk.

Real discussions can be about:
- generating sources
- automated restructure sources
- using overlapping moves
- implementing recursive solutions in COBOL
- object orientation in COBOL
- all kinds of algorithms implemented in COBOL

etc. etc.

I even think that the moderator wants this site to be professional.

And now to anybody: hit me! :)

Regards,

Crox



 
Hi Crox,

I beg to differ, although I agree that preperation before posting is desireable. I think some at the site are rude in the way they react to the sins of the new posters, who may not be aware of the protocols. To some of the new posters all of this my be unfamiliar; a little "noblesse oblige" is not too much to ask.

Someone there suggested that these "rules" or prerequisites should be displayed in a panel to begin the "new post" process. Good idea. Then those that ignore the suggestions s/b "flamed", however, until that time, the "flamers" can ignore such a post rather than be rude.

Pow, Blam, Bang, Crunch! :)

Regards, Jack.
 
There are people who are looking for some direction, something that perhaps was not explained clearly in class. Or junior programmers looking for a nudge.

There are other people who want someone to do their homework, either because they figure professionals will do a GREAT job (that's a quote), or because they have let the course slip all semester and don't know where to begin.

You KNOW I go out of my way to help the first sort. The second sort deserve to be flamed. A thread was just deleted here because I red-flagged it ... the exact same question had been asked in comp.lang.cobol by the same person.

Stephen J Spiro



 
WOW! Thanks guys, now I am rally afraid to ask a question here or anywhere else. Slade, however, I have been reading my book and other books, professor seem to have the notion that since you want to become a programmer you already know the language and just give you the programs without lecturing on it. I am not complaining well I don't mean to complain because I am going to do my work, I have a strong desire to become a programmer and I will be helping others like myself real soon I hope. Again, thanks for all your help and advice. Peace... Since I don't want to be FLAMED, I'll just keep my questions.
 
Hi ucmeme,

No guts, no glory. Put on your asbestos suit and fire away (no pun intended). :)

Regards, Jack.
 
Ask questions, you will either get answers or you won't. And when the course is over, file a complaint against the Professor with the Dean of the Faculty.
 
LOL, Good Answer Stephen, "When The Course Is Over" because they go for BLOOD i mean it's hard really hard an if you complain you might as well pack your back and move on! However, I am doing ok, just haveing a few problems trying to explain this entire DATA DIVISION when I did not write the program and really have not been told anything about the DATA DIVISION except to read and be prepared to discuss it in class. So here I am trying to find help any way I can.

Thanks to everyone that answered mypost!
 
Just look at this:.

MOVE FUNCTION CURRENT-DATE TO WA-TODAYS-DATE-TIME.
MOVE WA-TODAYS-MONTH TO WA-MONTH.
MOVE WA-TODAYS-DAY TO WA-DAY.
MOVE WA-TODAYS-YEAR TO WA-YEAR.

The function accepts the date/time from the System.
The system date is in a set format.
The other fields are used to format the date in a
way it can be represented when printed.
Example 20020225 is 02252002.
You can move this to an edited field like:
XXBXXBXXXX and then add the / / to make it a normal
date. A lot depends on the ability of your compiler.



If you do not like my post feel free to point out your opinion or my errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top