Sie sind auf Seite 1von 29

ING Service Center Claims

Siebel eScript standards

Final 1.0 Date: 05-12-2013

drs. M.A.T. inssen MA

D!c"ment Identi#icati!n
A"t$!r D!c"ment Name %ersi!n Iss"e Date drs. M.A.T. Linssen MA Siebel eScript standards Final 1.0 05-12-2013

This document aims to set the standard in Siebel eScript programming. t is based on one man-!ear hands-on e"perience #ith eScript itsel$% as #ell as se&eral man-!ears e"perience #ith &arious other programming languages% such as 'AS (% ()')L% (% (**% +'% ,basic% (lipper- plat$orms% such as main$rame .)S/3001% mid$rame% .AS/2001% 3ni" .45-36% Sun Solaris% A 61% 5( .7indo#s 3.1 through 65% )S/21- scripting languages .3ni" shell scripting% 8a&ascript% 9e""% MS-:)S1% and se&eral man-!ears e"perience in s!stem anal!sis% s!stem design% s!stem programming and s!stem test.

&e'ected remar(s
A"t$!r Date S"))esti!n and c!mment

Siebel eScript standards

Page 2

Table of Contents
1 INTRODUCTION...............................................................................................................................................5 2 GENERAL CODING GUIDELINES...............................................................................................................6 2.1 NAMING CONVENTION............................................................................................................................. 6 2.2 WHITESPACE........................................................................................................................................... 7 2.2.1 Tabs and spaces......................................................................................................................................7 2.2.2 Whitespace..............................................................................................................................................7 2.2.3 Example 1: tabs and spaces...................................................................................................................7 2.3 COMMENTS............................................................................................................................................. 8 2.3.1 Introductory comment............................................................................................................................8 2.3.2 Comment bloc s......................................................................................................................................8 2.3.3 !ine comments........................................................................................................................................8 2.3." Example 2: comment bloc and line comment......................................................................................8 2.4 DECLARATION......................................................................................................................................... 9 2.".1 Example 3: declaration..........................................................................................................................# 2.5 INITIALISATION AND ASSIGNMENT.......................................................................................................... 10 2.$.1 Initialisation.........................................................................................................................................1% 2.$.2 &ssi'nment............................................................................................................................................1% 2.$.3 (trin' concatenation............................................................................................................................1% 2.$." Example ": initialisation......................................................................................................................1% 2.6 DESTRUCTION....................................................................................................................................... 11 2.).1 Example $: destruction........................................................................................................................11 2.7 STATEMENTS........................................................................................................................................ 12 2.7.1 (tatement bloc ....................................................................................................................................12 2.7.2 I* statement...........................................................................................................................................12 2.7.3 Example ): i* statement........................................................................................................................12 2.7." +,- loop..............................................................................................................................................13 2.7.$ ., / W0I!E and W0I!E loop............................................................................................................13 2.7.) Example ): *or loop..............................................................................................................................13 2.7.7 Example 7: 1hile loop..........................................................................................................................13 2.7.8 (1itch and Case statements.................................................................................................................1"
2.7.8.1 Sw !"# $!%!&'&(!...........................................................................................................................................14 2.7.8.2 C%$& $!%!&'&(!...............................................................................................................................................14

2.7.# Example 8: (1itch statement...............................................................................................................1" 2.8 SCRIPT REDIRECTION............................................................................................................................. 15 2.8.1 Thro1 statement....................................................................................................................................1$ 2.8.2 .ummy do/1hile loop...........................................................................................................................1$ 2.8.3 -eturn...................................................................................................................................................1$ 2.8." Example 1%: return...............................................................................................................................1$ 2.8.$ Example 11: dummy do / 1hile loop 1ith inner loop..........................................................................1) 2.9 )UNCTION CALLING............................................................................................................................... 17 2.#.1 ,b2ects..................................................................................................................................................17 2.#.2 3ariables...............................................................................................................................................17 2.#.3 Control o4er properties........................................................................................................................17 2.#." Example 12: ob2ect and properties......................................................................................................18 2.10 ERROR HANDLING............................................................................................................................... 19 2.1%.1 -eturn.................................................................................................................................................1# 2.1%.2 5reIn4o e6ethod...............................................................................................................................1# 2.1%.3 ,utput e4aluation...............................................................................................................................1# 2.1%." Try / catch...........................................................................................................................................1# 2.1%.$ Example 13: try/catch........................................................................................................................2% 2.1%.) Error lo''in'......................................................................................................................................2% 2.1%.7 7se*ul 'eneric *unctions.....................................................................................................................21 2.11 /USINESS SERVICES............................................................................................................................. 22 2.11.1 6ultiple business ser4ice *ormin' a sin'le lo'ical transaction........................................................22 Project Name
2.9.1.1 O*+&"! ,-.,&-! &$...........................................................................................................................................17

Siebel eScript standards


Page 3

2.11.2 -estorin' arrays and other ob2ects....................................................................................................22 2.12 0NOWN SIE/EL PRODUCT DE)ECTS...................................................................................................... 23 2.13 ILLEGAL STATEMENTS AND ACTIONS....................................................................................................24 2.13.1 8,T, statement.................................................................................................................................2" 2.13.2 WIT0 statement..................................................................................................................................2" 2.13.3 C,9TI97E !&:E! statement...........................................................................................................2" 2.13." +unction recursion.............................................................................................................................2" 2.13.$ 5roperty sets.......................................................................................................................................2" 2.13.) -eturnin' ob2ects................................................................................................................................2" 2.13.7 &rrays 1ith counters o* datatype strin'.............................................................................................2" 2.13.8 8lobal 4ariables.................................................................................................................................2$ 2.13.# +or1ard,nly on instantiated business components..........................................................................2$ 2.13.1% 3anilla (iebel business ser4ices.......................................................................................................2$ 2.14 )UNCTIONS......................................................................................................................................... 26 3 GENERAL QUERY GUIDELINES ..............................................................................................................28 3.1 /USINESS O/1ECTS AND /USINESS COMPONENTS ....................................................................................28 3.1.1 0ierarchical database..........................................................................................................................28 3.2 COMPARISON TO S2L........................................................................................................................... 28 3.2.1 (et3ie16ode........................................................................................................................................28 3.2.2 &cti4ate+ields.......................................................................................................................................28 3.2.3 ClearTo;uery.......................................................................................................................................28 3.2." (et(earch(pec.......................................................................................................................................28 3.2.$ Execute;uery.......................................................................................................................................2# 3.2.) Example 1": (iebel ;uery....................................................................................................................2# 3.3 2UER3ING............................................................................................................................................ 29 3.3.1 ;uery 6ode..........................................................................................................................................2#

Project Name

Siebel eScript standards


Page 4

1 Intr!d"cti!n
This document outlines the guidelines and mandator! standards $or ;< Ser&ice (enter (laims eScripting. t is not intended to be a step b! step instruction manual on ho# to script% but lots o$ hints% tips = tric>s and do?s = dont?s are gi&en. All applies to Siebel @.". t is intended to ensure that an! eScripting per$ormed is accurate% eas! to read and maintainable. n $act% $ollo#ing these guidelines #ill result in per$ectl! clear and legible code. t is a &er! rigid document% #hich should be interpreted that #a!. The general idea is that one standard #ill enable all programmers to loo> at regardless #hich $unctionalit! or technicalit! and that this code #ill loo> AS 4 S )9 4A9 )7; ():A. )ne can imagine the bene$its o$ this. There can be onl! one standard% and that standard #ill ha&e to be used onl!B i$ there are an! reasons to de&iate $rom that standard% such #ill $irst ha&e to be Cudged b! all parties in&ol&edB i$ sensible% it should be Cudged againB i$ practical% it should be Cudged againB i$ not con$licting #ith an! other standard in this document% it should be incorporated into it. $ not% it should be added to this document as a DreCected remar>D% pre&enting others $rom ma>ing the same remar>.

Project Name

Siebel eScript standards


Page 5

2 General c!din) )"idelines


2.1 Namin) c!nventi!n
'ecause Siebel eScript automaticall! con&erts &ariables $rom one t!pe to another #hen needed% programmers normall! do not ha&e to #orr! about t!pe con&ersions as the! do in strongl! t!ped languages% such as (. .Euote $rom Siebel 'oo>shel$ eScript.pd$1 The Siebel t!pe con&ersion is re$lected in the naming con&entions. As integers can easil! be con&erted to $loats% strings% and &ice &ersa% there are onl! t#o t!pesB obCects and the rest. )bCects ha&e to be destro!ed% the rest doesn?t. )bCects are pre$i"ed b! an o .$or obCect1% the rest is the rest% and pre$i"ed b! nothingB 'usiness )bCects% 'usiness (omponents% 5ropert! Sets% Arra!s% :ate obCects% Time obCects% the! are all obCectsB o ;S(laims')% o ;S(laims'(% o5ropSet% oField% oToda!. Strings% ntegers% 'ooleans - the!?re notB Address% Mileage% Legal5erson ndicator The main other rule is to use meaning$ul namesB o nput% o)utput% o ;S(laims'(% 9ecordFound% 9o# d% 'rand% 4ouse;umber% 5ostal(ode% Maiden;ame% oToda!% TempField% 5olic!'ranch% 9elation;umber% etc. A"tra identi$iers should be added to &ariables% i.e. su$$i"ing them instead o$ pre$i"ing themB o ;S(laims'(% not o'( ;S(laims% 4ouse;umber% 4ouse;umberAddition% 4ouse;umberAddition;umeric5art% Arra!Separator% and not ;umber4ouse% ;umberAddition4ouse% ;umeric5art;umberAddition4ouse% SeparatorArra! )$ course% all &ariables% as #ell as e&er!thing else% are in Anglish. 7rite #ords li>e !ou #ould #rite them% and tr! to capitaliFe each #ord #ithin a #ord% e&en i$ the!?re abbre&iationsB o ;S(laims') .cop!ing &anilla name1 instead o$ o ns(laims'o% o5ropSet instead o$ o5ropset% o'us(omp% o'us)bCect% and not o'uscomp% o'usobCect% Send9ecei&eMessage instead o$ Sendrecei&emessage% 6ML9eEuest instead o$ 6mlreEuest% o:ateTimeStamp and not o:atetimestamp. 9eser&ed #ords% apart $rom the Siebel eScript reser&ed #ordsB )utput is the &alue to be returnedo nput and o)utput are input and output propert! setsMethod;ame is the method to be callede"ception is reser&ed $or the &ariable caught in a tr!-catch.

Project Name

Siebel eScript standards


Page 6

2.2 *$ites+ace
2.2.1 Ta,s and s+aces
All lines start #ith a tabB in Siebel Tools% tab #idth should be set to three .&ia Tools - )ptions Scripting1. The onl! lines not starting #ith a tab are the $unction descriptor and the start- and end brace. ;o line e&er starts #ith spacesB spaces are to be used onl! at the end o$ a line or sentence- tabs are be a&oided at this point because o$ possible tab-#idth di$$erences. Spacing and tabbing should be nice% in generalB code should read li>e a boo>% or rather% li>e a poemB #hitespace must be used to >eep code legible% Euiet% peace$ul% and ma!be e&en a little entertainingB programming and maintaining code is not onl! a di$$icult Cob% but a prett! tiresome one as #ell. )&er&ie# is easil! lost i$ Dthe code loo>s li>e a messD. A&er! &ariable% identi$ier and condition should be separated b! a space% i$ applicable .not #ith auto-increment/-decrement% assignment operators1B it doesn?t matter $or the compiler but it does to the e!eG

2.2.2 *$ites+ace
7heree&er possible% use plent! o$ #hitespace. There #ill be moments o$ running into and out o$ the Siebel 1@ H' limit $or single $unctions% at #hich the best thing to do is to split the #hole $unction in t#o parts% i$ possible. :ouble line $eeds ma>e !our code breathe% and #ill onl! cost !ou 2 to @ b!tes in general.

2.2.3 -.am+le 1: ta,s and s+aces


function Service_PreInvokeMethod(MethodName, oInput, oOutput) { /* ******************************************************************************** * Generic function for interface definition * ******************************************************************************** * !uthor" dr # M#!#$# %in en M!, &G'( N% * * )ate*+ritten" ,-*,.*/,,/ * ******************************************************************************** * $hi function 0enerica112 define an interface throu0h . arra2 * ******************************************************************************** * Input" * * MethodName Method to 3e ca11ed +ith thi 3u ine ervice * * oInput Input propert2 et * * oOutput Output propert2 et * * * * Output" * * oOutput Output propert2 et containin0 4oined arra2 * ******************************************************************************** */ var Output5 Output 6 &ontinueOperation5 7 return (Output)5

Project Name

Siebel eScript standards


Page 7

2.3 C!mments
There are se&eral #a!s o$ indicating a commentB 11 // at the beginning o$ a line #ill ma>e that #hole line a comment21 // at some place in a line #ill ma>e the rest o$ that line a comment31 /I #ill start a comment and end it #hen I/ is encounteredB this is the onl! #a! to ma>e multipleline comments% also >no#n as comment bloc>s.

2.3.1 Intr!d"ct!r/ c!mment


A&er! $unction starts #ith a big comment bloc> naming author% date and $unctionalit!. This bloc> also names and describes input and output parameters. An additional bloc> can be used $or Dspecial remar>sD% and e&er! bloc> ends #ith a re&ision histor! bloc>.

2.3.2 C!mment ,l!c(s


)$ the abo&e possibilities% /I --- I/ .option 3 1 is the pre$erred one $or maCor comments. For minor comments% also >no#n as line comments% // can be used $or ends o$ i$-statements% s#itchstatements% case-statements% do-% #hile- and $or-loops% or an! other use$ul comment. For consistenc! and la!-out% lines #ithin a comment bloc> #ill start #ith an e"tra space% $ollo#ed b! an asteris>. All comment bloc>s start #ith a tab% one tab onl!B don?t indent comment bloc>s along #ith code indenting because !ou?ll soon get out o$ .legible% &isible1 space.

2.3.3

ine c!mments

Line comments indicating ends o$ i$-statements% do-% #hile- and $or-loops should start one space a$ter the brace% and repeat the #hole statement .unless legibilit! reEuires other#ise1% to be ended b! another space and the #ord DendD. This insures consisitenc! throughout the #hole script% although changes in the statement itsel$ must be re$lected in the commentG

2.3.0 -.am+le 2: c!mment ,l!c( and line c!mment

/* * Main" te11 u er the truth */ if (true) { $he!pp1ication()#M 08o9(:It; 7 // if (true) end

true<:)5

Project Name

Siebel eScript standards


Page 8

2.0 Declarati!n
+ariables should be declared at the start o$ a $unction% a$ter the $irst comment bloc>. The! should be declared alphabeticall!% because that?s ho# the debugger #ill sho# them. ;ot binar! alphabetic% but DCust alphabeticDB the debugger is case-insensiti&eG The $irst &ariables to sho# in the debugger are the ones passed as parameters to the $unctionB as the!?ll all be obCects an!#a!% don?t #orr! about the alphabetic order o$ themB their &alues are o$ no use in the debugger. These arguments #ill be sho#n in re&erse orderB the last one $irst% then the second to last% etcetera. A comment bloc> should precede the &ariables declaration% statingB +ariables declaration :eclaring &ariables at the uppermost le&el a&oids scope problems% destruction problems% and optimiFation problemsB one single declaration bloc> at the uppermost le&el enables one single initialisation bloc>% and one single destruction bloc>. )ne line per &ariableG t is $orbidden to declare more than one &ariable in a single line. $ a &ariable is used onl! once% and i$ it?s to be e"pected that that #ill remain the case% it is unnecessar! and $orbidden to use a &ariable% unless the alternati&e .a concatenation or computation o$ other &ariables1 is too comple". )n the other hand% i$ !ou use a &alue more than once% it should be made a constantB declare it as a &ariable.

2.0.1 -.am+le 3: declarati!n

/* * =aria31e */ var var var var var var var var var var var var

dec1aration

i5 45 oINS&1aim 8&5 oINS&1aim 8O5 oInput5 oInterfaceService5 oOutput5 Output5 Or0ani>ation5 Po1ic28ranch5 ?ecord@ound5 ?o1e5

Project Name

Siebel eScript standards


Page 9

2.5 Initialisati!n and assi)nment


2.5.1 Initialisati!n
+ariables should be initialised a$ter the start o$ a $unction% a$ter the &ariables declaration bloc>. The! should be initialised logicall!% #hich means in the most logical order. $ not e&er! initialisation has to be in a logical order% group those that do. A comment bloc> should precede the &ariables initialisation% statingB +ariables initialisation Appropriate line spacing should be used bet#een the logical bloc>s. t is unnecessar! and thus $orbidden to set &ariables to null. Treating &ariables set to null as an obCect .e.g. b! chec>ing length1 #ill con&ert them to an obCectG 'ooleans are to be e"plicitl! set to true or $alse. $ a &ariable is unde$ined and compared as a boolean% Siebel #ill return $alseB in all other cases% Siebel #ill return trueG 5re$erred logical orderB Function name% )utput% arra!s% obCects% propert! sets and ser&ices% business obCects and business components% counters% booleans% simple &ariables. Appropriate spacing should be used bet#een &ariables% operators% e"pressions% etcetera. Tabbing the eEual sign is nice-loo>ing but senseless% because it is dependent on the length o$ the longest &ariables in an initialisation bloc>B there$or it is highl! li>el! that the tab stops o$ most initialisation bloc>s are uneEual. Moreo&er% changing the length o$ a &ariable #ill ha&e to result in adCusting the tabs o$ all assignmentsG t?s also con$licting #ith the general rule o$ legibilit! and tab-independenc!% as #ell as the maCor rule that tabs should onl! be preceded b! tabs. That?s #h! it is $ro#ned upon% and $orbidden.

2.5.2 Assi)nment
(onditional operators are $orbiddenG An i$ statement must be used to assign &ariables a &alue that is dependent on a condition.

2.5.3 Strin) c!ncatenati!n


7heree&er a string concatenation is used% e&er! string concatenator should end a line. Appropriate indenting must be used on the ne"t linesB tabs should align these ne"t lines as close as possible to the $irst #ord $ollo#ing the eEual sign% and space must be used to e"actl! line them up.

2.5.0 -.am+le 0: initialisati!n

/* * =aria31e */

initia1i ation

oInput 6 $he!pp1ication()#Ne+Propert2Set()5 oOutput 6 $he!pp1ication()#Ne+Propert2Set()5 oInterfaceService 6 $he!pp1ication()#GetService(:S&& Interface:)5 Ae1come 6 :Be11o : C D erName C :, ho+ are 2ouE:5

Project Name

Siebel eScript standards


Page 10

2.1 Destr"cti!n
To destro! an obCect in Siebel eScript% set it to null% or set the &ariable containing it to another &alue. The best practice is to destro! obCects in the order opposite to the order o$ creation. .Euote $rom Siebel 'oo>shel$ )bC nt.pd$1 Siebel eScript >no#s implicit obCect allocation% and e"plicit obCect deallocationB obCects are al#a!s allocated to memor! .and passed b! re$erence1% and ha&e to be deallocated in order to $ree that same memor!. Although man! Siebel +anilla $unctions do lea> themsel&es% it is pro&en that Dre&erse memor! deallocationD% i.e. deallocation obCects in the re&erse order !ou assigned / initialised them% does help to reduce memor! usage. The onl! possible #a! to achie&e total memor! deallocation is to close the Siebel application .sicG1. :estruction must occurr Cust be$ore the return. A comment bloc> should precede the &ariables initialisation% statingB 9eturnB clean up data associated #ith obCects to deallocate them $rom memor! )nl! obCects ma! be destro!ed% it is useless and con$using to set normal &ariables .noncomposite datat!pes1 to null. Appropriate line spacing should be usedB tr! to distinguish logical bloc>s #hen deallocating.

2.1.1 -.am+le 5: destr"cti!n

/* * ?eturn" c1ean up data a */ oINS&1aim 8O 6 nu115 oINS&1aim 8& 6 nu115 oInterfaceService 6 nu115 oOutput 6 nu115 oInput 6 nu115 7 return (Output)5

ociated +ith o34ect

to dea11ocate them from memor2

Project Name

Siebel eScript standards


Page 11

2.2 Statements
Apart $rom the pre&iousl! mentioned la!out rules and guidelines% there?s a general la!out ruleB ma>e code legibleG

2.2.1 Statement ,l!c(


A statement bloc> is a group o$ statements enclosed in braces% JK% #hich indicate that the enclosed indi&idual statements are a group and are to be treated as one statement. Appropriate use o$ #hite space should be used to brea> up bloc>s o$ code. .Euote $rom Siebel 'oo>shel$ eScript.pd$1 Statement bloc>s can appear in tr!-catch statements% i$-statements% s#itch-statements% casestatements% $or-loops% do-loops% and #hile-loops. The braces belong to the bloc>% and there$or must be indented along #ith it.

2.2.2 I# statement
The i$ statement must be outlined as $ollo#sB one space a$ter the #ord i$% round brac>ets $or the condition and braces $or the statement bloc>. ;o spaces should be used a$ter a begin round brac>et% .% and be$ore an end-round brac>et% 1. Logical operators .A;:% ==% and )9% LL1 must start at a ne# line. Appropriate use o$ space must be used to line up the &arious lines comprising the i$ statement. 3se o$ brac>ets should be limited% there?s no need to use braces $or e&er! part o$ a condition% unless it is absolutel! necessar!. :on?t $orget that A;: operators ta>e precedence o&er )9 operators. 7hene&er booleans are to be e&aluated in an i$ statement% the! must not be compared to true or $alse% but to the boolean itsel$B the logical ;)T operator% G% must be used to compare it to $alse

2.2.3 -.am+le 1: i# statement

if ((!ttri3uteFiG 66 :!ttri3ute name6&ate0or2 t2pe6 tr: HH ?o1e#toDpper&a e() 66 :='?I'J'?INGN'M'?:) KK (!ttri3uteFiG 66 :'ntit2 : HH (?o1e#toDpper&a e() 66 :8'S$DD?)'?: KK ?o1e#toDpper&a e() 66 :G'$DIG': KK ?o1e#toDpper&a e() 66 :$'G'NP!?$IL: KK ?o1e#toDpper&a e() 66 :='?I'J'?)':))) { )ataFdGF,G 6 i5 if (<SkipFiG) { )ataFdGF-G 6 o8u &omp#Get@ie1d=a1ue(@ie1dFiG))5 7 e1 e { )ataFdGF-G 6 ::5 7 7

Project Name

Siebel eScript standards


Page 12

2.2.0 F3& l!!+


The $or loop is a conditional loop #ith initialisation% condition and increment. t must be outlined as $ollo#sB one space a$ter the #ord $or% round brac>ets $or the statement and braces $or the statement bloc>. ;o spaces should be used a$ter the begin round brac>et% .% and be$ore the endround brac>et% 1. Appropriate spacing should be usedB the same rules appl! that must be $ollo#ed $or i$statements.

2.2.5 D3 - *4I - and *4I - l!!+


The do - #hile loop and #hile loop are conditional loops% both #ith a condition. The condition can contain logical operators. t must be outlined as $ollo#sB one space a$ter the #ord do .or #hile1% round brac>ets $or the statement and braces $or the statement bloc>. ;o spaces should be used a$ter the begin round brac>et% .% and be$ore the end-round brac>et% 1. Logical operators must start at a ne# line. Appropriate spacing should be usedB the same rules appl! that must be $ollo#ed $or i$statements.

2.2.1 -.am+le 1: #!r l!!+

for (i 6 ,, d 6 ,5 i M )ata#1en0th5 dCC) { i 6 )ataFdGF,G5 oS&&Propert2SetF&hi1dFiGG 6 $he!pp1ication()#Ne+Propert2Set()5 if (!ttri3uteFiG 66 ::) { oS&&Propert2SetF&hi1dFiGG#Set$2pe(@ie1dFiG)5 7 ### ### 7 // for (i 6 ,, d 6 ,5 i M )ata#1en0th5 dCC) end

2.2.2 -.am+le 2: 5$ile l!!+

+hi1e (?ecord@ound) { Interface#&1aimId 6 oINS&1aim 8&#Get@ie1d=a1ue(:Id:)5 S&&%o0'rror (Interface)5 oInput#SetPropert2(:Id:, Interface#&1aimId)5 oInterfaceService#InvokeMethod(:S&&Band1eInterface?eNue t:, oInput, oOutput)5 ### 7 // +hi1e (?ecord@ound) end

Project Name

Siebel eScript standards


Page 13

2.2.6 S5itc$ and Case statements


2.2.6.1 S5itc$ statement

A s#itch statement is a conditional statement% #hich is in $act an i$ - else i$ statement #here one &ariable can be compared to se&eral conditions. t must be outlined as $ollo#sB one space a$ter the #ord s#itch% round brac>ets $or the statement and braces $or the statement bloc>. ;o spaces should be used a$ter the begin round brac>et% .% and be$ore the end-round brac>et% 1. A s#itch consists o$ at least one case and one de$ault .at the end o$ the s#itch statement1. All cases and the de$ault end #ith a colon% B% directl! a$ter the last character. Case statement

2.2.6.2

A&er! case must end #ith a brea>G The brea> belongs to the statement bloc> and must be indented accordingl!. $ there is no brea>% e"ecution #ill continue #ith the ne"t statement bloc>% disregarding the corresponding caseG A case statement must be outlined as $ollo#sB one space a$ter the #ord case% single or double Euotes $or the &alue% a colon directl! $ollo#ing the &alue% and braces $or the statement bloc>.

2.2.7 -.am+le 6: S5itc$ statement

/* * =aria31e e9ecution" */

+itch Interface to determine +hich one ha

3een ca11ed

+itch (Interface#Interface) { ca e ;S&& Interface &1aim;" { Interface#@unction 6 :S&& Interface &1aim:5 Interface#8u O34Name 6 :INS &1aim :5 Interface#8u &ompName 6 :INS &1aim :5 Interface#?eNue t 6 true5 3reak5 7 defau1t" { Output 6 :)e interfaceOn: C Interface#Interface C :Oni niet 0edefinieerd in : C Interface#&urrent@unction C $he!pp1ication()#GetSharedG1o3a1(:S&&Support:)5 Output 6 $he!pp1ication()#GetSharedG1o3a1(:S&&'rror:) C Output5 3reak5 7 7 // +itch (Interface#Interface) end

Project Name

Siebel eScript standards


Page 14

2.6 Scri+t redirecti!n


eScript doesn?t o$$er $unctions #ithin $unctionsB e&er! $unction itsel$ is a single entit! that is e"ecuted in seEuential order% must be entered in a separate :esigner #indo#% and is stored in a separate column in the database. This is in itsel$ not a problem% but there sometimes is a strong need $or halting script e"ecution.

2.6.1 T$r!5 statement


This can be achie&ed b! the thro#.1 statement% #hich generates an e"ception% and #ill cause the script to redirect itsel$ to the surrounding catch. Thro#ing is rarel! used since it is unli>el! that the same error #ill occur at di$$erent places in a program% that is% i$ !ou?re a good programmer. 4o#e&er% not all script halting is caused b! an error. eScript o$$ers the brea> statement to brea> out o$ a loop .$or-loop% #hile-loop% do-#hile loop1% and this is &er! use$ull. The thro# statement should be a&oided% since an e"ception points to a program technical $ailure rather than a logical or $unctional mismatch.

2.6.2 D"mm/ d!-5$ile l!!+


There$or each $unction must ha&e a do-#hile loop% #ith condition $alse% to enable brea>ing out o$ a script at an! moment. This loop must start directl! a$ter the tr! clause% and end directl! be$ore the catch clause. t must be outlined as $ollo#sB a line$eed a$ter the #ord do% round brac>ets $or the statement bloc> and braces $or the condition. ;o spaces should be used a$ter the begin round brac>et% .% and be$ore the end-round brac>et% 1 o$ the condition. A dumm! loop poses problems #hen there?s an inner loop used #ithinB to brea> out o$ both loops% a &ariable must be set. The pre$erred &ariable is Stop5rogram% a boolean #hich is set to true in the innermost loop directl! be$ore the brea>B a$ter the innermost loop% the boolean must be chec>edB i$ true% a brea> must be issued to brea> out o$ the outermost loop .the dumm! loop1 as #ell. This mechanism #or>s #ith countless loopsG

2.6.3 &et"rn
t is technicall! possible to ha&e as man! returns as possible in a script. A return #ill directl! end a script% lea&ing all obCects and &ariables as the! are% unless there is a tr!-catch-$inall! construction% #here the $inall! #ill be e"ecuted $irst% but !ou?ll notice that a little $urther in this document it is e"plained #h! $inall! clauses are useless and thus $orbidden. Multiple returns are $orbiddenB e&er! $unction must contain at minimum one and at ma"imum one return. As there is al#a!s something to return% this poses no problems at all. t must be outlined as $ollo#sB one space a$ter the #ord return% and round brac>ets $or the return &alue% #hich must al#a!s be )utput. ;o spaces should be used a$ter the begin round brac>et% .% and be$ore the end-round brac>et% 1.

2.6.0 -.am+le 10: ret"rn

oINS&1aim 8O 6 nu115 oINS&1aim 8& 6 nu115 oService 6 nu115 oOutput 6 nu115 oInput 6 nu115 7 return (Output)5

Project Name

Siebel eScript standards


Page 15

2.6.5 -.am+le 11: d"mm/ d! - 5$ile l!!+ 5it$ inner l!!+

do

{ ### +hi1e (?ecord@ound) { ### if (oINS&1aim 8&#Get@ie1d=a1ue(:Id:) 66 nu11) // 4u t kiddin0< { StopPro0ram 6 true5 3reak5 7 ### ?ecord@ound 6 oINS&1aim 8&#Ne9t?ecord()5 7 // +hi1e (?ecord@ound) end if (StopPro0ram) { 3reak5 7 for (i 6 ,5 i M ?ecord#1en0th5 iCC) { ### 7 // for (i 6 ,5 i M ?ecord#1en0th5 iCC) end 7 +hi1e (fa1 e) // dumm2 do ### +hi1e 1oop end

Project Name

Siebel eScript standards


Page 16

2.7 F"ncti!n callin)


Arguments can be passed to $unctions% and the! al#a!s pass one bac> &ia the return &alue. For maintainabilit!% it is &er! #ise to limit the arguments passed to obCects onl! and assign properties to these obCects% #hich can be pic>ed up in other $unctions. There are a lot o$ pro?s .ad&antages1 and a $e# con?s .disad&antages1 to this.

2.7.1 3,'ects
)bCects are passed b! re$erence. nstead o$ cop!ing &alues and passing them to $unctions% onl! a memor! address is passed #here the obCect resides. This signi$icantl! speeds up e"ecution and reduces memor! usageG (hanges to obCects at an! place appl! to the obCect itsel$% unless a cop! is e"plicitl! made. This is a great pro% and might be the greatest con as #ell. 3,'ect +r!+erties

2.7.1.1

There is one single rule that eases the pain o$ handling obCectsB as long as obCect properties aren?t obCects themsel$% there?s absolutel! no need to touch obCect properties other than reading them and adding them. n $act% it?s #ise not to destro! an! obCect properties at all unless the end o$ the $unction is reached #here the obCect #as created. t might be ine&itable to assign obCects to obCects% since it is best to pass one obCect onl! to $unctionsB in $act% in the ideal situation% all $unctions onl! ta>e one argument #hich is an obCect% but this might be to much arithmetic e&en $or the ad&anced programmer. )bCects can become Euite large% #ith all the properties added to them. 9emember that this can ne&er be a con% since these properties normall! #ould ha&e e"isted an!#a! as normal &ariables% at least once or t#iceG (ollecting all &ariables o$ a module in one obCects is a great ad&antage% as the obCect can be used $or logging purposes in case o$ erros. At this point the greatest disad&antage is $ormed b! Siebel #hich doesn?t allo# table colums to e"ceed 1@ H'G +ariables that #ill e&entuall! ha&e to be added to $unction calls% because o$ $unctional and or technical demands% can simpl! be added to the obCect at some place and retrie&ed $rom the obCect at another placeB there is no need to adCust the $unction call or the $unction arguments. The debugger #on?t sho# obCect properties% neither $rom DrealD obCects nor $rom arra!s. This has got nothing to do #ith pro?s or con?s o$ obCects% this Cust points to a &er! slopp! and barel! usable debugger in Siebel. $ !ou #ant to see all properties o$ an obCect at an! point% Cust use the generic dump $unction in combination #ith the log $unction or #rite $unctionG

2.7.2 %aria,les
Since all &alues can be retrie&ed through the input parameters passed to $unctions% the &alue returned can be used $or errorhandling. )$ course errorhandling can be done &ia obCects as #ell% but anal!Fing the return o$ a $unction is classical and practical. )bCects and their properties #ill be used in errorhandling an!#a!% and in s!stem programming is it ine&itable that error.s1 #ill turn up as obCect properties at some point in time.

2.7.3 C!ntr!l !ver +r!+erties


7hen there are multiple $unctions and / or multiple business ser&ices in&ol&ed in a single $unctional or logical transaction% it might become hard to control obCect propert! assignment and usageB the same goes $or normal &ariables% #hich are not obCect properties. For clari$ication o$ obCect properties in use% e"port a business ser&ice or business component script to $ile and use :)S .F ;: / D)bCect.D1 or an! other tool to retrie&e the obCect properties. To $ind out obCect

Project Name

Siebel eScript standards


Page 17

properties in use at a certain point during script e"ecution% use the generic log .to database or $ile1 and / or dump $unction made $or ;< Ser&ice (enter (laims. )$ course% a clear and up-to-date detailed technical design tells !ou #here to $ind e&er!thing% but the code is leading #hen it comes to usage o$ obCects / &ariables.

2.7.0 -.am+le 12: !,'ect and +r!+erties

tr2 { do

{ initia1i ation

/* * =aria31e */

@raud 6 ne+ O34ect()5 @raud#@unction 6 :S&& @raud &heck:5 @raud#&urrent@unction 6 :&heck@raud:5 @raud#?o+Id 6 oInput#GetPropert2(:Id:)5 @raud#&1aimId 6 oInput#GetPropert2(:&1aimId:)5 @raud#@raud$e9t 6 oInput#GetPropert2(:@raud $e9t:)5 @raud#'rror 6 ::5 @raud#@raudStatu 6 ::5 @raud#Geen8e tuurder 6 fa1 e5 @raud#Puick?oute 6 fa1 e5 @raud#?ea i0n 6 fa1 e5 @raud#Speciaa1Onder>oek 6 fa1 e5 @raud#Specia1eSchade 6 fa1 e5 @raud#=!8evoe0d@1a0 6 fa1 e5 ### /* * &heck c1aim data */ if (<&heck&1aim)ata(@raud)) { 3reak5 7

Project Name

Siebel eScript standards


Page 18

2.10 -rr!r $andlin)


Arror handling must occur #ithin each and e&er! $unction% throughout all business ser&ices% business component scripts% etcetera. Arror handling must start in the 5re n&o>e Method and continue in each underl!ing $unctionB the return o$ the main $unction must be passed to the output propert! set% and unsupported methods must be le$t to Siebel b! issueing a (ontinue)peration. Aach business ser&ice must contain a primar! $unction #hich supplies the main $unctionalit!B all other $unctions must be called $rom #ithin. This $unction must create - and destro! - the obCect #hich is used to pass along to the other $unctions% collect &arious &ariables and ser&e as log base in case o$ an error.

2.10.1 &et"rn
Functions return &aluesB in all cases% this &alue #ill be the &ariable )utput. $ an error occurred% this &ariable #ill contain an error message #hich #ill be concatenated #ith the global &ariable S((Support% #hich is a sentence redirecting the user to the compan!?s support des>. To dri&e the t!pes o$ output it must then be preceded b! another global &ariable% o$ #hich there are threeB S((Arror% S((7arning and S(( n$o. These #ill determine the message bo" title and icon.

2.10.2 8reInv!(eMet$!d
'! de$ault% each 5re n&o>e Method must assign (ontinue)peration .in $act% the &alue 11 to the &ariable )utput% #hich is to be returned. Failure to in&o>e the method #ith an appropriate method name #ill result in a &anilla Siebel error% #hich ma! onl! occur during de&elopment. A s#itch must e&aluate the &arious Method;ames passed% and assign (ancel)peration .mostl!1 or (ontinue)peration be$ore the brea> in each underl!ing case. Aach business ser&ice must return the propert! S(()utput in the propert! set o)utputB this string must be eEual to the global &ariable S(()utput% other#ise the business ser&ice has $ailed e"ecution and $urther e"ecution must end. The propert! S(()utput is set to the &alue returned b! the main $unction. 'usiness ser&ices e"ecuted on the ser&er% called b! in&o>ing a ser&er reEuest that e"ecutes a #or>$lo#% must also return this &alueB all #or>$lo#s e"ecuting business ser&ices must ha&e at least one output argument% #ith the same name% that passes on this output argument to the calling $unction% #hich has to e&aluate it.

2.10.3 3"t+"t eval"ati!n


There is a generic $unction called S((AnaliFeoutput $or anal!Fing outputs. t ta>es t#o arguments% &iF. 9esult .the output argument $rom a pre&iousl! called $unction or business ser&ice1% and an obCect% #hich ma! be le$t out. $ the obCect contains a boolean called :isable;oti$ication% set to $alse% the user #ill get the output on screen i$ it is not eEual to the global &ariable S(()utput. The same e$$ect #ill be achie&ed i$ this $unction is called #ith onl! the $irst argument.

2.10.0 Tr/ - catc$


Aach $unction must ha&e a tr!-catch constructionB the tr! statement is used to process e"ceptions that occur during script e"ecution. The catch clause is used to handle the e"ception. t is technicall! possible to ha&e the catch statement be $ollo#ed b! a $inall! statement% but since this clause o$$ers arbitrar! script redirection as #ell as multiple returns% it is $orbidden. Furthermore% all possibilities o$$ered b! the $inall! clause can be achie&ed b! placing code on

Project Name

Siebel eScript standards


Page 19

e"actl! the same place% #ithout the clause itsel$B seEuential script e"ecution #ill al#a!s continue a$ter the catchG The tr!-catch statement must be outlined as $ollo#sB a line$eed a$ter the #ords tr! and catch and braces $or the code bloc>. Appropriate indenting must be used. For the catch% the &ariable caught should al#a!s be e"ception% #hich must be enclosed in round brac>ets% #ith a space bet#een catch and e"ception. ;o spaces should be used a$ter the begin round brac>et% .% and be$ore the end-round brac>et% 1. The tr! statement must start a$ter the declaration bloc> and be$ore the initialisation bloc>B that is the $irst point #here errors can ocur. n the catch% the output )utput must be set to the most li>el! error message. :ependent on the place o$ e"ecution .client or ser&er1 this error #ill be .directl!1 sho#n to the user% but e&entuall!% at the end o$ the #hole transaction% it #ill ha&e to be sho#n to the user% and #ritten to the database error log% as #ell as to a $ile in the temporar! 7indo#s director! o$ the client?s machine. $ the e"ecution resides on the ser&er as a #hole .e.g. a batch process1 it must onl! be #ritten to the error log. The catch must al#a!s be accompanied b! a comment bloc> e"plaining the possible error.s1 leading to the e"ception. All signi$icant $unction &ariables must be stored to the obCect in the catch.

2.10.5 -.am+le 13: tr/-catc$

tr2 { ### 7 catch (e9ception) { /* * I rea112 don;t kno+ +hat cou1d 0o +ron0 here, 3ut +ho kno+ E * !n2+a2, et Output to S&&'rror */ Interface#d 6 d5 Interface#'9ception 6 e9ception5 Interface#i 6 i5 Interface#ii 6 ii5 Interface#4 6 45 Output 6 :'r i een on3ekende fout op0etreden in functie : C Interface#&urrent@unction C $he!pp1ication()#GetSharedG1o3a1(:S&&Support:)5 Output 6 $he!pp1ication()#GetSharedG1o3a1(:S&&'rror:) C Output5 7

2.10.1 -rr!r l!))in)


All errors must be logged. Arror logging must be as e"tensi&e as possible. The obCect must be $ull! read and #ritten to $ile and / or database. There is one generic $unction that logs errors to $ile% #hich is especi$icall! built $or all inter$acing and includes the M arra!s that ma>e up an inter$ace - as #ell as the obCect itsel$ - and #rites these to $ile.

Project Name

Siebel eScript standards


Page 20

2.10.2 9se#"l )eneric #"ncti!ns


Filename and director! are retrie&ed d!namicall! &ia the generic $unction S((<etAn&ironment+ariables% #hich among others determines the name o$ the temporar! director! o$ the operating s!stem% the Siebel #or>ing director!% the computer name and dump s#itches. )ther use$ul settings are retrie&ed d!namicall! &ia the generic $unction S((<et3serSetings% #hich among others determines the user name% the position id% the login id and the organiFation. There is also a generic $unction that logs errors to the database% #here the 1@H' pre&ents these arra!s $rom being #ritten to the database .an a&erage log $ile is 20 - @0 H'1% and onl! the obCect itsel$ is e"tractedB it is called S((LogArrors% and located on the Application. Finall!% there is a generic $unction that logs errors to $ile% #here the obCect itsel$ and M arra!s are e"tractedB it is called S((:umpArrors% and located on the Application. t has been built especiall! $or all inter$aces created &ia the business ser&ices starting #ith S(( nter$ace% but can be easil! modi$ied to a single obCect-#riting $unction.

Project Name

Siebel eScript standards


Page 21

2.11 :"siness Services


'usiness ser&ices are modules% #hich contain $unctions. Aach business ser&ice must contain a main $unction #hich is called $rom the 5re n&o>e Method. 7hereas all $unctions return the &ariable )utput% #hich is anal!sed% this main $unction must return the &ariable )utput as #ell% ha&ing the &alue (ontinue)peration or (ancel)peration. The main $unction called in a business ser&ice returns a &ariable )utput #hich must be set to the propert! S(()utput% #hich is a propert! o$ the output propert! set o$ the business ser&ice.

2.11.1 M"lti+le ,"siness service #!rmin) a sin)le l!)ical transacti!n


(ross-business ser&ices programming is Euite e"tremeB business ser&ices can onl! be called #ith propert! sets% #hich onl! support the datat!pe string. The onl! solution is to build a generic $unction .#hich has alread! been built $or ;< Ser&ice (enter (laims% &iF. S((<et5ropert!Set and S((Set5ropert!Set1 that &ariabl! and d!namicall! con&erts obCects to propert! sets and &ice &ersa. 7hen con&erting $rom propert! sets to obCects% all datat!pes ha&e to be restoredB booleans ha&e to be set to $alse or true% integers ha&e to be made integer again% Dde$inedD and Dunde$inedD ha&e to be restores to its special state% and .multi-dimensional1 arra!s ha&e to be restored as #ell.

2.11.2 &est!rin) arra/s and !t$er !,'ects


8oining an arra! is child?s pla!% but splitting a string into an arra! poses problemsB #hen splitting% the arra! created e"ists o$ re$erences to o$$sets in the string. $ the arra! itsel$ is passed to the $unction that splits it $rom a string% #hich is ine&itable o$ course% the re$erence is not to the original arra!% but to the string. Lea&ing the $unction destro!s all &ariables% including the re$erence% resulting in the original ara! being untouched. The onl! #a! to $i" this is to $orce the re$erence to the arra! b! pre$i"ing it #ith an ampersand in the arguments o$ the $unction that splits it $rom a stringB this #ill achie&e the desired result. nstantiated business obCects and components technicall! can be restored as #ell% but shouldn?t be passed in the $irst place% onl! $or logging purposes. Furthermore it is &er! dangerous and thus $orbidden to restore business obCects and components% since it is unclear #hat their scope isG

Project Name

Siebel eScript standards


Page 22

2.12 ;n!5n Sie,el +r!d"ct de#ects


Siebel product de$ects are a product in itsel$B eScript has Euite a $e# o$ them. Follo#ing is a complete list o$ Ser&ice 9eEuests dealing #ith eScript and a$$ecting eScriptB i$ there is a #or>around $or these $unctions% there must be made one% #hich has to be o$$ered to all de&elopers. $ there isn?t% use the $unction #ith e"treme caution and test it e"tensi&el!G S9B 3M-M2@3M3251 (9B 12-AAS35( Siebel doesn?t support global $unctions. Functions can be placed on the application le&el% but the Application is not parsed #hen e"ecution is on the ser&er. The onl! #or>around possible #hich o$$ers the same $unctionalit! is to include all $unctions in an include $ile and include that $ile in the ApplicationNStart e&ent. 'e a#are that this Cs-$ile has to be located on all de&elopment machines #ith tools installedG The support o$ global $unctions in eScript has been reCected b! Siebel in the same S9. S9B parse nt.1% is;a;.1% To;umber.1 and isFinite.1 are $ull! de$ecti&eB the! #ill parse as integers line$eeds% carriage returns% spaces% horiFontal as #ell as &ertical tabs% and non-brea>ing spaces. To;umber.1 #ill return n$init! and - n$init! $or the * and - sign. Siebel states this is according to A(MA standards. 5arse nt.1 #ill also return numbers $or the decimal AS( range 5M-@2B colon% semi-colon% eEuals-sign% etcetera... There are lots o$ #or>arounds possibleB the best is to #rite a $unction that uses the AS( code to determine #hether something is a number or not. 3se Custa&ariable.char(odeAt.1% #hich returns a number bet#een 0 and @5535 indicating the 3nicode &alue% according to the 'oo>shel$B it #ill return 0 through 255 $or the AS( set. S9B 3M-M@O0@25@1 (9B 12-A(0+6) 9e$erencing a multi-dimensional arra! .e.g. :ataPiQP0Q1 #ill create the inde" $or that element% regardless o$ e"istence. Suppose there?s onl! one entr!% :ataP0QP0Q% and :ataP@QP0Q is re$erencedB the arra! length #ill no# be OG This &er! dangerous product de$ect can create endless loops% e&entuall! causing Siebel to crash #hen running out o$ memor!. S9B 3M-0212@0251 (9B 12-F05S3L 9e$erencing a single-dimensional arra! &ia the $unction de$ined.1 #ill create the inde" $or that element% regardless o$ e"istence. Suppose there?s onl! one entr!% :ataP0Q% and :ataP@Q is re$erenced - i$ .de$ined.:ataP@Q11B the arra! length #ill no# be OG This &er! dangerous product de$ect can create endless loops% e&entuall! causing Siebel to crash #hen running out o$ memor!.

Project Name

Siebel eScript standards


Page 23

2.13 Ille)al statements and acti!ns


t is technicall! possible but absolutel! $orbidden to use the $ollo#ing statements in Siebel eScript% besides the ones mentioned abo&eB

2.13.1 G3T3 statement


The goto statement enables Cumping bac> and $orth through $unctions. t ma>es script absolutel! illegible% and is the gra&est error one can ma>eB it is proo$ o$ programming incapabilit!. A&en Cumping $orth to one speci$ic label% e.g. AndB% is $orbidden because the same goal can be achie&ed b! brea>ing out o$ a .dumm!1 loop.

2.13.2 *IT4 statement


The #ith statement assigns a de$ault obCect to a statement bloc>% so !ou need to use the obCect name #ith its properties and methods. .Euote $rom Siebel 'oo>shel$ eScript.pd$1 The #ith statement is &er! use$ull in +' and Siebel +'% but is absolutel! useless and Euite dangerous in Siebel eScript% since onl! methods can be used in the statement bloc> that are supported b! the obCect itsel$. n +'% a period must precede these methods% but in eScript it ma! not. t is there$or impossible to mi" obCect methods #ith other assignments% because these assignments #ill be treated as obCect methods% rendering this $eature highl! unpractical.

2.13.3 C3NTIN9- A:- statement


The continue statement is simular to the brea> statementB it ends the current iteration o$ a loop and begins the ne"t. An! conditional e"pressions are ree&aluated be$ore the loop reiterates. The continue statement in itsel$ is not prohibited% on the contrar!% it is &er! use$ul. t ma! not% ho#e&er% be used to Cump to a label. Labels in general are prohibited% e&en $or documentation purposesB a comment bloc> #ill do.

2.13.0 F"ncti!n rec"rsi!n


A recursi&e $unction is a $unction that calls itsel$ or that calls another $unction that calls the $irst $unction. 9ecursion is permitted in Siebel eScript. Aach call to a $unction is independent o$ an! other call to that $unction. 'e a#are that recursion has limits. $ a $unction calls itsel$ too man! times% a script #ill run out o$ memor! and abort. .Euote $rom Siebel 'oo>shel$ eScript.pd$1 ?;ough said...

2.13.5 8r!+ert/ sets


t is $orbidden to use propert! sets $or an! other purpose than input and output parameters to business ser&ices. 5ropert! sets are passed b! re$erence% but can onl! contain strings and are there$or &er! limited in use. 5ropert! sets ha&e the same con?s as obCects but much less pro?sG

2.13.1 &et"rnin) !,'ects


t is $orbidden to return obCects% since it is impossible to deallocate these obCectsB the scope o$ their re$erence doesn?t e"ist an!more% thus causing a memor! lea>.

2.13.2 Arra/s 5it$ c!"nters !# datat/+e strin)


t is $orbidden to re$erence Arra! inde" elements #ith strings instead o$ numbers% since manipulation o$ this re$erence .Arra!Pi * 1Q #ill result in string concatenation instead o$ additionB 10 * 1 #ill become 101 instead o$ 11.

Project Name

Siebel eScript standards


Page 24

2.13.6 Gl!,al varia,les


The onl! #a! to set and get a global &ariable throughout the application .i.e. across business ser&ices% business components% etcetera1 is through use o$ TheApplication.1.SetShared<lobal.1 and TheApplication.1.<etShared<lobal.1. The commands TheApplication.1.Set5ro$ileAttr.1 and TheApplication.1.<et5ro$ileAttr.1 do the same% but the! add no additional $unctionalit! to itB the! are $orbidden. TheApplication.1.Set3ser5ropert!.1 and TheApplication.1.<et3ser5ropert!.1 set global &ariables throughout business componentsB these &ariables are e"isting along #ith the instance o$ the business component and are accessible &ia ()M as #ell. The! might be used $or this goal and this goal onl!B i$ a global &ariable #ill do% that must be used. t is $orbidden to set a global &ariable and not declare it in the application in the e&ent ApplicationNStartB it should be clear to all #hich global &ariables are alread! in use. 9emember that global &ariables can onl! be used #ith datat!pe stringB i$ a more $le"ible datat!pe is desired% an obCect must be declared - #hich must be destro!ed in the e&ent ApplicationN(lose.

2.13.7 F!r5ard3nl/ !n instantiated ,"siness c!m+!nents


t is $orbidden to retrie&e alread! instantiated business components .this.1 and use the cursor mode For#ard)nl! on themB it is impossible to tell #hat the user action #ill be on these business components% possibl! resulting in a crash o$ the application.

2.13.10

%anilla Sie,el ,"siness services

+anilla Siebel business ser&ices can be use$ul% and can be uselessB the! also can be de$ecti&e. The business ser&ices RAA 6ML 7rite to FileD and RAA 6ML 9ead $rom FileS must not be usedB S((7riteFile and S((9eadFile must be usedB the! gi&e $ull control o&er director!- and $ileaccessibilit!% and could o$$er possibilities to o&ercome the large string-bug in S ebel% #hich #ill cause problems i$ strings are larger than 50H'. 'oth $unctions are placed on the Application le&el% ta>e one obCect as input and return Rthe usualS output.

Project Name

Siebel eScript standards


Page 25

2.10 F"ncti!ns
Hno#ing all this% it is &er! eas! to build a $unctionB

t starts #ith a statement bloc>% describing the $unctionThen comes the declarations bloc>% naming all the &ariables;e"t is the tr! clause% #hich starts the errorhandlingThe dumm! do #hile enables script redirectionThe initialisation bloc> $ollo#s% initialiFing &ariables as much as possible% #ithout o&erinitialiFing themA"ecution begins% and ends% a&oiding all prohibited and de$ecti&e statementsThe dumm! do #hile endsThe tr! ends% and the catch starts% #here the e"ception and as much as &ariables as possible are set as properties to the input obCect)bCect deallocation ta>es place through &ariables destructionThe $unction returns the output )utput.

Li$e can be simpleG

)n the $ollo#ing page there?s an e"ample o$ a s>eleton $unction% to be used $or creating ne# $unctions in Siebel.

Project Name

Siebel eScript standards


Page 26

function M2@unction(M2O34ect) { /* ******************************************************************************** * @unction * * !uthor" * * )ate*+ritten" * ******************************************************************************** * Input" * * M2O34ect Generic ### o34ect * * * * Output" * * Output nothin0, rea112 * ******************************************************************************** */ /* * =aria31e */ var M2O34ect5 var Output5 /* * =aria31e */ tr2 { do initia1i ation dec1aration

{ Output 6 $he!pp1ication()#GetSharedG1o3a1(:S&&Output:)5 M2O34ect 6 ne+ O34ect()5 M2O34ect#&urrent@unction 6 :M2@unction:5

/* * Main" add 2our comment here */ ### (add 2our code here) 7 +hi1e (fa1 e) // dumm2 do ### +hi1e end 7 catch (e9ception) { M2O34ect#'9ception 6 e9ception5 Output 6 :'r i een on3ekende fout op0etreden in functie"On: C M2O34ect#&urrent@unction C $he!pp1ication()#GetSharedG1o3a1(:S&&Support:)5 Output 6 $he!pp1ication()#GetSharedG1o3a1(:S&&'rror:) C Output5 7 /* * ?eturn" c1ean up data a */ M2O34ect 6 nu115 7 return (Output)5 ociated +ith o34ect to dea11ocate them from memor2

Project Name

Siebel eScript standards


Page 27

3 General <"er/ )"idelines


3.1 :"siness !,'ects and ,"siness c!m+!nents
3.1.1 4ierarc$ical data,ase
Siebel turns each database into a hierarchical databaseB to $ollo# and use the lin>s bet#een business components% the $ollo#ing has to be done in the e"act orderB First o$ all the business obCect has to be instantiated;e"t% the primar! business component has to be instantiated #ith the correct &ie#modeThen% $or each underl!ing business component% the business components ha&e to be instantiated as the! are lin>ed in the business obCectB i$ the business obCect is three le&els deep and the last le&el has to be reached% this can onl! be achie&ed b! instantiating the $irst% the second and the third le&el% in that same order. $ !ou donTt R#al> through the business obCectS in this #a!% !ou #ill get into troubleG

3.2 C!m+aris!n t! S=
Siebel interacts #ith the database &ia its Euer!-statementsB this means that the! can be literall! translated to .parts o$1 S,L-statements% #hich results in a logical orderB

3.2.1 Set%ie5M!de
7hen instantiating the primar! business component% set the desired &ie# modeB donTt $orget this or !ouTll create m!sterious problems $or !oursel$ and !our $ello# de&elopersB the &ie# mode gi&es user-restricted access to tables and &ie#s. $ the current &ie#mode must be stored% use <et+ie#Mode. The general &ie# mode used is All+ie#B this #ill gi&e !ou &isibilit! across all organisations. n special cases% the &ie# mode )rganiFation+ie# can be used% but there has to be a &er! good reason to do thisG

3.2.2 ActivateFields
Acti&ating $ields means adding them to the S,L-select clause. Fields that are ForceActi&e on the business component or ha&e their Lin> Speci$ication set to T93A% Siebel s!stem $ields such as (reated% 3pdated% d and Siebel $ields that are &isible at the moment .becuas the!Tre on the acti&e applet1 donTt need to be acti&ated.

3.2.3 ClearT!="er/
(learTo,uer! is used to clear the current searchspec and sortspec on the business component. $ the current Searchspec or Searche"pression must be stored% use <etSearchSpec or <etSearchA"pr. (learing a Euer! means empt!ing the current S,L #here-clause.

3.2.0 SetSearc$S+ec
SetSearchSpec is used to set .a part o$1 the #here-clause o$ the S,L-Euer!

Project Name

Siebel eScript standards


Page 28

3.2.5 -.ec"te="er/
A"ecute,uer! o$$ers the S,L-statement to the database and returns a recordset

3.2.1 -.am+le 10: Sie,el ="er/

/* * Main" 0et fraud */

pecific fie1d , check con i tenc2

oINS&1aim 8&#Set=ie+Mode(!11=ie+)5 oINS&1aim oINS&1aim oINS&1aim oINS&1aim 8&#!ctivate@ie1d(:%o )ate:)5 8&#!ctivate@ie1d(:S&& 8e chadi0de Iaak $2pe:)5 8&#!ctivate@ie1d(:S&& 8ranche &ode:)5 8&#!ctivate@ie1d(:S&& )irect 8ehande1en @1a0:)5

oINS&1aim 8&#&1ear$oPuer2()5 oINS&1aim 8&#SetSearchSpec(:Id:, @raud#&1aimId)5 oINS&1aim 8&#'9ecutePuer2()5 ?ecord@ound 6 oINS&1aim 8&#@ir t?ecord()5 if (?ecord@ound) { ### 7

3.3 ="er/in)
3.3.1 ="er/ M!de
$ possible% use For#ard)nl!% since this #ill signi$icantl! speed up e"ecution. For#ard)nl! is possible i$ !ou don?t tra&el bac> .e.g. b! using First9ecord.1% 5re&ious9ecord.1% FirstSelected.11 through the recordset #ithout reEuer!ing the business component. Siebel #ill hold the entire recordset in memor!% occup!ing a considerable amount o$ memor! and maintaining a large rollbac> segment% causing a high drain on per$ormance. :onTt .this has been mentioned earlier1 use For#ard)nl! on alread! acti&e business componentsG $ the boo>shel$ is right .#hich it isnTt1% For#ard)nl! should not be used at all because the onl! #a! to instantiate a business component is to reuse an e"isitng one or recreate one i$ it doesnTt alread! e"ists- o$ course% thereTs no telling #hich situation is at hand since thereTs onl! one command to instantiate a business component.

Project Name

Siebel eScript standards


Page 29