How De-editing works in COBOL-85

De-editing occurs when an elementary item with a PICTURE clause containing editing characters is MOVEd to a similarly defined elementary item, but without the editing characters.

By “similarly defined,” I mean numeric edited to numeric, or alphanumeric edited to alphanumeric. When this is done, the effects of the editing are reversed, and the original value is produced and placed in the receiving field.

So if an edited field has a PICTURE clause of PIC ZZ,ZZ9.99, a value of 2,876.22, and is MOVEd to a field defined as PIC 9(5)V99, it will end up with the value 0287622 (with an assumed decimal point between the 6 and the 2).

De-editing was introduced in the 1985 COBOL Standard. It is not available when using a 1974 Standard (or prior) compiler. In such a case, because edited data items are classified as alphanumeric, they are treated as such, and whatever characters are there are transferred. Needless to say, the results are not very good.

Related: COBOL – 2 things you may not known about Arrays

Even with new programs, de-editing is very rarely done. This is because the PICTURE edit facilities are designed for output data that is being presented to the user on screens or in reports. In most of these cases, there is no intent to reuse the data because the unedited value is readily available in the computer data file or database.

Situations in which de-editing is used occasionally are in terminal and PC screen update programs. Even here, use is normally limited to PICTURE clauses such as PIC -(7).99. This will present numbers without leading zeros and will float in a minus sign if the value is negative. When or if the user modifies the value, the program can convert it back to an arithmetic number with a simple MOVE statement. Obviously, normal editing for NUMERIC is still required in case some other characters have been entered.

Related: COBOL Quiz -Part:1 and Part:2

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.