lpad - ing a field

sreekuax

Member
I need to add zeros to the left of two fields... lets take ckd_amt and ck_nbr fields.
if it was sql then LPAD is an option.. likewise is there an option in progress ?

The total content length after lpading should be 10 for both....
I tried declaring a variable as integer '9999999999' and then adding the variable to ck_nbr.. but it was displaying properly in the procedure editor but when i tried the same in a stream ..its not working...
Any idea ? and for ckd_amt I still dont have a clue.

Thanks for any help.
 

Cringer

ProgressTalk.com Moderator
Staff member
How are you putting it to the stream?

And you'll have to give us more info because have no idea about your system and what ckd_amt and ck_nbr are.
 

sreekuax

Member
in case of ck_nbr :
DEFINE VARIABLE xx-ck_nbr as integer format '9999999999' no-undo .
output to out-stream.
for each ck_mstr no-lock :
assign xx-ck_nbr = xx-ck_nbr + ck_nbr.
put stream out-stream unformatted
ck_nbr '|' xx-ck_nbr.
skip.
end.
output close.
*********************** this is not working....
but if you remove the stream part and try display in mfg/pro progress procedure editor it works fine....
and as I told.. for ckd_amt I dont have a clue yet !
 

Cringer

ProgressTalk.com Moderator
Staff member
The unformatted option on the put command removes all formatting so that's why that won't work.

Code:
DEFINE VARIABLE lv-mine AS INTEGER     NO-UNDO FORMAT '9999999999'.

lv-mine = 234.

MESSAGE string(lv-mine,'9999999999')
  VIEW-AS ALERT-BOX INFO BUTTONS OK.
 

sreekuax

Member
ckd_amt is an amount value field and the format is ->>>>,>>>,>>9.99 (10 decimal place...) requirement is ..
say ckd_amt has a value... ckd_amt = 297.63 .. first i need to remove the decimal by multipying 100...
297.63 * 100 = 29763... now.. lpad zeros to length 10... so the value should be ... '0000029763' ...
 

Cringer

ProgressTalk.com Moderator
Staff member
in that case I would do

Code:
lv-amount = ckd_amt * 100. 
messsage string(lv-amount,'9999999999') view-as alert-box.
 
Top