Page 1 of 1

Routine_for trimming and sign assign

Posted: Tue Nov 13, 2007 2:17 pm
by reddysrc
Hi All,

i need a Routine for my server job (7.5.2)

here is the requirement :"Convert the (23, 3) number into 16 position character. Left pad with ZERO's and Keep the sign if it is required. "

could you help me how to wright routine for this one.

Thanks
Chandu

Re: Routine_for trimming and sign assign

Posted: Tue Nov 13, 2007 2:41 pm
by gateleys
You should be able to achieve what you want with this derivation -

Code: Select all

If Arg1 < 0 Then '-':Fmt(Field(Arg1,'-',2), "15'0'R") Else Fmt(Arg1, "16'0'R")
It won't work if the input value has a length in excess of 16.

Posted: Tue Nov 13, 2007 4:07 pm
by ray.wurlod
But does if you truncate Arg1. Let stage variable svArg1 be defined as Right(Arg1,16).

Code: Select all

If svArg1 < 0 Then '-':Fmt(Field(svArg1,'-',2), "R%15") Else Fmt(svArg1, "R%16")