I'm trying to convert a number to character removing zeros from the beginning of the number and the end of decimal parts.
I found this solutions, What do you think about it? Do I forget something?
Many thanks.
I found this solutions, What do you think about it? Do I forget something?
Code:
**free Ctl-Opt dftactgrp(*no) actgrp('QILE') bnddir('QC2LE' :'AL400MNUV2') option(*nounref :*srcstmt :*nodebugio) datfmt(*iso) timfmt(*iso) decedit('.') debug alwnull(*usrctl); Dcl-Pr DspLongTextMsg ExtPgm('QUILNGTX'); Text Char(65535) Const options(*varsize); Length Int(10) Const; MsgId Char(7) Const; QualMsgF Char(20) Const; ErrorCode Char(32767) Options(*varsize); End-Pr; DCL-DS ErrorCode Qualified; BytesProv Int(10) inz(0); BytesAvail Int(10) inz(0); END-DS; Dcl-s CharField Varchar(30); Dcl-s WorkField Zoned(20: 6); Dcl-s LogMsg VarChar(640000); //------------------------------ WorkField = 10.0; Exsr DectoChar; WorkField = 1234; Exsr DectoChar; WorkField = -11.34; Exsr DectoChar; WorkField = -01.550; Exsr DectoChar; WorkField = -00.670888; Exsr DectoChar; *Inlr = *On; //------------------------------ Begsr DecToChar; CharField = %TrimR(%TrimR(%Char(WorkField) :'0') :'.'); CharField = %ScanRpl('.' :'0.' :CharField :1 :1); CharField = %ScanRpl('-.' :'-0.' :CharField :1 :2); LogMsg = CharField + ' Len=' + %Char(%len(CharField)); DspLongTextMsg(LogMsg : %Len(LogMsg) :*blanks :'' : ErrorCode); EndSr;
Many thanks.
Comment