Home > PeopleCode > Carriage Return in PeopleCode

Carriage Return in PeopleCode

November 29, 2007 Leave a comment Go to comments

Sometime back, I was writing an application engine using PeopleCode and I needed to insert a carriage return between two long strings getting concatenated so they look like two sentences one after the other. The below code explains how I achieved it.

&string1 = ‘Emplid xyz123 is terminated on 01/01/2008’
&string1 = ‘Emplid abc456 is terminated on 01/02/2008’

&mailString = &String1 | &String2;

/* This concatenation would lead &mailString look as shown below
Emplid xyz123 is terminated on 01/01/2008Emplid abc456 is terminated on 01/02/2008

/* To put a CR/LF (both unix and DOS style linefeed, safe for all platforms), you would change the above line to read like this: */

&mailString = &String1 | char(10) | char (13) |&String2;

/* Now the &mailString will look like as shown below

Emplid xyz123 is terminated on 01/01/2008
Emplid abc456 is terminated on 01/02/2008

Categories: PeopleCode Tags: ,
  1. Shawn Eary
    October 15, 2015 at 7:07 pm

    I appreciate this article, but I think the char(10) | char (13) sequence may be backwards for the more common operating systems. Instead of:
    &mailString = &String1 | char(10) | char (13) |&String2;
    I think you really want
    &mailString = &String1 | char(13) | char (10) |&String2;

    See comment about MS Windows in this thread:

    I understand that some older operating systems *may* put char(13) *after* char(10) but I think char(13) *usually* comes *before* char(10):

  2. Shawn Eary
    November 17, 2015 at 4:54 pm

    I think
    &mailString = &String1 | char(10) | char (13) |&String2;
    should be
    &mailString = &String1 | char(13) | char (10) |&String2;

    For most platforms including MS-DOS:

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: