Focal Point
[Closed] How to concatenate FIRSTNAME and LASTNAME into one field for printing

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

June 07, 2012, 05:40 PM
Liz Campbell
[Closed] How to concatenate FIRSTNAME and LASTNAME into one field for printing
Hi, I'm a new WebFOCUS developer. I need to concatenate two fields FIRSTNAME/A50 AND LASTNAME/A50 into one field (A/30) for printing. Can anyone help? Thanks.

This message has been edited. Last edited by: Kathleen Butler,
June 07, 2012, 05:51 PM
Waz
Hi Liz,

Welcome to the forum.

I would suggest getting a soft copy of all the manuals, the functions manual in particular.


What you need to do is use the concatenate functionality.

| is a soft concatenate
|| is a hard concatenate

The soft concatenate just adds to the end of the previous text, including trailing spaces.
The hard concatenate shifts the trailing spaces to the end of the concatenated text.

e.g.
DEFINE FILE X
FULL_NAME/A101 = FIRSTNAME || (' ' | LASTNAME) ;
END


With the use of the parentheses, you control what happens when.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

June 07, 2012, 08:31 PM
Dan Satchell
Just one thing to add to Waz's excellent explanation - if you need to limit the final output to 30 characters, then you can use the EDIT function to do so:

DEFINE FILE X
 FULL_NAME_LONG/A101 = FIRSTNAME || (' ' | LASTNAME) ;
 FULL_NAME_SHORT/A30 = EDIT(FULL_NAME_LONG,'999999999999999999999999999999$');
END



WebFOCUS 7.7.05
June 08, 2012, 03:48 AM
Alan B
There is also the options when fields are actually variable length, common with relational systems.

If the fields are actually A50V, then this can be done as:
FULL_NAME/A30V = FIRSTNAME || (' ' | LASTNAME);

If the fields are not variable length, the same effect can be obtained,
FULLNAME/A30V = TRIMV('B',FIRSTNAME || (' ' | LASTNAME),100,' ',1,'A30V');

which I prefer to long EDIT, as I can never count all those 9s correctly.


Alan.
WF 7.705/8.007