Tuesday, 2 January 2018

%DECH Example

      * 
      * Description :·%DecH() Example
      *
      * Syntex      :
      *
      * %DecH(Numeric Expression : Precision : Decimal Places)
      *
      * Function    :·Return Packed decimal value for given numeric
      *               expression with half adjusted decimal value.
      *
      * Output      :·Packed Decimal Value of first parameter
      *
      * Note        :·No msg will be issued if unable to convert in
      *               desired precision
      *==========================================================
      *
     D ZonedDec        S              5S 3 Inz(10.123)
     D FloatDec        S              8F   Inz(123.45678)
     D PackedDec       S             15P 5

     C
      /Free

           PackedDec = %DecH(ZonedDec : 5 : 2) ;
           Dsply %Char(PackedDec) ;              // 10.12000

           PackedDec = %DecH(FloatDec : 5 : 2) ;
           Dsply %Char(PackedDec) ;              // 123.46000

      /End-Free
     C                   SetOn                                        LR

No comments:

Post a Comment