Entering content frame

Syntax documentation Script Language Locate the document in its SAP Library structure

Use

You can use the scripting language to embed script elements into the content of e-mail templates. As with the UNIX script languages, a grave accent (`) character is used to begin and close the script elements.

The scripting language used in the GP email templates supports checking conditions, basic mathematical functions, using built-in parameters and accessing context parameters. For more information on how to access context parameters, built-in parameters and the built-in process roles, see Replacements.

The basic syntax of the scripting language is described in this documentation.

Basics of the Script Language

General language elements

Syntax

Description

eval(expression)

Evaluates an expression

exists(expression)

Checks the existence of a context variable

write(expression)

Writes its argument into the content of the e-mail

writeln(expression)

Writes its argument into the content of the e-mail and appends a new line to it

fcount(expression)

Reserved, but not used by GP

 

This graphic is explained in the accompanying text

` writeln( " This text will be displayed in the email " )`

 

Flow control elements

Syntax

Description

if (expression) {…} else {…}

 

 

 

 

 

 

 

C like if command (please note the else branch is not optional, but mandatory)

This graphic is explained in the accompanying text

`i = 1;

if( i == 1 ) { `i is 1

` } else { `i is not 1

` };

switch (expression)  {
case expression1: …
  break;
case expressionn: …
default: …
}

 

 

 

 

 

 

 

 

 

 

C like switch command

This graphic is explained in the accompanying text

`i = 1;

while( i < 4 ) {

  switch( i ) {

    case 1: `with break

` break;

    case 2: `no break -> default

`

    default: `the default`

  }

  i = i + 1;

} `

while (expression) {…}

 

 

 

 

 

C like while command

This graphic is explained in the accompanying text

`i = 1;

while( i < 4 ) {writeln(i); i = i + 1; }`

loop

Reserved, but not used by GP

loopidx

Reserved, but not used by GP

stop

Stops processing of the file (HTML template file/plain text file containing the script)

 

String handling functions

Syntax

Description

codejs(string)

Not used by GP

codeurl(string)

Encoding a string into URL encoded string

substr

Returns a substring of the string

len(string)

Returns the length of the string

 

This graphic is explained in the accompanying text

`writeln(  " name@company-emailaddress.com "  );

string2 = codeurl( " name@company-emailaddress.com " );

write( string2 )`

 

Mathematical functions

Syntax

Description

not(number)

Negation

add(number, number)

Addition

sub(number, number)

Subtraction

div(number, number)

Division

mod(number, number)

Mod

mul(number, number)

Multiplication

 

This graphic is explained in the accompanying text

`writeln( mod( 3, 2 ) );`

 

Comparison

Syntax

Description

==

Equal

<

Less than

>

Greater than

<=

Less than or equal

>=

Greater than or equal

 

This graphic is explained in the accompanying text

`i = 1; i2 = 2;

if( i <= i2 ) { ` i < i2

` } else { `i2 > i

` }

i = 2; i2 = 1;

if( i <= i2 ) { ` i < i2

` } else { `i2 > i

` }

i = 2; i2 = 2;

if( i <= i2 ) { ` i <= i2

` } else { `i2 > i

` }

 

 

Leaving content frame