Skip to main content

Problem:

This issue occurs during migration from HPCOBOL to Server Express.  The ACCEPT statement in HPCOBOL includes behavior that is an enhancement or extension of the ANSI standard ACCEPT.  If the data-item being ACCEPTed already has a value, then data entered by the user overwrites the existing value on a character-by-character basis, and if the user presses Enter without entering any data, then the data-item's value is left unchanged.

By contrast, the ANSI behavior is to entirely replace the existing value of the data item with whatever the user enters, and if the user enters nothing, to initialize the data item.

Example code:

000001  WORKING-STORAGE SECTION.

000002  01  WS-ACCEPT        pic X(10) VALUE "WOOGA".

000003  PROCEDURE DIVISION.

000004  DISPLAY "WS-ACCEPT, Press ENTER to TAKE DEFAULT: ",

000005      WS-ACCEPT.

000006  ACCEPT WS-ACCEPT.

000007  DISPLAY "XXX" WS-ACCEPT "XXX".

If the user presses Enter without entering any data, then in HPCOBOL, the output is:

XXXWOOGA     XXX

whereas with Micro Focus, the output is:

XXX          XXX

Is there a way to mimic the HPCOBOL behavior using Micro Focus syntax?

Resolution:

Consider the following program.  These 10 lines are a complete COBOL program and will compile as written:

000001 WORKING-STORAGE SECTION.

000002 01  WS-ACCEPT        PIC X(10) VALUE "WOOGA".

000003 PROCEDURE DIVISION.

000004 DISPLAY "WS-ACCEPT, PRESS ENTER TO TAKE DEFAULT: "

000005   AT 0101.

000006 DISPLAY WS-ACCEPT AT 0141.

000007 ACCEPT WS-ACCEPT AT 0201.

000008 DISPLAY "XXX" AT 0301.

000009 DISPLAY WS-ACCEPT AT 0304.

000010 DISPLAY "XXX" AT 0314.

It shows behavior similar to HPCOBOL, but with the consequence of starting the Micro Focus ADIS system, which clears the screen when first invoked, and operates in full-screen mode, and requires each individual DISPLAY and ACCEPT to have an AT specifying the row and column.  The screen also scrolls one line after the program returns to the shell, so a person running this program will probably have to scroll back one line in the terminal window to see the entire output after the program exits.

But the behavior otherwise matches the HPCOBOL behavior.  This program serves as an example of how ACCEPT code might be re-written during a migration from HPCOBOL to Server Express.

Old KB# 2298