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

Difficult recognizable tricks in COBOL 11

Status
Not open for further replies.

Crox

Programmer
Apr 3, 2000
893
NL
I am looking for tricks in COBOL. I need examples of code that is doing something else then you think at first sight.

Thanks in advance!

Regards,

Crox
 
COBOL is not very fancy it is plain and technical. It is simplicity of design, and fast as hell.

If you do not like my post feel free to point out your opinion or my errors.
 
Hi
A simple trick in 2000YK was like,
"that is doing something else then you think at first sight".
Code:
000000 01  in-year   pic 9(2).

000000     subtract 1 from in-year.

source was fixed to:

000000**   subtract 1 from in-year.
000000     add      99 to  in-year.
Baruch

 
Nice Baruch,

I tried this with several COBOL compilers with this program:

Code:
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. 99-Y2K.
000300 ENVIRONMENT DIVISION.
000400 CONFIGURATION SECTION.
000500 SOURCE-COMPUTER. CROX.
000600*                                     **********************
000700*                                     * CROX COPYRIGHT (C).*
000800*                                     **********************
000900 OBJECT-COMPUTER. CROX.
001000 SPECIAL-NAMES.
001100 INPUT-OUTPUT SECTION.
001200 FILE-CONTROL.
001300 DATA DIVISION.
001400 FILE SECTION.
001500 WORKING-STORAGE SECTION.
001600 01  IN-YEAR     PIC 99.
001700 01  TEST-INYEAR PIC S9(4) COMP.
001800 PROCEDURE DIVISION.
001900 MAIN SECTION.
002000 MAIN-000.
002001     MOVE 2000        TO IN-YEAR.
002002     SUBTRACT 1 FROM IN-YEAR.
002003     DISPLAY '1) IN-YEAR = ' IN-YEAR.
002004     MOVE 2000        TO IN-YEAR.
002005     COMPUTE IN-YEAR = IN-YEAR - 1.
002006     DISPLAY '2) IN-YEAR = ' IN-YEAR.
002007     COMPUTE IN-YEAR = IN-YEAR - 0001.00.
002008     DISPLAY '3) IN-YEAR = ' IN-YEAR.
002009
002010     PERFORM VARYING TEST-INYEAR FROM 0 BY +1 UNTIL
002020                     TEST-INYEAR > +99
002030         MOVE TEST-INYEAR TO    IN-YEAR
002031         DISPLAY 'new IN-YEAR IN: ' IN-YEAR WITH NO ADVANCING
002040**       SUBTRACT 1 FROM        IN-YEAR
002041         ADD     99       TO    IN-YEAR
002051         DISPLAY '  OUT: '      IN-YEAR
002061     END-PERFORM
002161     PERFORM VARYING TEST-INYEAR FROM 0 BY +1 UNTIL
002261                     TEST-INYEAR > +99
002361         MOVE TEST-INYEAR TO    IN-YEAR
002461         DISPLAY 'old IN-YEAR IN: ' IN-YEAR WITH NO ADVANCING
002561         SUBTRACT 1 FROM        IN-YEAR
002761         DISPLAY '  OUT: '      IN-YEAR
002861     END-PERFORM
004100     .
004200 MAIN-999.
004300     GOBACK.
004400 END PROGRAM 99-Y2K.
[\code]

The big difference is:

new IN-YEAR IN: 00  OUT: 99
old IN-YEAR IN: 00  OUT: 01

Thanks for your trick.

Regards,

   Crox
 
The target of a compute can be alpha numeric and numeric.

05 ssn-x pic x(09).
05 filler redefines ssn-x.
10 ssn-9 pic 9(09).

Technically both fields are the same storage space. It is not exactly the same field, but in a way it is.

You might also have:
05 SSN-X.
10 SSN-9 PIC 9(05) COMP-3.


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