Passing value with numeric format

142 views Asked by At

i have problems regarding passing value with formatting issues. The description i have put in the codes as i am having problem passing my PreEditedCheque in my code for the if ValidateMMonCheque <> MM part. The output for if length(RawChequenumber) = 15 will be in 1 digit instead of 00001 ( example)

MM = HostGetFLD('','MM')
YY = HostGetFLD('','YY')
PreEditedCheque = substr(RawChequenumber,11,5)

ValidateMMonCheque = substr(RawChequenumber,7,2)

if ValidateMMonCheque <> MM Then    *From this statement* 
Do
   PreEditedCheque = substr('00000',1,5)  *This part where those 0 can't be properly shown if pass to the next statement*
   EditedCheque = '00'||'2'||'0'||YY||MM||'00'||PreEditedCheque 
   rc = message(2,2,EditedCheque)
End


if length(RawChequenumber) = 15 Then  

   EditedCheque = '00'||'2'||'0'||YY||MM||'00'||PreEditedCheque + 1 *Second statement if <>MM ran, this part, the PreEditedCheque will be not in 00001, it will be 1. 

rc = PanSetCtlData('PREVIEW',EditedCheque)
1

There are 1 answers

0
Ross Patterson On BEST ANSWER

What you're asking for is to have the cheque number padded to the left with zeroes in a 5-character field. The Right() function is your friend:

Right(PreEditedCheque, 5, '0') /* "1" -> "00001" */