IBM Support

PI99703: CBL V6.2 NEW INTRINSIC FUNCTIONS: HEX-OF, BIT-OF, E, PI AND TRIM

A fix is available

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as new function.

Error description

  • New CBL V6.2 intrinsic functions:
    
    1) HEX-OF
    The HEX-OF function returns an alphanumeric character item
    consisting of the content of the specified input character item
    converted to a hexadecimal representation.
    
    2) BIT-OF
    The BIT-OF function returns an alphanumeric character item
    consisting of characters "1" and "0" that correspond to the
    binary value of each byte in the input argument.
    
    3) E
    The E function returns an approximation of e, the base of
    natural logarithms.
    
    4) PI
    The PI function returns a value that is an approximation of pi,
    the ratio of the circumference of a circle to its diameter.
    
    5) TRIM
    The TRIM function returns a character item that contains the
    characters in the argument with leading spaces, trailing
    spaces, or both, deleted.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED: Users of Enterprise COBOL 6.2 who need to    *
    *                 do one or more of the following:             *
    *                 1. convert a value to an alphanumeric        *
    *                 character string consisting of the           *
    *                 hexadecimal representation of the value      *
    *                 2. convert a value to an alphanumeric        *
    *                 character string consisting of a binary      *
    *                 representation of the value using the        *
    *                 characters "0" and "1"                       *
    *                 3. remove leading and/or trailing spaces     *
    *                 from an alphanumeric or national character   *
    *                 string                                       *
    *                 4. reference the mathematical constant e,    *
    *                 the base of natural logarithms               *
    *                 5. reference the mathematical constant pi,   *
    *                 the ratio of the circumference of a circle   *
    *                 to its diameter.                             *
    ****************************************************************
    * PROBLEM DESCRIPTION: New function: Add support for the       *
    *                      following new intrinsic functions:      *
    *                      1. HEX-OF - convert a value to a        *
    *                      hexadecimal string                      *
    *                      2. BIT-OF - convert a value to a        *
    *                      character string consisting of a binary *
    *                      representation of the value using the   *
    *                      characters "0" and "1"                  *
    *                      3. TRIM - remove leading and/or         *
    *                      trailing spaces from an alphanumeric    *
    *                      or national character string            *
    *                      4. E - the mathematical constant e,     *
    *                      the base of natural logarithms          *
    *                      5. PI - the mathematical constant pi,   *
    *                      the ratio of the circumference of a     *
    *                      circle to its diameter.                 *
    ****************************************************************
    * RECOMMENDATION: Apply the provided PTF.                      *
    ****************************************************************
    Enterprise COBOL did not provide a way to convert data values
    to hexadecimal or bit strings.  Enterprise COBOL was also
    lacking support for the following intrinsic functions defined
    in the COBOL standard: TRIM, E and PI.
    

Problem conclusion

Temporary fix

Comments

  • The compiler was updated to add support for the following
    intrinsic functions that are IBM extensions to the COBOL
    language:
    1. HEX-OF - convert a value to a hexadecimal string
    2. BIT-OF - convert a value to a character string consisting of
    a binary representation of the value using the characters "0"
    and "1"
    
    The compiler was updated to add support for the following
    intrinsic functions defined in the 2002 COBOL standard:
    1. E - the mathematical constant e, the base of natural
    logarithms
    2. PI - the mathematical constant pi, the ratio of the
    circumference of a circle to its diameter
    
    The compiler was updated to add support for the following
    intrinsic function defined in the 2014 COBOL standard:
    1. TRIM - remove leading and/or trailing spaces from
    an alphanumeric or national character string
    
    
    +--------------------------------------------------------------+
    | Start of changes for:                                        |
    | Enterprise COBOL for z/OS Language Reference, SC27-8713-01   |
    
    
    Chapter 21. Intrinsic functions
    
    Add the following new sections for HEX-OF, BIT-OF, TRIM, E
    and PI.
    
    
    HEX-OF
    
    The HEX-OF function returns an alphanumeric character string
    consisting of the bytes of the input argument converted to a
    hexadecimal representation.
    
    The type of the function is alphanumeric.
    
    Format
    
    >>-FUNCTION HEX-OF--(--argument-1--)------------------------><
    
    argument-1
        Can be a data item, literal, or intrinsic function result
        of any data class. argument-1 identifies the source
        character string for the conversion.
    
    The returned value is an alphanumeric character string
    consisting of the bytes of argument-1 converted to a hexadecimal
    representation. The length of the output character string in
    bytes is two times the length of argument-1 in bytes.
    
    Examples
    
        1. FUNCTION HEX-OF('Hello, world!') returns
        'C8859393966B40A6969993845A'
    
        2. 01 BIN PIC 9(9) BINARY VALUE 12.
        .
        .
    
        FUNCTION HEX-OF(BIN) returns '0000000C'
    
        3. 01 PAC PIC 9(5) COMP-3 VALUE 12345.
        .
        .
    
        FUNCTION HEX-OF(PAC) returns '12345F'
    
        4. 01 ZON PIC 9(5) VALUE 12345.
        .
        .
    
        5. FUNCTION HEX-OF(ZON) returns 'F1F2F3F4F5'
        6. FUNCTION HEX-OF(FUNCTION NATIONAL-OF(' ')) returns '0020'
    
    
    BIT-OF
    The BIT-OF function returns an alphanumeric character string
    consisting of characters "1" and "0" that correspond to the
    binary value of each byte in the input argument.
    
    The type of the function is alphanumeric.
    
    Format
    
    >>-FUNCTION BIT-OF--(--argument-1--)-------------------------><
    
    argument-1
        Can be a data item, literal, or intrinsic function result of
        any data class. argument-1 identifies the source character
        string for the conversion.
    
    The returned value is an alphanumeric character string
    consisting of the bytes of argument-1 converted to the bit
    pattern corresponding to the binary value of each byte in
    argument-1. The length of the output character string in bytes
    is eight times the length of argument-1 in bytes.
    
    Examples
    
        1. FUNCTION BIT-OF('Hello, world!') returns '110010001000010
           110010011100100111001011001101011010000001010011010010110
           10011001100100111000010001011010'
    
        2. 01 BIN PIC 9(9) BINARY VALUE 12.
        .
        .
    
        FUNCTION BIT-OF(BIN) returns
        '00000000000000000000000000001100'
    
        3. 01 PAC PIC 9(5) COMP-3 VALUE 12345.
        .
        .
    
        FUNCTION BIT-OF(PAC) returns '000100100011010001011111'
    
        01 ZON PIC 9(5) VALUE 12345.
        .
        .
    
        4. FUNCTION BIT-OF(ZON) returns
        '1111000111110010111100111111010011110101'
    
        5. FUNCTION BIT-OF(NATIONAL-OF(' ')) returns
        '0000000000100000'
    
    
    TRIM
    
    The TRIM function returns a character string that contains the
    characters in the argument with leading spaces, trailing spaces,
    or both, deleted.
    
    The function type depends on the argument type as follows:
    
    Table 1. TRIM function types depending on the argument types
    
    Argument type   Function type
    Alphabetic      Alphanumeric
    Alphanumeric    Alphanumeric
    National        National
    
    Format
    
    >>-FUNCTION TRIM--(--argument-1--+----------+--)-------------><
                                     +-LEADING--+
                                     '-TRAILING-'
    
    argument-1
        Must be a data item of class alphabetic, alphanumeric, or
        national.
    
    The returned value is:
    
        - If LEADING is specified, the returned value is a character
        string that consists of the characters in argument-1
        beginning from the leftmost character position that does not
        contain a space character through the rightmost character
        position.
    
        - If TRAILING is specified, the returned value is a
        character string that consists of the characters in
        argument-1 beginning from the leftmost character position
        through the rightmost character position that does not
        contain a space character.
    
        - If neither LEADING nor TRAILING is specified, the returned
        value is a character string that consists of the characters
        in argument-1 beginning from the leftmost character position
        that does not contain a space character through the
        rightmost character position that does not contain a space
        character.
    
        - If argument-1 contains all spaces or argument-1 is of
        length zero, the returned value is of length zero.
    
    Examples
    
        FUNCTION TRIM(" Hello, world! ", LEADING) returns
          "Hello, world! "
        FUNCTION TRIM(" Hello, world! ", TRAILING) returns
          " Hello, world!"
        FUNCTION TRIM(" Hello, world! ") returns "Hello, world!"
        FUNCTION TRIM(" ") returns ""
        FUNCTION TRIM("") returns ""
    
    
    E
    
    The E function returns an approximation of e, the base of
    natural logarithms.
    
    The function type is numeric.
    
    Format
    
    >>-FUNCTION E------------------------------------------------><
    
    When ARITH(COMPAT) is in effect, FUNCTION E returns the long
    precision (64-bit) floating-point approximation of 2.71828182845
    9045235360287471352662.
    
    When ARITH(EXTEND) is in effect, FUNCTION E returns the extended
    precision (128-bit) floating-point approximation of 2.7182818284
    59045235360287471352662.
    
    
    PI
    
    The PI function returns a value that is an approximation of pi,
    the ratio of the circumference of a circle to its diameter.
    
    The function type is numeric.
    
    Format
    
    >>-FUNCTION PI-----------------------------------------------><
    
    When ARITH(COMPAT) is in effect, FUNCTION PI returns the long
    precision (64-bit) floating-point approximation of 3.14159265358
    9793238462643383279503.
    
    When ARITH(EXTEND) is in effect, FUNCTION PI returns the
    extended precision (128-bit) floating-point approximation of 3.1
    41592653589793238462643383279503.
    
    
    | End of changes for:                                          |
    | Enterprise COBOL for z/OS Language Reference, SC27-8713-01   |
    +--------------------------------------------------------------+
    
    
    +--------------------------------------------------------------+
    | Start of changes for:                                        |
    | Enterprise COBOL for z/OS Programming Guide, SC27-8714-01    |
    
    Chapter 6. Handling Strings
    
    Add the following new subsection to section
    "Converting data items (intrinsic functions)".
    
    Converting to hexadecimal or bit data (HEX-OF, BIT-OF)
    
    You can use the HEX-OF or BIT-OF intrinsic functions to convert
    data of any type to a string of hexadecimal or binary digits.
    
    The HEX-OF intrinsic function can be used to convert data of any
    type to a human readable string of hexadecimal digits ("0"
    through "9" and "A" through "F") that represent, in hexadecimal
    form, the underlying byte values of the data to be converted.
    The length of the output hex string in bytes is two times the
    length of the input argument string in bytes.
    
    For example, FUNCTION HEX-OF('Hello, world!') returns 'C88593939
    66B40A6969993845A'.
    Note: The first two hexadecimal digits 'C8' correspond to the
    EBCDIC encoding of the letter 'H'.
    
    The argument to the HEX-OF intrinsic function can be a literal,
    a data item, or the result of an intrinsic function.
    
    The BIT-OF intrinsic function can be used to convert data of any
    type to a human readable string of binary digits ("0" or "1")
    that represent, in bit string form, the underlying byte values
    of the data to be converted. The length of the output bit string
    in bytes is eight times the length of the input argument string
    in bytes.
    
    For example, FUNCTION BIT-OF('Hello, world!') returns '110010001
    000010110010011100100111001011001101011010000001010011 010010110
    10011001100100111000010001011010'.
    
    Note: The first eight characters '11001000' of the output string
    correspond to the hexadecimal value x'C8', which matches the
    output of the HEX-OF intrinsic function shown above and
    corresponds to the EBCDIC encoding of the letter 'H'.
    
    The argument to the BIT-OF intrinsic function can be a literal,
    a data item, or the result of an intrinsic function.
    
    
    Appendix G. COBOL SYSADATA fle contents
    
    In section "Parse tree record: X'0024', update the Node subtype
    "for Function identifier type" as follows:
    
    0057
            HEX-OF
    0058
            BIT-OF
    0059
            E
    0060
            TRIM
    0061
            PI
    
    | End of changes for:                                          |
    | Enterprise COBOL for z/OS Programming Guide, SC27-8714-01    |
    +--------------------------------------------------------------+
    

APAR Information

  • APAR number

    PI99703

  • Reported component name

    ENT COBOL FOR Z

  • Reported component ID

    5655EC600

  • Reported release

    620

  • Status

    CLOSED UR1

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2018-06-28

  • Closed date

    2018-07-18

  • Last modified date

    2018-10-02

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Modules/Macros

  • IGY8RWTU IGYCASMB IGYCCBE  IGYCCCRT IGYCCICS IGYCCSRV IGYCDGEN
    IGYCDIAG IGYCDMAP IGYCEN$0 IGYCEN$1 IGYCEN$2 IGYCEN$3 IGYCEN$4
    IGYCEN$5 IGYCEN$8 IGYCEN$D IGYCEN$R IGYCFGEN IGYCFREE IGYCINIT
    IGYCJA$0 IGYCJA$1 IGYCJA$2 IGYCJA$3 IGYCJA$4 IGYCJA$5 IGYCJA$8
    IGYCJA$D IGYCJA$R IGYCLIBH IGYCLIBO IGYCLIBR IGYCLSTR IGYCLVL0
    IGYCLVL1 IGYCLVL2 IGYCLVL3 IGYCLVL8 IGYCMALL IGYCOB2E IGYCOPI
    IGYCOSCN IGYCPGEN IGYCRCTL IGYCRDPR IGYCRDSC IGYCREAL IGYCRWT
    IGYCSCAN IGYCSIMD IGYCUE$0 IGYCUE$1 IGYCUE$2 IGYCUE$3 IGYCUE$4
    IGYCUE$5 IGYCUE$8 IGYCUE$D IGYCUE$R IGYCXREF IGYDRV   IGYEQCWI
    IGYMSGE  IGYMSGK  IGYMSGT  IGYQCBE  IGYWIVP1 IGYWIVP2 IGYZQDRV
    IGYZQENU IGYZQJPN
    

Publications Referenced
SC27871401SC27871301   

Fix information

  • Fixed component name

    ENT COBOL FOR Z

  • Fixed component ID

    5655EC600

Applicable component levels

  • R620 PSY UI57342

       UP18/08/02 P F807

  • R621 PSY UI58271

       UP18/10/02 P F809

  • R622 PSY UI57344

       UP18/07/31 P F807

  • R62H PSY UI58273

       UP18/09/06 P F809

Fix is available

  • Select the PTF appropriate for your component level. You will be required to sign in. Distribution on physical media is not available in all countries.

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SS6SG3","label":"Enterprise COBOL for z\/OS"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"620","Edition":"","Line of Business":{"code":"LOB35","label":"Mainframe SW"}}]

Document Information

Modified date:
12 December 2023