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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pic Clauses - where to write?

Status
Not open for further replies.

allis

Technical User
Oct 16, 2002
11
0
0
US
I need to write a program that takes input from a data file, and then uses pic clauses to edit that data to appear a certain way.

Do I still use the file section to describe the input and output (report) records in data division?

Where do I write the pic clauses that edit the data, and where do I write the move statements?

Basically, I need to know how to take an input file, and then how to write the code to edit that to appear specifically the way the desired report looks. It's just figuring out the right pic clauses to get desired results.

I just need to know where to code this?

Thanks
 
Hi allis,

I hope you wouldn't mind my saying this, but, I think you need to do the following before attempting to solve your problem:

1. You need to understand the fundamentals of computer programming. For example, study how data is described in programming languages (or COBOL).

2. PIC clauses do not make a COBOL program. You must actually study programming using COBOL.

COBOL is a wonderful language to program in; but, you must be willing to study it (as any other programming language).

Dimandja
 
To get you started, you'd put the record description of your inputfile in the file section with the pic clauses

FD INPUTFILE.
01 INPUTRECORD.
02 FIELD1 PIC ...

(Find out how the data is structured)

Then, describe your output file i the file section as a file with one field, long enough to hold everything you want it to hold

FD OUTPUTFILE.
01 OUTPUTRECORD.
02 OUTPUTFIELD PIC X(80).

Then, in the WORKING STORAGE SECTION, you can define your detailline..

01 DETAILLINE.
02 FILLER PIC X(5) value SPACES
02 DFIELD1 PIC ...

Inwhatever format you want it...

Next, in the procedure division, you need to make a loop in which you READ the inputfile, MOVE the fields to the detailline, and then WRITE your outputfile FROM the detailline...

Hope you'll figure out the rest by youself, this is pretty basic, so I'm sure there's many books availabe to get you started... --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
You can put the file description in the file section, yes.
You have to define a print-file in the file section too!!!
You describe in working-storage section a record the same size as the print file record calling it PRINT-DETAIL.


1. open the file.
2. read the record.
3. move the record fields to the output fields.
4. move spaces to print-record.
5. move PRINT-DETAIL to PRINT-RECORD.
6. write PRINT-RECORD after WS-SPACE LINES.

Note WS-SPACE is a variable you set up holding a whole number 1,2 or 3. 1 for single space, 2 for double space and 3 for triple space. That way you can change the spacing scheme by changing one variable.

You still have to write a page and column heading for each page and decide how many lines to write on each page. You have to use a counter for the detail lines and perform a heading routine and zero out the counter when you reach the target value for the number of lines per page. 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