Focal Point
[SOLVED]CHANGE INTERGER TO CHARACTER

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3237081376

October 20, 2014, 02:32 PM
QuickLearner
[SOLVED]CHANGE INTERGER TO CHARACTER
Hello to all,

I would like to convert this integer to a character. I have the code below, but it seems to be padding the number with zero's:

 CR_NUMBER/A15= IF INC_INCIDENT_ID EQ 0 THEN '' ELSE EDIT(INC_INCIDENT_ID); 


Changes 200993916 to 00200993916. I need the zero's removed.

This message has been edited. Last edited by: QuickLearner,


WebFOCUS 7.6
Windows, All Outputs
October 20, 2014, 02:39 PM
MattC
quote:
Originally posted by QuickLearner:
Hello to all,

I would like to convert this integer to a character. I have the code below, but it seems to be padding the number with zero's:

 CR_NUMBER/A15= IF INC_INCIDENT_ID EQ 0 THEN '' ELSE EDIT(INC_INCIDENT_ID); 


Changes 200993916 to 00200993916. I need the zero's removed.




 CR_NUMBER/A15= IF INC_INCIDENT_ID EQ 0 THEN '' ELSE EDIT(INC_INCIDENT_ID, '$$9999999999999'); 



WebFOCUS 8.1.05
October 20, 2014, 02:49 PM
QuickLearner
quote:
Originally posted by MattC:
quote:
Originally posted by QuickLearner:
Hello to all,

I would like to convert this integer to a character. I have the code below, but it seems to be padding the number with zero's:

 CR_NUMBER/A15= IF INC_INCIDENT_ID EQ 0 THEN '' ELSE EDIT(INC_INCIDENT_ID); 


Changes 200993916 to 00200993916. I need the zero's removed.




 CR_NUMBER/A15= IF INC_INCIDENT_ID EQ 0 THEN '' ELSE EDIT(INC_INCIDENT_ID, '$$9999999999999'); 


Perfect. Thank you!!!


WebFOCUS 7.6
Windows, All Outputs
October 20, 2014, 03:17 PM
MartinY
Will work while you only have 2 leading zeros.
This will don't care about how many zeros:
CR_NUMBER/A15= IF INC_INCIDENT_ID EQ 0 THEN '' ELSE FPRINT(INC_INCIDENT_ID, 'abc', 'A15'); 

Where abc = the format of INC_INCIDENT_ID such as P13, D13, ...


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
October 20, 2014, 03:19 PM
Alan B
Well the EDIT is only going to work for numbers from 100000000 to 999999999, which is ok if all your numbers are in that range.

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
October 21, 2014, 08:02 AM
MartinY
quote:
Well that is only going to work for numbers from 100000000 to 999999999, which is ok if all your numbers are in that range.

Alan above comment is applicable to the EDIT command suggested by MattC.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
October 21, 2014, 09:34 AM
Alan B
Yes indeed Martin. I was writing as you posted I reckon. FPRINT is the correct approach.


Alan.
WF 7.705/8.007