SAP Knowledge Base Article - Public

1210713 - Extracting the Initials out of a Name String field using a function

Symptom

A name string is held in the database in a variable format, for example:

James Jones

Bill J Smith

Alan D F Other

John B Doe

The individual initials are required from this string, eg, A D F O (Alan D F Other) or J J (James Jones).

Resolution

There is an additional User Function Library DLL that returns all the first characters of each 'word' in a string, where the 'words' are separated by spaces.

Download and run Ufltech1.exe. The enclosed readme file describes how to install the DLL.

Once you see that the GetInitials function is listed in the Additional Functions folder in the CR Formula Editor, you can create a formula to extract the initials:

@Initials

GetInitials({Table.Name})

This returns the initials, with no spaces. For example, 'Joe A. Doe' becomes 'JAD'.

To insert spaces between the initials, create another formula:

@InsertSpace

If length({@Initials}) = 2 then

{@Initials}[1] + " " + {@Initials}[2]

else

if length({@Initials}) = 3 then

{@Initials}[1] + " " +{@Initials}[2]+ " " + {@Initials}[3]

else

if length({@Initials}) = 4 then

{@Initials}[1] + " " +{@Initials}[2]+ " " +{@Initials})[3] + " " + {@Initials}[4]

The above formula is designed to accommodate up to 4 initials; however you can add to this formula to accommodate more.

Knowledge base article C2004685 describes how to achieve the same results with variables, instead of the GetInitials function.

Keywords

EXTRACT INITIALS FROM STRING NAME GETINITIALS Seagate Crystal Reports Using the GetInitials function Extracting values from string fields , c2004913 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 4.0