COBOL Tips.

A Mainframe-Tip a Day keeps the bugs away!
Forum rules
All of these Tips/Tuning-suggestions should be tested your own, at your shop, prior to use in Prod.
Previous topicNext topic
User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

COBOL Tips.

Post by Anuj Dhawan » Fri May 24, 2013 11:16 pm

1. Do you know how COBOL Compiler finds a data-set as VSAM data-set? When the ORGANIZATION clause is coded for a file, the COBOL compiler interprets it as a VSAM data-set. Hence, the ORGANIZATION clause should not be coded with a non-VSAM data-set.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue May 28, 2013 8:38 pm

2. Using an odd number of digits for PACKED DECIMAL (COMP-3) is 5% to 20% faster than using an even number of digits... why? It's a "Tip of the Day" section and not the "Explanation of the Day" section. So I leave that for the reader to explore... :)


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Jul 16, 2013 6:34 pm

3. MERGE statement can have OUTPUT PROCEDURE but not INPUT PROCEDURE.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Jul 16, 2013 6:37 pm

4. For a table with less than 50 entries use SEARCH ( Sequential Search) and for greater than 50 entries, use SEARCH ALL ( Binary Search). (though opinions vary, however, it's usually advisable).


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: COBOL Tips.

Post by Robert Sample » Tue Jul 16, 2013 6:43 pm

Regarding tip 1: COBOL recognizes a VSAM ESDS file by the presence of AS-ddname in the SELECT statement.



User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Aug 06, 2013 3:36 pm

5. Carefully use the verb INITALIZE. It generates a move for every non-filler elementary data item, especially on very long records or large files. If you need to use INITALIZE do it once in "housekeeping" and save in "working-storage". Then move the group from working storage wherever you would code the INITALIZE.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Aug 06, 2013 3:36 pm

6. Always remove test compile options such as “Displays”, before implementing into production.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Sat Aug 10, 2013 10:39 pm

7. In continuation with what Robert has said that if you are accessing ESDS VSAM file, then in COBOL SELECT clause has AS-DDNAME. If you are not doing that then an S213 ABEND might occur when attempting to open data set.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Sat Aug 10, 2013 10:41 pm

8. Have you ever thought why it's READ FILE in COBOL and not READ RECORD as it's in WRITE RECORD? :)

The answer is: You READ FILE because, there is no way out to know in advance:
  1. If there is actually a record to read or not
  2. For variable or undefined length files, one does not know how long the next record will be if there is one.
And You WRITE RECORD because without knowing above two answers one can not write in and while WRITing program already know them.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Oct 01, 2013 1:53 pm

9. For Enterprise Cobol V 4.1 (onwards) for zOS, if you compile the program using the compiler option "XREF ON", one can see from where the Copybook came that was used while compiling the Program.

In the listing find for "COPY/BASIS" (when XREF ON is used) - This section lists the copybooks and their location.



Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Oct 01, 2013 2:27 pm

10. It's advisable that, if possible avoid doing a sort within a COBOL program. COBOL sorts are very inefficient. If you must do a sort in a COBOL program, specifying the FASTSRT compiler option may be handy for tuning. On the other hand, if you are using INPUT/OUTPUT procedure then FASTSRT compiler option will not increase the performance. It is better to use the (DF)SORT control statements like INREC, OUTREC, SUM, SKIPREC, INCLUDE or OMIT ,STOPAFT etc and put them under the ddname SORTCNTL or IGZSRTCD.


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.


zprogrammer
Global Moderator
Global Moderator
Posts: 605
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars
Zodiac: Libra

Re: COBOL Tips.

Post by zprogrammer » Tue Dec 31, 2013 9:06 pm

11.When ever we do processing reading a file better to have an approach like this


Templace

Code: Select all

         Open file
         Read file
         process until EOF
                     "MAIN PROCESSING"
                      Read file
         Close file   


zprogrammer


zprogrammer
Global Moderator
Global Moderator
Posts: 605
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars
Zodiac: Libra

Re: COBOL Tips.

Post by zprogrammer » Tue Feb 11, 2014 1:13 am

12.A simple and effective way to debug your program When you have no DEBUGGING TOOL in place is

You could add display after start of every section and start of every para

On execution you could see the program flow and understand the problem much faster


zprogrammer


Quasar Chunawala
Registered Member
Posts: 35
Joined: Sun Aug 11, 2013 4:48 pm
Location: Pune
Zodiac: Aquarius

Re: COBOL Tips.

Post by Quasar Chunawala » Wed Mar 12, 2014 12:02 am

13. As a follow-on tip to the above, I worked at a shop, where all COBOL batch modules had this standard -

Code: Select all

5500-GET-TRADES.
    MOVE '5500-GET-TRADES' TO WS-PARA-NAME
    PERFORM 9000-DEBUG THRU 9000-EXIT
    ...
    para-body
    ...
5500-EXIT. EXIT.

9000-DEBUG.
    IF LS-DEBUG-SW = 'Y'
        DISPLAY WS-PARA-NAME
    END-IF.
9000-EXIT. EXIT.
You can code the JCL as,

Code: Select all

//* By Default
//STEP010 EXEC PGM=MYPROG01,PARM='N'           
//* Turn on debug mode
//STEP020 EXEC PGM=MYPROG01,PARM='Y'           



User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Apr 29, 2014 5:10 pm

14. This is not really a "tip" but interesting to know:

In SELECT INFILE ASSIGN TO UT-S-INFILE or SELECT INFILE ASSIGN TO DA-S-INFILE - what does UT-S- and DA-S- stands for?

The syntax for SELECT clause in COBOL is SELECT file-name ASSIGN TO DD-name.

Keeping above in mind, for the second line above, the first Part in DDNAME is "Device Class" - UT stands for utility (Tape or sequential disk) and DA stands for direct access (Disk). Second Part in DDNAMAE: is "Method of Organization" - S – Sequential (Printer, Terminal, Disk or Tape).


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

User avatar

Topic Author
Anuj Dhawan
Founder
Posts: 2624
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Zodiac: Sagittarius

Re: COBOL Tips.

Post by Anuj Dhawan » Tue Apr 29, 2014 5:36 pm

15. ALL31: ALL31 specifies whether an application can run entirely in AMODE 31 or whether the application has one or more AMODE 24 routines.

The ALL31 option allows LE to take advantage of knowing that there are no AMODE(24) routines in the application. It specifies that the entire application will run in AMODE(31). This can help to improve the performance
for an all AMODE(31) application because Linkage Editor can minimize the amount of mode switching across calls to common run time library routines.

This option does not implicitly alter storage, in particular storage managed by the STACK and HEAP run-time options. However, you must be aware of your application's requirements for stack and heap storage,
because such storage can potentially be allocated above the line while running in AMODE 24


Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.

Previous topicNext topic

Return to “Tip Of the Day.”