Converting Native Fujitsu Cobol Numeric Fields to / from Decimal

There are any number of bizarre syntax rules concerning the interaction of native Cobol data types and .Net data types.  One of the stranger ones is this:  If you want to convert a .Net Decimal value to a native Cobol numeric field, that field must be signed.  Oddly enough, the inverse is not true.  You can convert unsigned Cobol fields to .Net Decimal values.  So, to convert Decimal to Cobol you must do something like this:

01  WS-TEMP PIC S9(5)V99.
01  WS-VALUE PIC 9(5)V99.
01  WS-DECIMAL OBJECT REFERENCE CLASS-DECIMAL.

SET WS-TEMP TO WS-DECIMAL.
MOVE WS-TEMP TO WS-VALUE.

What at PITA!

One Response to “Converting Native Fujitsu Cobol Numeric Fields to / from Decimal”

  1. Jean-Francois Gagnon Says:

    And that working as long as your decimal value does not have a greater precision than your COBOL variable.
    You want to make a improvement request to Alchemy Solution in that regards.
    Some comments in that sense were provided to them a couple of years ago.

Leave a Reply