Procedure Division Conversion Rules

In procedure division, the COBOL Unicode conversion utility for z/OS applies the following conversion rules to ensure that the correct operations on data fields convert to usage NATIONAL. These conversion rules are based on statement type.

Statement(s) Conversion Rule Description
  • ADD

  • DIVIDE

  • EVALUATE

  • WHEN

  • ENTRY

  • IF

  • INITIALIZE

  • INSPECT

  • INVOKE

  • MULTIPLY

  • PERFORM

  • SEARCH

  • SET

  • STOP

  • STRING

  • SUBTRACT

  • UNSTRING

  • EXEC

Add “N” in front of every literal in the context of these statements.

DISPLAY

Surround each national data item in its context with FUNCTION DISPLAY-OF(), so that EBCIDIC data is printed on the log. If the data item is national numeric item (PIC 9 USAGE NATIONAL), add FUNCTION DISPLAY-OF() and reference modification to the item.

  • CALL

  • CANCEL

Add FUNCTION DISPLAY-OF() if the first parameter is NATIONAL data field.

COMPUTE

Add FUNCTION DISPLAY-OF() to the parameter of FUNCTION NUMVAL().

Example 1: Prefix “N” Added to Literals in the Context of STRING Statements

IBM Enterprise COBOL compiler complains if both national and non-national items are contained in the context of some statements, including STRING, UNSTRING, and INSPECT. Since SQL-STMT of ICST-DYSQL is a national character field, the statement cannot be compiled unless we add “N” prefix to the literals.

STRING
     N'%ROUND(TLP_COST,2), ' DELIMITED BY SIZEN'%ROUND(LLP_COST,2), ' DELIMITED BY SIZE
     INTO SQL-STMT OF ICST-DYSQL
     WITH POINTER SQL-STMT-LEN OF ICST-DYSQL
     ON OVERFLOW PERFORM ZS000-STRING-ERROR
END-STRING

Example 2: Insert DISPLAY-OF() Intrinsic Function Around National Data Items

The conversion utility inserts DISPLAY-OF() intrinsic function around national data items in the context of DISPLAY statements, so that the data is converted to EBCDIC.

The DISPLAY-OF() function only accepts the PIC N parameter. To convert the PIC 9 USAGE NATIONAL item to non-Unicode using the DISPLAY-OF() function, you must add a reference modification (in the following example (1:)) to the PIC 9 USAGE NATIONAL ITEM, so that the item is first converted to a PIC N item.

DISPLAY 'RUNID= ' FUNCTION DISPLAY-OF(RUNID OF KBDPR)
DISPLAY 'OPRID= '  FUNCTION DISPLAY-OF(OPRIDX OF KBDPR)
DISPLAY 'RUNID OF SQLRT=' FUNCTION DISPLAY-OF(BATCH-RUN-ID OF SQLRT)
DISPLAY 'PROCESS-INSTANCE = ' FUNCTION
DISPLAY-OF(PROCESS-INSTANCE OF KBDPR(1:))

Example 3: Add FUNCTION DISPLAY-OF() if the First Parameter is National Data Field

If the first parameter of a CALL statement, which specifies the called subprogram, is a national data item, the conversion utility adds the DISPLAY-OF() function to the parameter, because the national data item cannot be used for the CALL parameter.

CALL FUNCTION DISPLAY-OF(COBOL-PROG OF W-WK) USING SQLRT
                                         LOGMS
                                         BMSET
                                         DYSQL
                                         SPARM
                                         SBIND
                                         SCACH
                                         ECURS

Example 4: Add FUNCTION DISPLAY-OF() to the Parameter of FUNCTION NUMVAL()

If the data field passed to function NUMVAL() is national data type, the conversion utility adds function DISPLAY-OF() to convert the data item to EBCDIC data, as NUMVAL() function cannot process national data.

COMPUTE W-COMPARE-GPA =
            FUNCTION NUMVAL ( FUNCTION DISPLAY-OF(W-CONDITION-DATA
))