COBOL

COBOL

COBOL

COBOL is responsible for the efficient, reliable, secure, and unseen day-to-day operations of the world's economy.

 View Only
  • 1.  Unexpected behaviour when SORTing empty ODO-Table with NUMCHECK in effect

    Posted Fri May 05, 2023 10:01 AM

    Hello there fellow COBOLics,

    we found something, that looks like a defect in the COBOL 6.3 Compiler. We have a variable length table that is defined like

    01  TEMP-OUT.    
        03 ODO-Object              PIC S9(4) BINARY.
        03 ODO-Subject    OCCURS 0 TO 42 DEPENDING ON ODO-Object.
            05 Tabular-Data-1       PIC X(69).
            05 Tabular-Data-2       PIC X(69).
            05 Tabular-Data-n       PIC X(69).

    and then the SORT looks like:

    SORT ODO-Object 
      ASCENDING Tabular-Data-1
                Tabular-Data-2

    Now, whenever ODO-Object contains ZERO, Message IGZ0279W is issued for each data-name given in the SORT Statement as a result of the NUMCHECK option. Since sorting an empty table is a rather trivial task, we would not expect those fields to be touched at all. 
    Language Reference in regard to SORT states pretty clearly: "The number of occurrences of table elements that are referenced by data-name-2 is determined by the rules in the OCCURS clause." And the Programming Guide in regard to ODO states "The length of the variable portions of a group item is the product of the object of the DEPENDING ON phrase and the length of the subject of the OCCURS clause."

    Can someone confirm this behaviour. Is there a reason for this behaviour or is it really a defect?

    Kind regards,
    Christoph



    ------------------------------
    Christoph
    ------------------------------


  • 2.  RE: Unexpected behaviour when SORTing empty ODO-Table with NUMCHECK in effect

    Posted Fri May 05, 2023 10:51 AM

    What behaviour are you seeing that you think is incorrect?



    ------------------------------
    Mike Chase
    Enterprise COBOL Developer
    mike.chase@ca.ibm.com
    ------------------------------



  • 3.  RE: Unexpected behaviour when SORTing empty ODO-Table with NUMCHECK in effect

    Posted Mon May 08, 2023 07:16 AM

    Hi Christoph,

    Could you let us know what maintenance level your compiler is at? It's the Pyymmdd on the first compile listing header, as well as the NUMCHECK suboptions as shown in the compiler options listing?

    I'm assuming SORT ODO-Object is a typo, as ODO-object is not a table, you'd have to SORT ODO-Subject or you get a compilation error.

    Bernie



    ------------------------------
    Bernie Rataj
    Technical Support Professional
    IBM Canada Ltd.
    Markham ON Canada
    https://www.ibm.com/products/cobol-compiler-zos
    https://www.ibm.com/products/pli-compiler-zos
    ------------------------------



  • 4.  RE: Unexpected behaviour when SORTing empty ODO-Table with NUMCHECK in effect

    Posted Mon May 08, 2023 07:52 AM

    Hello,

    I gut a hint via PN from Gary to look into https://www.ibm.com/support/pages/apar/PH46802 which looks like the correct solution. I will post an update as soon as the APAR is tested. Also as Bernie pointed out: It should say 

    SORT ODO-Subject
      ASCENDING Tabular-Data-1
                Tabular-Data-2

    Sorry for the confusing typo!

    Cheers,
    Christoph



    ------------------------------
    Christoph
    ------------------------------



  • 5.  RE: Unexpected behaviour when SORTing empty ODO-Table with NUMCHECK in effect

    Posted Mon May 08, 2023 08:13 AM

    I compiled and executed as you have it, but SORTed ODO-Object as Bernie suggested, with no problem.

    Make certain you set ODO-Object (which, IMHO, you might consider changing the name of to ODO-ObjectS. or ODO-Count) to zero before executing the SORT.

    I used COBOL 6.3.0  P220720

    Cheers.




    ------------------------------
    Jon Butler
    ------------------------------