# What should I do to add floating dollar signs.



## jonathan731 (Aug 30, 2003)

In the following Cobol program I cant figure out how to put the dollar sign since i cant have Edited Pic clauses in the working storage section since im using that for calculations. How should I go about it?
*Jonathan Garcia, 000-846-100
*This Program is to organize the info in employee.dat

Identification Division. 
Program-id. Simple. 
Date-Compiled.

Environment Division. 
Input-Output Section. 
File-Control.
Select input-file 
assign to "/home1/c/a/acsi203/employee.dat" 
Organization is line sequential.

Select output-file assign to "prog2out.dat" 
Organization is line sequential.

Data Division. 
File Section.

FD Input-file. 
01 Input-rec. 
02 Last-name pic x(10).
02 First-name pic x(10).
02 ssn pic x(9).
02 Dept-Num pic 9.
02 Filler pic x(4). 
02 Salary pic 9(2)V9(2).
02 Filler pic x(1).
02 Marital-Status pic x.
02 Dependents pic x. 
02 Month pic 9(2).
02 Daiy Pic 9(2).
02 year Pic 9999.
02 Filler pic x(20).
02 Age pic x(3).
02 Filler pic x.

FD Output-file.
01 Output-rec.
02 Last-name1 pic x(10).
02 First-name1 pic x(10).
02 ssn1 pic x(9).
02 Dept-Num1 pic 9.
02 Filler pic x(4). 
02 Salary1 pic 9(2)V9(2).
02 Filler pic x(1).
02 Marital-Status1 pic x.
02 Dependents1 pic x.
02 Filler Pic x(2) value spaces. 
02 Month1 pic 9(2).
02 Daiy1 Pic 9(2).
02 year1 Pic 9(4).
02 Filler pic x(20).
02 Age1 pic 9(3). 
02 Filler pic x(58).

Working-Storage Section. 
01 Report-header.
02 Filler pic x(45) value spaces.
02 Filler pic x(42) 
value "University Textile Company - Employee List".
02 Filler pic x(45) value spaces.

01 Report-Headings.
02 Filler Pic x(4) Value "Last".
02 Filler Pic x(11) Value Spaces.
02 Filler Pic x(5) Value "First".
02 Filler Pic x(11) Value Spaces.
02 Filler Pic x(3) Value "SSN".
02 Filler Pic x(15) Value Spaces.
02 Filler Pic x(6) Value "Salary".
02 Filler Pic x(3) Value Spaces.
02 Filler Pic x(7) Value "Marital".
02 Filler Pic x(2) Value Spaces.
02 Filler Pic x(8) Value "Dept Num".
02 Filler Pic x(2) Value Spaces.
02 Filler Pic x(5) Value "Hired".
02 Filler Pic x(9) Value Spaces.
02 Filler Pic x(3) Value "Age".
02 Filler Pic x(3) Value Spaces.
02 Filler Pic x(7) Value "Yrs Svc".
02 Filler Pic x(5) Value Spaces.
02 Filler Pic x(10) Value "Base Bonus".
02 Filler Pic x(2) Value spaces.
02 Filler Pic x(11) Value "Final Bonus".
02 Filler Pic x(1).

01 Empty-Line.
02 Filler Pic x(132) Value Spaces.

01 Info-line. 
02 Last-name-out pic x(10).
02 Filler Pic x(5) Value Spaces.
02 First-name-out pic x(10).
02 Filler pic x(5) Value Spaces.
02 ssn-out  pic x(9).
02 Filler Pic x(5) Value Spaces.
02 Dept-Num-out pic 9.
02 Filler Pic x(5) Value Spaces. 
02 Salary-out pic 9(2).9(2).
02 Filler Pic x(5) Value Spaces.
02 Marital-Status-out pic x.
02 Filler Pic x(7) Value Spaces.
02 Dependents-out pic x.
02 Filler Pic x(6) Value Spaces. 
02 Month-out pic 9(2).
02 Filler Pic x Value "/".
02 Daiy-out Pic 9(2).
02 Filler Pic x Value "/".
02 year-out Pic 9(4).
02 Filler Pic x(6) Value Spaces.
02 Age-out pic 9(2).
02 Filler Pic x(4) Value Spaces.
02 Yrs-svc Pic 9(2).
02 Filler Pic x(11) value Spaces. 
02 Base-Bonus Pic 9(4). 
02 Filler Pic x(11). 
02 Final-Bonus Pic 9(4). 
02 Filler Pic x(1).

01 CURRENT-DATE-FIELDS.
02 CURRENT-DATE-Record.
10 CURRENT-YEAR PIC 9(4).
10 CURRENT-MONTH PIC 9(2).
10 CURRENT-DAY PIC 9(2).

01 Report-footer.
02 Filler pic x(51) value spaces.
02 filler pic x(31) 
value "Number of Records Processed:". 
02 Rec-Cnt pic 99 value zero.
02 Filler pic x(50) value spaces.

01 eof-flag pic x(3) value "no".

Procedure Division.

*This paragraph outlines what needs to be done step by step.

0000-main-logic. 
Perform 1000-init.
Perform 2000-main-loop until eof-flag = "yes".
Perform 3000-finish. 
Stop Run.

*This paragraph opens the input/output files and write the report header and creates the eof.

1000-init. 
Open input input-file output output-file. 
Write output-rec from report-header.
Write Output-rec from Empty-Line.
Write output-rec from Report-Headings. 
Write output-rec from Empty-Line.
Move Function Current-Date to CURRENT-DATE-FIELDS.
Read input-file at end move "yes" to eof-flag.

*This moves all the variables to the ouput variables and begins the writing of records as well as the counter it also does all the calculation to determine final and base bonuses.

2000-main-loop.
Move last-name to last-name-out.
Move first-name to first-name-out.
Move ssn to ssn-out.
Move salary to salary-out.
Move marital-status to marital-status-out.
Move dependents to dependents-out.
Move Month to Month-out.
Move daiy to Daiy-out.
Move year to Year-out
Move age to age-out.
Compute yrs-svc = CURRENT-YEAR - year.
If yrs-svc = 1 then 
Compute Base-Bonus = 50. 
If yrs-svc > 1 then
Compute Base-bonus = 50 * yrs-svc.
If yrs-svc < 1 then
Compute Base-bonus = 25.
If age > 50 then 
Add 63 to Base-bonus.
If Dept-Num = 1 then
Compute Final-Bonus = Base-Bonus - 200.
If Dept-Num = 2 then 
Compute Final-Bonus = base-Bonus - 200.
If Dept-Num = 3 then 
Compute Final-Bonus = base-bonus - 200.
Write output-rec from info-line.
Add 1 to Rec-Cnt.
Read input-file at end move "yes" to eof-flag.

3000-finish.
Write output-rec from Empty-Line.
write output-rec from report-footer. 
close input-file output-file.


----------



## Chicon (Jul 29, 2004)

You may use something like this :


```
[SIZE=2]
* in working-storage section

 01  DOLLAR   PIC x(1)  value "$".

 01  AMOUNT.
    02 AMOUNT_N   PIC 9(5).

 01  AMOUNT_DOLLAR  PIC X(7).

* in procedure division

     MOVE 550 TO AMOUNT_N
     MOVE ALL SPACES TO AMOUNT_DOLLAR
 
     STRING AMOUNT DELIMITED BY SIZE,
            " ",
            DOLLAR DELIMITED BY SIZE
       INTO AMOUNT_DOLLAR
     END-STRING
[/SIZE]
```


----------

