Report Requirement:

Recently client came with the Report requirement of adding a “.” between each digit of a Number value in Database Field. For example, if Database Field Value is: 12345 then client want to show in the report as: 1.2.3.4.5

Interestingly the length of the number can change, sometimes it will be 2 digits and sometimes it will be 6 digits etc.

Solution:

Crystal Report is so much powerful that it can be done by simply creating a Variable with below logic:

Note: In the below logic DATA_PROC.SRL_NBR is a field of a Procedure. You can do the same thing for Field of a Table.

stringVar x := “”;
numberVar y := Length(ToText(Trim({DATA_PROC.SRL_NBR})));
numberVar start_pos := 1;
x := Mid (ToText(Trim({DATA_PROC.SRL_NBR})), start_pos,1 );

if (y > 1) then
(
do

(

start_pos := start_pos + 1;

x := x + “.” + Mid (ToText(Trim({DATA_PROC.SRL_NBR})), start_pos,1 );

) while (start_pos < (y-1));

);

x

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x