WMB Best Practices and ESQL Development Guidelines

Embed Size (px)

Citation preview

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    1/24

    Integration Standards

    WMB Best Practices &

    ESQL Development Guidelines

    v1.0 

     April 7, 2016

    Printed on 4/7/2016 

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    2/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    Document History

    Revision History

    VersionNo

    !evisionDate

    Summary o" #$an%es !evision By

    0.1 22-May-07 First Draft version Santanu Mitra

    1.0 01-De-07 First !eleased version Santanu Mitra

    Document Distribution List

    Name itle

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 2 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    3/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    a'le o" #ontents

    1 Introdution................................................................................................................(

    2 'urpose.....................................................................................................................(

    $ Assu"ptions..............................................................................................................(

    % )e*Sp+ere M est 'raties..................................................................................6

    %.1 nderstand t+e Interfae usiness !euire"ent.............................................................6

    %.2 Interfae Design /ayout....................................................................................................6

    %.$ o""on +arateristis of Interfaes..............................................................................6

    %.% o""on rror&eption 3andling..................................................................................6

    %.( o""on ontrol 3andling...............................................................................................6

    %.6 o""on !outines and Su*-Flo4s...................................................................................7

    %.7 /oation of Integration /ogi............................................................................................7

    %.5 nderstand t+e Input and utput Messages....................................................................7

    %. Deter"ine +o4 "any Message Flo4s are needed...........................................................7

    %.10 o"plete t+e proessing 4it+ as fe4 nodes as possi*le..........................................5

    %.11 Message !outing 4it+in a flo4..................................................................................5

    %.12 Su*Flo4s...................................................................................................................5

    %.1$ 8ransationality and 'ersistene...............................................................................5

    %.1% se of A!DI9A/I8:...............................................................................................

    %.1( S;/ !F!9

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    4/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    (.5.2 IF State"ent............................................................................................................1%

    (.5.$ AS State"ent.....................................................................................................1(

    (.5.% S/8 State"ent.................................................................................................1(

    (.5.( I9S!8 State"ent..................................................................................................1(

    (.5.6 pdate State"ent...................................................................................................16

    (.5.7 D/8 State"ent.................................................................................................16

    (. Delarations....................................................................................................................16

    6 Appendi 1. I"portant Strutures............................................................................17

    6.1 M;MD @ Message Desriptor........................................................................................17

    6.2 M;!F32 @ !ules and For"atting 3eader.....................................................................15

    6.$ 'roperties @ Message Flo4............................................................................................15

    7 Appendi 2. De*ug 8raing......................................................................................20

    5 A Sa"ple S;/.......................................................................................................21

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age % of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    5/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    ( )ntroduction

    8+is dou"ent presents so"e findings and reo""endations onerning t+e use of )e*Sp+ereMessage ro>er )MB. 8+ese findings 4ere developed fro" previous eperienes of variousintegration proCets. It overs t+e aspets of )M develop"ent eno"passing Message Setguidelines, Message Flo4 guidelines and Deploy"ent guidelines.

    * Purpose

    8+is dou"ent an serve as a *aseline for Integration 'roCets using )M 4it+ a little or no"odifiations as appropriate.

    + ,ssumptions• 'rior 4or>ing level of >no4ledge on )M for t+e readers of t+is dou"ent.

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age ( of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    6/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    - We'Sp$ere MB Best Practices

    4.1Understand the Interface Business Requirement

    8+e first >ey to suessful 8e+nial Design and Interfae Develop"ent is a fir" >no4ledge of t+e intended *usiness logi and struture. 8+e soure to t+e usiness !euire"ent is to auirea fir" and defined Funtional Speifiation. 8o so"e degree, t+e Funtional Speifiation "ayundergo a fe4 "inor a"end"ents 4+ile t+e tas> of 8e+nial Speifiation is under4ay.3o4ever, it is epeted t+at t+e Funtional Speifiation +as defined all t+e "essages,o"ponents and proesses t+at are reuired for t+e interfae *efore t+e o""ene"ent of 8e+nial Design.

    8+ere "ay *e and usually isB "ultiple o"ponents to ea+ interfae, and in )M ter"s, t+at*oils do4n to Adapters and Message Flo4s. 8+e Funtional Speifiation is used to define 4+eret+e usiness !euire"ents are "et in ter"s of various o"ponents. It is reuired to onsider t+e

    various options availa*le and reate a design t+at is *ased on 4or>a*le funtionality of )M,and to +opefully end up 4it+ a reasona*le level of "aintaina*ility and perfor"ane as 4ell.

    4.2Interface Design Layout

    8+e )M interfaes to *e i"ple"ented s+ould +ave ertain o""on +arateristis so t+at re-use of o"ponents is opti"ied. 8+e design of t+e "essage flo4s s+ould ad+ere to one or "oreof t+e pattern te"plates laid out for t+e proCet. 3o4ever, t+ere an *e ases 4+ere t+ereuire"ent of t+e interfae is su+ t+at t+ere is no pattern te"plate "at+ing to lay out t+edesign of t+at interfae. 8+is ase is to *e treated as a speial ase and a ne4 pattern te"platefor t+is ase s+ould *e first designed *efore "oving for t+e te+nial design of t+e interfae.3o4ever, ourrene of su+ event is least epeted and if ours, definition of a ne4 patternte"plate s+ould *e t+e last +osen option.

    4.3Common Characteristics of Interfaces

    a+ )M Interfae designed for t+e proCet s+ould +ave ertain +arateristis 4+i+ areassu"ed to *e o""on aross all i"ple"ented interfaes. 8+ese o""on +arateristisgenerally refer to so"e o""on routines and flo4s or su*-flo4s 4+i+ are reo""ended to *eused glo*ally aross all interfaes in t+at proCet.

    4.4Common Error/Exception Handling

    a+ )M interfae s+all +ave a "e+anis" to +andle errors&eeptions. 8+ese

    errors&eeptions refer to *ot+ Syste"s generated ones as 4ell as ser ?enerated ones. It isreo""ended to +ave a o""on rror 3andling 'roedure&Module to +andle allerrors&eeptions t+at arise during eeution of an interfae. 8+is 'roedure&Module s+all *eetensively re-used *y all interfaes of t+e proCet.

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 6 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    7/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    4.5Common Control Handling

    8+e flo4 of ea+ "essage t+roug+ a )M interfae s+ould *e Eontrol 3andled for audit andlogging purpose. For t+is reason, t+ere is a reuire"ent to +ave a Eontrol Me+anis" in ea+and every "essage flo4. It is reo""ended to +ave a Eo""on ontrol 3andling

    routine&o"ponent t+at an *e re-used etensively *y all interfaes of t+e proCet.

    4.6Common Routines and Sub-Flows

    Many "essage flo4s reuire to perfor" ertain funtions li>e re-for"atting a date, getting urrentdate, getting a uniue identifier, et 4+i+ an *e laid do4n as o""on routines for re-use *y t+einterfaes. Also t+ere "ay *e ertain proesses li>e adding an !F32 +eader to a "essage, et4+i+ an also *e laid do4n as o""on su*-flo4s for re-use *y interfaes.

    It is reo""ended to +ave a set of o""on routines and su*-flo4s for t+e proCet t+at an *eetensively re-used *y t+e interfaes. 8+e ontents of t+is set annot *e defined e+austively atany point of ti"e. 8+is set s+all ontinually *e gaining "e"*ers fro" ti"e to ti"e in order to "eetreuire"ents.

    4.7Location of Integration Logic

     An interfae is o"prised of Adapters and Message Flo4s. 8+e integration logi is t+ereforeontained 4+olly 4it+in t+e adapters and "essage flo4s.

    8+e interfae designer +as t+e option of *uilding any reuired integration logi in t+e adapters or "essage flo4s. It is reo""ended t+at as "u+ *usiness logi as possi*le 4ill *e perfor"ed in"essage flo4s rat+er t+an in t+e adapters. In essene logi is only to *e loated in adapters if t+at is t+e only option for t+e interfae.

    In ot+er 4ords, adapters 4ill "e "ade as si"ple as possi*le. 8+e ore of t+e *usiness logis+ould *e >ept in )M.

    8+e *enefits of t+is approa+ are#

    • 8+e interfae solutions are pattern *ased, 4it+ t+e patterns represented *y )M "essage

    flo4s. eing pattern *ased, en+anes reusa*ility.

    • Saling and resiliene is si"plified 4it+ fe4er o"ple o"ponents to onsider.

    • Maintenane reuire"ents are easier to define and eeute, *y largely avoiding t+e need to

    +ange one o"ponent to ao""odate t+e +ange in anot+er reuire"ent.

    4.8Understand the Input and Output Messages

    It s+ould *e possi*le to ea"ine t+e Funtional Speifiation and deter"ine 4+at t+e input is, and

    4+at t+e output 4ould *e. Fro" t+is standpoint, t+e )M "essage flo4 an *e regarded as t+einstru"ent to onvert t+e input "essage into output "essagesB.

    4.9Determine how many Message Flows are needed

    First, at an appliation syste" level, it "ust *e deter"ined +o4 "any flo4s 4ill *e reuired for aninterfae. ut of t+is deter"ination, it 4ill *e possi*le to deter"ine +o4 "any types of "essagesa flo4 "ust +andle. So"eti"es t+ere is Cust one input "essage for"at and one output "essage

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 7 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    8/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    for"at. t+er ti"es t+ere are "ultiple "essages for a given flo4 and t+ere "ust *e logi 4it+int+e flo4 to sort t+e" out.

    4.10Complete the processing with as few nodes as possible

    8+e "ost funda"ental reo""endation to onsider 4+en 4riting a "essage flo4 is to *e asonise as possi*le. 8+ere is a perfor"ane ost assoiated 4it+ passing t+roug+ ea+ of t+e*uilt-in nodes of )M, so it is *est to 4rite "essage flo4s in as fe4 nodes as possi*le.

    In ot+er 4ords, t+ere s+ould *e as fe4 as possi*le nodes *et4een t+e input and output for"atsfor a given *usiness reuire"ent.

    4.11Message Routing within a flow

    !outing 4it+in t+e flo4 s+ould *e "ini"ied 4+ere possi*le. )+en routing is reuired, t+en t+erule a*out "ini"iing t+e nu"*er of nodes still applies.

    For a nu"*er of reasons, so"e "essage flo4s proess "ore t+an one "essage type. In t+is

    ase it is i"portant to understand t+e distri*ution of t+ese different "essage types and t+eir i"portane so t+at t+e "ost ritial or "ost freuent "essages go t+roug+ t+e +eapest pat+G i.e.t+e one 4it+ fe4est and si"plest nodes.

    )+en "ore t+an one "essage is proessed in a flo4, or 4+en t+ere is a reuire"ent for dyna"ilogi inside a flo4 *ased on "essage ontent, t+ere are at least t4o 4ays to diret t+e proessinglogi inside t+e flo4.

    ne 4ay is t+roug+ t+e use of !oute8o/a*el node. 8+is node "a>es use of t+e Destination/istarray of t+e /oalnviron"ent 8ree of a "essage flo4. )+en t+e "essage arrives, t+eDestination/ist is populated aording to t+e *usiness reuire"ent, and t+e !oute8o/a*el and/a*el nodes are used to diret su*seuent proessing.

     Anot+er 4ay is *y using t+e Filter node. ne or "ore Filter nodes ea+ ontaining a oolean filter epression is set up to ontrol logi *ran+es. If t+ere are "any possi*le pat+s, t+e Filter nodesan *e set up a asade, 4it+ t+e "ost o""on "essage *eing direted along t+e earliest pat+.

    8+e ost of using t+e Destination/ist is in setting it up in t+e first plae. 8+e ost of using Filters isin t+e nu"*er of nodes t+at are reuired for a o"ple routing evaluation. ne again, it isi"portant to "ini"ie t+e nu"*er of routing 4it+in a "essage flo4 as "u+ as possi*le.

     Anot+er variation of t+e routing t+e"e is to deliver data to one or "ore destination syste"s. Int+is senario, it is desira*le to allo4 t+e target syste"s to *e identified t+roug+ a data*ase ta*ledriven "e+anis".

    4.12SubFlows

    Message Flo4s an *e divided into Su*Flo4s. ssentially, a Su*flo4 is a seuene of nodes t+at

    *egins 4it+ an Input node and ends in an utput node. 8+e o*Cet of using Su*Flo4s is t+atfuntions an *e logially segregated in a 4ay t+at inreases "aintaina*ility and offersopportunity for reuse.

    8+e use of Su*Flo4s does not +ave an adverse perfor"ane effet *eause at deploy ti"e t+eyare si"ply folded into t+e flo4 to 4+i+ t+ey are assigned. It is i"portant t+at t+e overall nu"*er of nodes s+ould not *e inreased 4+en using Su*Flo4s.

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 5 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    9/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    4.13Transactionality and Persistence

     As a rule, all "essages s+ould *e +andled as a 8ransation. In t+e Input, utput and o"putenodes, t+e 8ransationality s+ould al4ays *e set to EAuto"ati. 8+is pratie allo4s t+e)e*Sp+ere M; "essage attri*utes to ontrol t+e 8ransationality of t+e flo4G i.e. if a "essage is

    read fro" a ueue 4it+ an attri*ute of E'ersistent, )I M 4ill supply t+e appropriate logging toguarantee t+e 8ransationality of t+e "essage.

    It "ust *e onsidered t+at over+ead is inurred *y "a>ing a "essage transational. 8+is isaused *y t+e need to save all t+e data neessary to ena*le a roll *a> s+ould a failure onditionour in a "essage flo4.

    4.14Use of CARDINALITY

    8+e use of t+e A!DI9A/I8: funtion s+ould *e restrited to "ini"u" as it reuires t+e parser to proess a large portion of t+e "essage and t+ere*y +indering perfor"ane. 8+is *uilt-infuntion s+ould not *e used inside a loop unless it is inevita*le.

    4.15ESQL REFERENCE Variable

    !eferene varia*les an *e used in S;/ to store a part or an entire "essage tree loation andan *e t+oug+t of as *eing si"ilar to a &HH pointer to a "essage ele"ent. 8+e use of !F!9 varia*le is reo""ended in S;/ for t4o reasons#

    • 8+ey redue oding onsidera*ly, espeially, 4+en large "essage tree 4it+ deep +ierar+y

    +as *een defined.

    • 8+ey "a>e S;/ "ore effiient 4+en used appropriately.

    !eferene varia*les an *e used to store loations in any type of "essage tree Input!oot,utput!oot, /oalnviron"ent, nviron"ent, etB.

    4.16Use of MOVE & LASTMOVE

    8+e M

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    10/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    4.17Backout Processing Considerations

    )+en an eeption is t+ro4n 4it+in a "essage flo4 and is not aug+t *y inlusion of a 8ryat+9ode, t+e Input 9ode for t+e "essage flo4 at+es it. If t+e at+ ter"inal of t+e M;Input 9odeis onneted, t+e "essage is propagated to t+is ter"inal and is proessed aording to t+e

    "essage flo4 logi.If t+e at+ ter"inal of t+e M;Input 9ode is not onneted, t+e transation is rolled *a>. If t+e"essage 4as read under a synpoint t+e original re"ains in t+e ueue *ut )e*Sp+ere M;inre"ents t+e M;MD a>out ount. 8+e M;Input 9ode t+en reads t+e "essage one again.

    8+e M;MD a>out ount is ea"ined *efore t+e "essage is proessed again. If it is not erot+en it i"plies t+at t+e "essage reeived *y t+e "essage flo4 is a *a>ed out "essage and t+e*ro>er t+en perfor"s *a>out proessing.

    • If t+e M;MD *a>out ount is less t+an t+e a>out !eueue 8+res+old attri*ute speified in

    t+e ueue definition, t+e "essage is propagated t+roug+ t+e output ter"inal of t+e M;Input9ode for nor"al proessing one again.

    • If t+e M;MD *a>out ount is not less t+an t+e a>out !eueue 8+res+old attri*ute

    speified in t+e ueue definition, t+e "essage is propagated t+roug+ t+e Failure ter"inal of t+e M;Input 9ode.

    • If t+e Failure ter"inal is 4ired t+en it follo4s t+at pat+ *ut, if it is not 4ired t+e a>out

    !eueue 9a"e attri*ute is loo>ed for and if a ueue na"e found in t+is attri*ute, t+e"essage is put into t+at ueue.

    • If no na"e is speified in t+e a>out !eueue 9a"e attri*ute, t+e "essage is 4ritten to t+e

    default Dead /etter ;ueue defined for t+e ueue "anager.

    • If t+e "essage ould not *e 4ritten to t+e Dead /etter ;ueue t+en it re"ains in t+e Input

    ;ueue.

    4.18WBI MB Message Flow Standard Unit Test Conditions8+e follo4ing are t+e standard nit 8est onditions t+at s+ould *e onsidered *y a developer 4+ile perfor"ing nit 8est on an interfae#

    • )+en a valid 8est Data is passed t+roug+ t+e "essage flo4 one or "ore output "essagesB

    are reated on t+e output ueuesB.

    • )+en an invalid 8est Data is passed t+roug+ t+e "essage flo4 t+e "essage is propagated to

    t+e error +andling ueue for error proessing.

    •  All fields of t+e output "essage are of orret lengt+ and +ave *een orretly for"atted

    aording to t+e reuire"ents.

    • )+ere t+e "essage +as repeating fields or struture, t+e interfae 4or>s orretly for *ot+

    single and "ultiple instanes of t+e field or struture.

    • )+ere t+e "essage +as an optional field or struture, t+e interfae 4or>s orretly for *ot+

    4it+ and 4it+out t+e field or struture in t+e "essage.

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 10 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    11/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    . ESQL Development Guidelines

    5.1Line Length

    It "ust *e possi*le to vie4 an S;/ file in a tet editor 4it+out srolling to t+e rig+t, and to print itout on A% portrait 4it+out line trunation or 4rapping. In pratie, t+is "eans to li"it a line to a*oundary of 50 +araters approi"ately.

    5.2Wrapping Lines

    )+en an epression does not fit in a single line, it is reo""ended to *rea> t+e line aording tot+e follo4ing general priniples#

    • rea> after a o""a.

    • rea> after an operator.

    • 'refer +ig+-level *rea>s to lo4-level *rea>s.

    •  Align t+e ne4 line 4it+ t+e *eginning of t+e sa"e level epression on t+e previous line.

    If t+e a*ove rules lead to onfusing ode or ode t+at is suis+ed up against t+e rig+t "argin, Custindent 5 spaes instead.

    5.3Comments

    8+e S;/ ode s+ould *e self-eplanatory as far as possi*le, for ea"ple, *y use of "eaningfulvaria*le na"es. o""ents are needed +o4ever, to eplain 4+at t+e S;/ ode is doing or 4+y

    is it doing t+at 4ay if it is not o*vious. nderlying assu"ptions s+ould *e noted.

    se t+e "ore standard for"at E& o""ent & for +eaders and "ulti-line o""ents, and E --o""ent for single line o""ents. o""ents "ust *e in o+erent gra""atial nglis+ starting4it+ a apital letter. Multiline o""ents s+ould *e a*ove t+e line of odes t+ey refer to, indentedto t+e sa"e level as t+e ode itself and *e preeded *y a *lan> line.

     A o""ent is reo""ended for ea+ logi onstrut as t+is tends to *e 4+ere *usiness logi an*e eplained.

    5.4Flower Box Comments

    Flo4er *o o""ents "ust appear at t+e start of every S;/ File, Module, 'roedures and

    Funtions. 8+e for"at s+ould *e as follo4s#ESQL /ile /lo0er Bo1

    /**********************************************************************

    * COPYRIGHT. . ALL RIGHTS RESERVED. NO PART OF *

    * THIS SOURCE CODE MAY BE REPRODUCED, STORED IN A RETRIEVAL SYSTEM, OR*

    * TRANSMITTED, IN ANY FORM BY ANY MEANS, ELECTRONIC, MECHANICAL, PHOTO*

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 11 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    12/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    * COPYING, RECORDING OR OTHERWISE, WITHOUT THE PRIOR WRITTEN PERMISS- *

    * ION OF *

    **********************************************************************/

    ESQL Module /lo0er Bo1

    /**********************************************************************

    * Node Name: *

    * Module Name: *

    * Description: *

    * *

    * Version Date Author Description *

    * =============== =========== =========== ============================*

    *

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    13/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    5.5Block Comments

    lo> o""ents inside a state"ent s+ould *e indented to t+e sa"e level as t+e ode t+eydesri*e. A *lo> o""ent s+ould *e preeded *y a *lan> line to set it apart fro" rest of t+eode.

    /*

    * Here is a block comment

    * They are usually more than one line long

    * and are preceded by a blank line.

    */

    SET OutputRoot.XML.MyMsg.MyFld01 = ‘Value01’;

    SET OutputRoot.XML.MyMsg.MyFld02 = ‘Value02’;

    SET OutputRoot.XML.MyMsg.MyFld03 = intValue03;

    5.6Internal and End-of-Line Comments

    S+ort o""ents an if neededB appear on a single line indented to t+e level of t+e ode t+atfollo4s. A *lan> line s+ould preede a single line o""ent.

    -- Set Customer First Name

    SET OutputRoot.XML.MyMsg.Customer.FirstName = ‘John’;

    -- Set Customer Last Name

    SET OutputRoot.XML.myMsg.Customer.LastName = ‘Smith’;

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    14/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    /*

    Old Code stuff.....

    .....

    */

    New Code stuff .....

    .....

    -- CR02577 End

    5.8Statements

    /ogial onstruts su+ as )3I/, IF, AS and data*ase ations s+ould +ave a o""entpreeding t+e". 8+ese are t+e *lo>s 4+ere *usiness logi is perfor"ed and t+e "ost li>elystu"*ling point 4+en it o"es to ot+ers trying to understand t+e ode.

    Speifi rules applying to t+ese state"ents follo4s, alt+oug+ in "any iru"stanes, o""on

    sense 4ill prevail.

    .2( WH)LE Statement/*

    * Comment here for the

    * WHILE Block

    */

    WHILE DO

    END WHILE;

    .2* )/ Statement/*

    * Comment here for the

    * IF-ELSE Block

    */

    IF THEN

    ELSEIF THEN

    ELSE

    END IF;

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 1% of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    15/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    .2+ #,SE Statement/*

    * Comment here for the

    * CASE Statement Block

    */

    SET intGrade = CASE InputRoot.MyMsg.Student.Marks

    WHEN > 90 THEN 1

    WHEN > 80 THEN 2

    WHEN > 70 THEN 3

    WHEN > 60 THEN 4

    ELSE 5

      END;

    .2- SELE# Statement/*

    * Comment here for the

    * INSERT Block

    */

    SET Environment.Variables.EmpList[] =

    (SELECT T.EMP_ID,

    T.EMP_NAME,

    T.EMP_AGE FROM Database.Schema.T_EMP AS T

     WHERE T.EMP_ID IN (1, 2, 3, 4, 5)

     AND T.EMP_AGE >= intMinAge);

    .2. )NSE! Statement/*

    * Comment here for the

    * INSERT Block

    */

    INSERT INTO Database.Schema.T_EMP

    (EMP_ID,

     EMP_NAME,

     EMP_AGE)

    VALUES intEmp_ID,

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 1( of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    16/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    chrEmpName,

    intEmpAge;

    .23 4pdate Statement

    /** Comment here for the

    * Update Block

    */

    Update Database.Schema.T_Emp AS T

    SET EMP_NAME = chrEmpName,

    EMP_AGE = 25

    WHERE T.EMP_ID = intEmpID;

    .25 DELEE Statement/*

    * Comment here for the

    * DELETE Block

    */

    DELETE FROM Database.Schema.T_EMP AS T

    WHERE T.EMP_ID = intEmpId;

    5.9Declarations

    Delaration of varia*les "ust *e "ade at t+e *eginning of ea+ and every proedure or funtion.ne varia*le delaration per line is reo""ended. Delarations s+ould *e grouped *y varia*letype and a *lan> line s+ould separate t4o groups. Also it is reo""ended not to initialie avaria*le during delaration. Initialiation s+ould *e epliitly "ade as a separate assign"entstate"ent.

    DECLARE intVar01 INTEGER;

    DECLARE intVar02 INTEGER;

    DECLARE intVar03 INTEGER;

    DECLARE chrVar01 CHARACTER;

    DECLARE chrVar02 CHARACTER;

    DECLARE blnVar01 BOOLEAN;

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 16 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    17/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    3 ,ppendi1 ( )mportant Structures

    6.1MQMD – Message Descriptor

    8+e M;MD struture ontains t+e ontrol infor"ation t+at ao"panies t+e appliation data4+en a "essage travels fro" one ueue to anot+er.

    8+e follo4ing ta*le su""aries t+e fields in t+e struture#

    /ield Description

    StruId Struture Identifier  

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    18/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    riginal/engt+ /engt+ of original "essage

    6.2MQRFH2 – Rules and Formatting Header8+e M;!F32 struture defines t+e layout of t+e rules and for"atting +eader. 8+is +eader an *eused to send string data t+at +as *een enoded using an JM/-li>e synta. It allo4s niodestring to *e transported 4it+out translations, and it an arry nu"eri data-types.

    8+e follo4ing ta*le su""aries t+e fields in t+e struture#

    /ield Description

    StruId Struture Identifier  

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    19/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    !eplyIdentifier 8+e reply identifier  

    !eply'rotool 8+e reply protool

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 1 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    20/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    5 ,ppendi1 * De'u% racin%

    In t+e event of an error in a "essage flo4, a de*ug level trae s+ould *e set up for t+e flo4. 8+isis done 4it+ t+e +elp of a set of o""ands to generate t+e de*ug trae file for diagnostis.

    1. pen a o""and pro"pt 4indo4.

    2. eute t+e o""and "si+angetrae Kro>er 9a"eL -u -e Keution ?roup 9a"eL -lde*ug -f KMessage Flo4 9a"eL -r 

    $. eute t+e "essage flo4 4it+ t+e "essage t+at you 4ant to trae.

    %. eute t+e o""and "sireadlog Kro>er 9a"eL -u -e Keution ?roup 9a"eL -l de*ug-f KMessage Flo4 9a"eL -o K8e"porary File 9a"eL

    (. eute t+e o""and "sifor"atlog @i K8e"porary File 9a"eL -o K8rae File 9a"eL

    pen t+e generated 8rae file in a tet editor and perfor" diagnosis.

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 20 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    21/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    2 , Sample ESQL

    /**********************************************************************

    * COPYRIGHT. ALL RIGHTS RESERVED. NO PART OF *

    * THIS SOURCE CODE MAY BE REPRODUCED, STORED IN A RETRIEVAL SYSTEM, OR*

    * TRANSMITTED, IN ANY FORM BY ANY MEANS, ELECTRONIC, MECHANICAL, PHOTO*

    * COPYING, RECORDING OR OTHERWISE, WITHOUT THE PRIOR WRITTEN PERMISS- *

    * ION OF *

    **********************************************************************/

    /**********************************************************************

    * Node Name: Get Employee Information *

    * Module Name: IDD111_EmployeeInfo *

    * Description: This module searches for information about the*

    * Employee from the Employee Database. *

    * *

    * Version Date Author Description *

    * =============== =========== =========== ============================*

    * 1.00 25-Feb-2006 A. Program The initial version. *

    **********************************************************************/

    CREATE COMPUTE MODULE IDD111_EmployeeInfo

    /****************************************************************

    * Function Name: Main *

    * Input Parameters: None *

    * Output Parameters: Boolean Return *

    * Description: The Main entrypoint to the module *

    * Version Date Author Description *

    * =============== =========== =========== ======================*

    * 1.00 25-Feb-2006 A. Program The initial version *

    *****************************************************************************/

    CREATE FUNCTION Main() RETURNS BOOLEAN

    BEGIN

    -- Copy input headers to output

    CALL prcCopyMessageHeaders();

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 21 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    22/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    -- Create the output message

    CALL prcCreateOutputMessage();

    -- Return success

    RETURN TRUE;

    END;

    /****************************************************************

    * Procedure Name: prcCopyMessageHeaders *

    * Input Parameters: None *

    * Output Parameters: None *

    * Description: Copies input message headers to *

    * the output message *

    * Version Date Author Description *

    * =============== =========== =========== ======================*

    * 1.00 25-Feb-2006 A. Program The initial version *

    *****************************************************************************/

    CREATE PROCEDURE prcCopyMessageHeaders()

    BEGIN

    DECLARE intIdx INTEGER; -- An Index Pointer

    DECLARE intCounter INTEGER; -- A counter

    -- Initialize Index to 1

    SET intIdx = 1;

    -- Initialize counter to cardinality of InputRoot

    SET intCounter = CARDINALITY(InputRoot.*[]);

    /*

    Iterate through each subtree of InputRoot and copy the

    Sub-tree to the OutputRoot until the Last one.

    */

    WHILE intIdx < intCounter DO

    SET OutputRoot.*[intIdx] = InputRoot.*[intIdx];

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 22 of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    23/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    SET intIdx = intIdx + 1;

    END WHILE;

    END;

    /****************************************************************

    * Procedure Name: prcCreateOutputMessage  *

    * Input Parameters: None *

    * Output Parameters: None *

    * Description: Creates the Output Message *

    * Version Date Author Description *

    * =============== =========== =========== ======================*

    * 1.00 25-Feb-2006 A. Program The initial version *

    *****************************************************************************/

    CREATE PROCEDURE prcCreateOutputMessage()

    BEGIN

    DECLARE chrEmpId CHARACTER; -- Employee Id

    -- Initialize chrEmpId

    SET chrEmpId = InputRoot.XML.Employee.Id;

    -- Check that the EmpId is not NULL to proceed

    IF chrEmpId IS NULL THEN

    -- Throw an Exception

    THROW USER EXCEPTION VALUES (‘The Employee Id

    Received in the Input is NULL’);

    END IF;

    -- Retrieve the Employee Info from Database

    SET OutputRoot.XML.Employee.EmployeeInfo[] =

    (SELECT T.EMP_ID AS EmployeeID,

    T.EMP_NAME AS EmployeeName,

    T.EMP_DOJ AS EmployeeDOJ,

    T.EMP_CURR_SAL AS EmployeeSalary

    FROM Database.HRM.T_EMP_MASTER AS T

    WHERE T.EMP_ID = chrEmpId);

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 2$ of 2%

  • 8/18/2019 WMB Best Practices and ESQL Development Guidelines

    24/24

    WMB Best Practices & ESQL DevelopmentGuidelines

    -- Check If any record is retrieved

    IF CARDINALITY(OutputRoot.XML.Employee.EmployeeInfo[])

    IS NULL THEN

    -- Throw an Exception

    THROW USER EXCEPTION VALUES (‘Employee Number ‘ ||

    chrEmpId || ‘ does not exist.’);

    END IF;

    END;

    END MODULE;

    Dou"ent# $126%07$7.do Printed on 4/7/2016  Date# %&7&2016

    'age 2% of 2%