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!

Acucobol ACCEPT and leading zeros 1

Status
Not open for further replies.

sstrugi

Programmer
Jan 24, 2004
2
YU
Hi Acucobol programmers.
I develop my application by use of Acucobol 4.3.1 compiler for Windows, and I have a problem:
How to make ACCEPT statement to accept leading zeros?

For example, I have this in working storage:
01 DATE-1.
03 DATE-1-DAY PIC 99.
03 DATE-1-MONTH PIC 99.
03 DATE-1-Year PIC 99.

and this in my screen-section.
01 S-DATE1.
03 SD1, entry-field, line 2, col 5, value DATE-1-DAy.
.....

When I enter for example '01' for SD1 (DATE-1-DAY) it shows
me ' 1' ; I'd like it to remain '01' after ACCEPT. How?
 
I am no expert on this, but one way might be to use PIC XX rather than PIC 99. The runtime accept routine might be more hesitant to suppress leading zeros on a PIC XX field.

Just a guess...there's probably a better way.

Tom Morrison
 
Something like the following should do it and avoid the error of a non-numeric value in a numeric field (or SOC7 error on the mainframe).

DATA DIVISION.
WORKING-STORAGE SECTION.
01 PIC-XX-02 PIC XX.
01 PIC-99-02 PIC 99.

PROCEDURE DIVISION.
perform until PIC-XX-02 ='99'
accept PIC-XX-02
if PIC-XX-02 NUMERIC
move PIC-XX-02 to PIC-99-02
else
move 0 to PIC-99-02
end-if
display PIC-99-02
end-perform

display 'End-of-Job'

GOBACK.


Saginaw
helpdesk@simotime.com
 
On second thought why not right-adjust the two digit number for the user as follows...


DATA DIVISION.
WORKING-STORAGE SECTION.
01 PIC-XX-02 PIC XX.
01 PIC-99-02 PIC 99.

PROCEDURE DIVISION.
perform until PIC-XX-02 ='99'
accept PIC-XX-02

* Right adjust the field for the user...
if PIC-XX-02(2:1) = SPACE
move PIC-XX-02(1:1) to PIC-XX-02(2:1)
move '0' to PIC-XX-02(1:1)
end-if
* Test for numeric...
if PIC-XX-02 NUMERIC
move PIC-XX-02 to PIC-99-02
else
move 0 to PIC-99-02
end-if
display PIC-99-02
end-perform

display 'End-of-Job'

GOBACK.



Saginaw
helpdesk@simotime.com
 
Thanks for your answers.

There must be an easier way to do this.
I have a lot of programs to change, and I just can't
belive that Acucorp didn't solve this problem.

By the way, how do you folks handle entering date types
in your programs?
 
Other versions of COBOL, Micro Focus for example, allow you to control the display of the data after the accept with the PICture. It seems to me that AcuCobol should address this issue.
 
Hi saginaw. I looked at your date routines and found one bug. The years 4000 and 8000 (any year divisible by 4000) will not be leap years.
 
webrabbit, you are the first to point out the Y4K compliance issue. Rather than take anoher 2,000 years (give or take a few leap years) to fix the problem we have updated the date routine to be Y4K compliant. Thanks for pointing out this oversite on our part.


Saginaw
helpdesk@simotime.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top