VSAM to DB2 Conversion

Embed Size (px)

Citation preview

  • 7/26/2019 VSAM to DB2 Conversion

    1/63

    VSAM to DB2

    Online And Batch Program Conversion Strategy

    Version 1.0

    1

  • 7/26/2019 VSAM to DB2 Conversion

    2/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    Preface

    Scope and audience

    This document is intended to assist in converting online programs using COBOL CICS

    and batch programs using COBOL which access VSAM files to access B! tables"

    "

    Objectives

    VSAM to B! conversion

    Structure of this document

    ocument discusses schema translation strateg# initiall#" Translation of batch COBOL

    access calls for VSAM to B! is discussed" Translation of CICS access calls to B!

    access calls is detailed out ne$t for each of the CICS commands for %SS files" The

    document ends with the performance tuning issues to be considered"

    Related documents

    VSAM to DB2 error handling document

    2

  • 7/26/2019 VSAM to DB2 Conversion

    3/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    Table of contents

    1 OVERVIEW............................................................................................................................................6

    2 SCHEMA TRANSLATION...................................................................................................................6

    3 CONVERSION STRATEGY................................................................................................................7

    &"' BATC()*O+*AMT*A,SLATIO,"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''&"'"' Specific Translation *ules""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''

    &"'"! Se-uential Organi.ation Se-uential Access"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'!3.1.2.1 INPUT.............................................................................................................................................123.1.2.2 I-O...................................................................................................................................................133.1.2.3 OUTPUTE!TEN".......................................................................................................................13

    &"'"& Inde$ed Organi.ation Se-uential Access"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'&3.1.3.1 INPUT.............................................................................................................................................133.1.3.2 I-O...................................................................................................................................................13.1.3.3 OUTPUT E!TEN".....................................................................................................................1!

    &"'"/ Inde$ed Organi.ation *andom Access"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'03.1.#.1 INPUT.............................................................................................................................................1!3.1.#.2 I-O...................................................................................................................................................1!

    3.1.#.3 OUTPUT........................................................................................................................................ 1!&"'"1 Inde$ed Organi.ation #namic Access""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'0

    3.1.$.1 INPUT.............................................................................................................................................1"3.1.$.2 I-O...................................................................................................................................................223.1.$.3 OUTPUT........................................................................................................................................ 2#

    &"! O,LI,2)*O+*AMT*A,SLATIO,"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""!0

    &"!"' *2A""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""!33.2.1.1 %&'c()*'..........................................................................................................................................2$3.2.1.2 CICS S+'(a,...................................................................................................................................2$3.2.1.3 Tra'a()*' *f S+'(a,....................................................................................................................2$

    &"!"! STA*TB*""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""&'3.2.2.1 %&'c()*'..........................................................................................................................................313.2.2.2 CICS S+'(a,...................................................................................................................................313.2.2.3 %ranslation o& Synta'......................................................................................................................31

    &"!"& *2A,24T 5 *2A)*2V"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""&/3.2.3.1 %&'c()*'..........................................................................................................................................3(3.2.3.2 CICS S+'(a,...................................................................................................................................3(3.2.3.3 Tra'a()*' *f S+'(a,.....................................................................................................................3

    &"!"/ 6*IT2""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""&73.2.#.1 %&'c()*'..........................................................................................................................................3"3.2.#.2 CICS S+'(a,...................................................................................................................................3"3.2.#.3 Tra'a()*' *f S+'(a,.....................................................................................................................3"

    &"!"1 *26*IT2"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""&33.2.$.1 %&'c()*'..........................................................................................................................................3$3.2.$.2 CICS S+'(a,...................................................................................................................................3$3.2.$.3 Tra'a()*' *f S+'(a,.....................................................................................................................3$

    &"!"8 2L2T2"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""/93.2.#.1 )unction...........................................................................................................................................(*3.2.6.2 CICS S+'(a,...................................................................................................................................(*3.2.6.3 Tra'a()*' Of S+'(a,....................................................................................................................(*

    &"!"0 :,LOC%""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""/!3.2.7.1 %&'c()*'..........................................................................................................................................(23.2.7.2 CICS S+'(a,...................................................................................................................................(23.2.7.3 Tra'a()*' *f S+'(a,....................................................................................................................(2

    &"!"7 2,B*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""/&3.2./.1 %&'c()*'..........................................................................................................................................(33.2./.2 CICS S+'(a,...................................................................................................................................(33.2./.3 Tra'a()*' Of S+'(a,....................................................................................................................(3

    &"!"3 *2S2TB*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""//

  • 7/26/2019 VSAM to DB2 Conversion

    4/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2.0.1 %&'c()*'..........................................................................................................................................((3.2.0.2 CICS S+'(a,...................................................................................................................................((3.2.0.3 Tra'a()*' Of S+'(a,....................................................................................................................((

    # OPTIMIING %OR PER%ORMANCE.............................................................................................#/

    /"' S 2L2CTI,+O,L;T(2*2C:*SO*""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""/3

    1"'"! Se-uential *ead STA*T>C:*SO*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""191"'"& Se-uential *ead *2A>C:*SO*""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""1'

    1"'"/ *andom *ead"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""1!

    1"'"1 Insert""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""1&

    1"'"8 *andom *ewrite"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""1/1"'"0 elete"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""18

    1"'"7 O)2,>C:*SO*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""10

    1"'"3 STA*T>C:*SO*""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""17

    1"'"'9 *2A>C:*SO*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""13

    1"'"'' ependant>Cursor>'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""891"'"'! ependant>Cursor>n""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""89

    1"'"'& ependant>:pdatable>Cursor>'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""89

    1"'"'/ ependant>:pdatable>Cursor>n""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""891"'"'1 =2TC(>)A*A>'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""8'

    1"'"'8 =2TC(>)A*A>n"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""8'

    1"'"'0 I,S2*T>)A*A>'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""8!

    1"'"'7 I,S2*T>)A*A>n"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""8!1"'"'3 :)AT2>)A*A>'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""8&

    1"'"!9 :)AT2>)A*A>n"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""8&

    #

  • 7/26/2019 VSAM to DB2 Conversion

    5/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    1 Overview%his document discusses translation strategy &or VSAM access calls a++earing in online COBO, C-CS and

    atch COBO, +rograms y S/,s to access DB2 tale.

    0m+hasis is on one to one translation o& each VSAM access call to DB2 access S/,s.

    2 Schema Translation

    During this +hase o& the migration VSAM &ile schema needs to e translated to relational schema.

    )or this a com+lete ma++ing document needs to e +re+ared &or the VSAM &iles eing converted to DB2

    tales. %his document has the VSAM &ile name the record name co+yoo name &or this &ile the &ield

    names o& the record ith the corres+onding DB2 tale names column names data descri+tion &or thecolumns indicators to identi&y hether nulls are alloed the column is an inde' and ma++ing e'ce+tions

    o& any ind. -t is understood that in such conversion there are cases o& multi+le ma++ing lie one VSAM

    &ile ma++ed to many tales many VSAM &iles ma++ed to one tale di&&erent record ty+es o& a VSAM &ilema++ed to di&&erent tales one &ield o& a VSAM record ma++ed to multi+le columns o& a tale many&ields o& a VSAM record ma++ed to one tale column.

    !

  • 7/26/2019 VSAM to DB2 Conversion

    6/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3 Conversion Strategy

    %he conversion is ased on the &olloing translation rules 4

    1. COBO, source code ill remain same e'ce+t &or the introduction o& ne code and commenting o&

    e'isting code as +art o& translation. 5e code ill e either emedded S/, statements or COBO,constructs or -5C,6D0 co+yoos to su++ort translation. Comments ill e added to indicate the

    +rogram changes done.

    2. DC,705 variales ill e used as host variales. %hese values ill e moved into the VSAM &ile

    structure &or the +rogram +rocessing.

    3. VSAM se8uential o+erations ill e translated using cursors on the associated tales.

    (. -9O o+erations on array &ields o& the record ill e translated using cursors &or normalised cases. -ndenormalised cases the array &ields ill e translated to the corres+onding columns on the DB2 tale.

    . 5o cursor ill e de&ined i& &ile is o+ened in O6%P6% or 0:%05D mode.

    #. Any su++orted COBO, construct related to VSAM &ile hich is translated to relational e8uivalent ornot needed any more ill e commented.

    !. -n case o& commenting OP05 statements i& the same statement o+ens some other non;VSAM &iles or

    VSAM &iles hich ill not e converted an OP05 statement to o+en those &iles ill e added in the

    +rogram and the original OP05 statement ill e commented.

    ". -n case o& commenting C,OS0 statements i& the same statement closes some other non;VSAM &iles orVSAM &iles hich ill not e converted an C,OS0 statement to close those &iles ill e added in the

    +rogram and the original C,OS0 statement ill e commented.

    $. At any +oint o& time there ill e only one cursor o+ened +er tale. Cursors ill e de&ined and

    o+ened ith various conditions ased on organiD0> B? condition &or inde'ed &iles.

    =ith =@0>0 condition &or S%A>% and >0AD

    =ith )O> )0%C@ &or read only o+eration

    =ith )O> 6PDA%0 &or u+date o+erations

    11. S%A>% o+erations ill e translated to cursor declaration ith =@0>0 condition. %he condition used

    in the =@0>0 condition ill e same as the condition stated in the S%A>%. -& S%A>% uses 0/6A,

    %O then the ill e used in the =@0>0 condition. -& S%A>% uses 7>0A%0> %@A5 then ill

    e used in the =@0>0 condition.

    12. S%A>% can use a &ull;ey or +artial ey. %he translation ill de+end on the ty+e o& ey used as ell asthe ey length s+eci&ied.-& S%A>% uses &ull ey then the columns ma++ed to this ill e used in the

    =@0>0 clause. -& S%A>% statement uses +artial ey there are 2 cases 4a. i& the eylength is a constant non at conversion time the S%A>% ill e translated to

    D0C,A>0 C6>SO> using the tale columns corres+onding to this ey length s+eci&ied.

    . -& the ey length is calculated at run time it needs to e analysed and suitale =@0>0 clause

    should e used in the D0C,A>0 C6>SO> clause.

    13. Any column corres+onding to ey &ields o& the VSAM &ile needs to e used as an inde' on the tale.Alternate record eys can e considered as inde' on tales. %his needs tale to e inde'ed on columns

    corres+onding to alternate record eys.

    "

  • 7/26/2019 VSAM to DB2 Conversion

    7/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    1(. C,OS0 ill e translated to closing the cursorEsF de&ined on the corres+onding tale. -& same C,OS0

    statement closes non;VSAM &iles or VSAM &iles not eing converted se+arate close statement to

    close the these &iles ill e generated and included in the source code.

    1. Standard error Paragra+hs ill e +er&ormed to tae care o& any S/,COD0 checing.

    1#. All the )-,0 S%A%6S logic used y the +rogram ill e retained &or conditional +rocessing. %he )-,0

    S%A%6S &or the converted VSAM &ile ill e set y the standard error +rocessing logic de+ending onthe value o& S/,COD0 returned

    1!. One;to;one ma++ing ill e handled y translating the VSAM access to the corres+onding S/,

    statement.

    Se-uential Operation for VSAM file

    a" Se8uential >0AD o+erations ill e translated to cursor )0%C@.

    b" Se8uential >0=>-%0 ill e translated to 6PDA%0 ith C6>>05% O) condition.

    c" Se8uential D0,0%0 ill e translated to D0,0%0 ith C6>>05% O) condition.

    *andom Operation for VSAM file

    a. >andom >0AD o+erations ill e translated to S0,0C% ith =@0>0 condition.

    . >andom >0=>-%0 ill e translated to 6PDA%0 ith =@0>0 condition.

    c. >andom D0,0%0 ill e translated to D0,0%0 ith =@0>0 condition.

    d. =>-%0 ill e translated to -5S0>% ith VA,60S clause.

    1". -n the case o& one;to;many ma++ing the &olloing scenarios are +ossile 4

    a. One VSAM &ile having di&&erent record ty+es ma++ed to di&&erent tales

    Se-uential Operation on the VSAM file

    0'am+le o& this is header and detail records in a VSAM &ile. -n DB2 there can e tale

    de&ined &or header records and another tale de&ined &or detail records. Any se8uential read o&this VSAM &ile ill e translated to o+ening a cursor on the header tale then &etch cursor

    on the header tale. 6sing the ey retrieved &rom the header tale o+en a cursor on the

    detail tale and continue &etch using this cursor until end;o&;cursor then close the cursor onthe detail tale. Again &etch the cursor on the header tale and continue the +rocess o& o+en

    cursor and &etch cursor on the detail tale.

    )or any se8uential u+date or delete o+erations on this VSAM &ile the same translation

    strategy ill e used ut ith the cursor o+tion )O> 6PDA%0.

    *andom Operation on the VSAM file

    -& the VSAM &ile is eing read randomly using a ey value moved ithin the +rogram then

    the +rogram &lo needs to e analysed to determine hich tale needs to e accessed.

    . )ields o& one VSAM &ile ma++ed to di&&erent tales

    -n such cases any in+ut;out+ut o+eration on this VSAM &ile ill e translated to an e8uivalentS/, statements to access data &rom all the associated tales.

    Se-uential Operation on the VSAM file

    )or a se8uential read on this &ile a cursor ill e de&ined hich ill Goin re8uired data &romall the associated tales.

    )or any se8uential u+date or delete on the &ile individual cursors ill e de&ined on the

    associated tales ith the )O> 6PDA%0 clause. -n the case o& a VSAM &ile ma++ed to to

    $

  • 7/26/2019 VSAM to DB2 Conversion

    8/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    DB2 tales the cursor on the &irst tale ill e &etched then the cursor on the second tale

    ill e &etched. -& oth the ros &etched have the same ey then the DC,705 values are

    &ormatted as re8uired and moved to the COBO, layout o& the &ile. Values &or any u+dates to

    e made are moved in and the tales are u+dated. -n case the eys &etched y the to cursorsare not same then this may e either ecause o& some invalid data in one o& the tales or

    ecause some ros are eing added into either o& the tales &rom some other VSAM &ile.

    Since this may e a valid case as +er a++lication design additional analysis ill e re8uired.

    *andom Operation on the VSAM file

    )or a random read translate to a S0,0C% clause using a Goin &rom the associated tales.

    )or rite rerite or delete translate to a -5S0>% 6PDA%0 or D0,0%0 ith conditional

    e'ecution. -& the o+eration on the &irst tale as success&ul then only attem+t a similaro+eration on the other tale.

    c. Many VSAM &iles ma++ed to one tale

    Se-uential Operation on the VSAM file

    %ranslate the se8uential o+eration to cursor o+eration on the tale using only the columns

    &rom tale hich has een ma++ed &rom the &ields o& this VSAM &ile. =hile inserting use

    de&ault values &or the columns coming &rom other &iles. =hile u+dating u+date only the tale

    columns ma++ed &rom the &ile eing reritten.

    *andom Operation on the VSAM file

    )or read select only the tale columns hich have een ma++ed &rom the &ile eing read.)or delete veri&y i& the ro is +resent in the tale e&ore attem+ting a delete &rom the tale

    -& +resent then do a delete else do not attem+t to delete. %his is ecause the delete o+eration

    hich might have een +er&ormed on the other VSAM &ile hich also ma+s to this tale

    might have already deleted the entire ro. )or u+date u+date only the tale columns hichhave een ma++ed &rom this &ile. )or insert veri&y i& the ey eing inserted is already +resent

    in the tale i& +resent then do an u+date instead o& an insert else do an insert. %his is ecause

    this ro might already have een inserted hen a rite as +er&ormed on the other &ile hich

    also ma+s to this tale. =hile inserting use de&ault values &or the columns coming &rom other&iles.

    d. One &ield ma++ed to multi+le columns

    One field split into different columns

    Situations ere a &ield &rom the VSAM &ile is s+lit into tale columns ill e taen care o& as

    +er the s+litting s+eci&ied in the ma++ing in+ut. %his ill e valid &or any &ields in the &ile

    hich is ty+e D-SP,A?. But any attem+t to s+lit a &ield de&ined as COMP or COMP;3 illneed additional analysis.

    One field mapped to different columns

    -n situations ere a hole &ield can e ma++ed to di&&erent columns de+ending on someconditional +rocessing the e'ce+tion logic associated ith the ma++ing &or that &ield ill

    have to e used. %his e'ce+tion logic ill also e used to assign the +ro+er DC,705

    &ield to the COBO, &ield.

    1$. =hile +o+ulating de&ault values &or any 5O% 56,, &ields in the DB2 tale assume * &or numeric and

    SPAC0S &or C@A> &ields as de&ault.

    Any 56,, &etched &rom the tale ill e inter+reted as a * i& the receiving &ield is numeric or as

    SPAC0S i& the receiving &ield is al+hanumeric.

    2*. Be&ore u+dating or inserting into any column hich has a numeric data ty+e in DB2 +er&orm a

    numeric;chec. -& the value is non;numeric assign the null indicator &or nullale &ields and* &or non;nullale &ields.

    1*

  • 7/26/2019 VSAM to DB2 Conversion

    9/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    21. )or grou+s containing numeric items ma++ed to a single numeric column the grou+ ill e treated as

    an al+hanumeric and moved into the numeric column. Such translation ill hold good only i& the

    numeric values in the su;&ields can e treated as an al+hanumeric value &rom the usiness +oint o&vie. )or e'am+le it is o to ma+ a grou+ item having su;items as account and su;account oth

    numeric into a single numeric tale column as account. But i& the same translation is +er&ormed &or

    items lie amounts then the result ill e un+redictale.

    22. -n many situations a &ield de&ined in the VSAM layout and the corres+onding DB2 tale column ill

    have di&&erent lengths this is ecause the dataty+es in VSAM and DB2 are di&&erent and have their

    on &ield length restrictions.

    23. )or variale length VSAM &iles eing used in the +rogram the tale ill have columns corres+onding

    to the OCC6>S &ields. %he numer o& columns ill e the ma'imum +ossile value o& the OCC6>S

    clause. A&ter conversion to tales there ill e a column &or each occurance o& the variale occurance

    &ield although all the columns may not e used or not have values +o+ulated in them. =ithin the+rogram the logic ill e to use all the occurances o& the &ield ut this may not e in tune ith the

    e'isting +rogram logic.

    2(. 5e &ields de&ined in the tales &or any &uture use ill e +o+ulated ith the de&ault values.

    2. -n case o& C-CS +rograms a record can e read into an area ithin the +rogram or into the C-CS

    u&&er. -n the later situation a +ointer is used &or accessing the u&&er area here the record is read into.

    A&ter translation the use o& this +ointer ill e avoided &or data read &rom tales. De&ine a *1 levelitem ith length e8ual to the record length &or the &ile &or hich the +ointer as used. A&ter accessing

    data &rom the tales &ormat and move this data to the record layout as ell as to this nely de&ined

    data item. Any use o& the data stored in the u&&er identi&ied y the +ointer ill e re+laced y using

    the nely de&ined data item.

    2#. %ranslate a S%A>% rose >0AD50:% o+eration into OP05 cursor and )0%C@ cursor. A&ter

    each &etch the ey values retrieved ill e saved and ill e com+ared ith the ey value e&ore the

    ne't &etch. -& the ey values match continue ith the &etch else close the cursor and then o+en a necursor using the current ey values and continue the &etch o+eration. %his &eature ill allo the si+

    se8uential +rocessing to e converted correctly.

    2!. Any VSAM &iles used in internal +rogram sorting ill also e translated to S/, statements.

    2". A&ter conversion many &ile OP05 statements ill have een commented ecause they are not re8uired

    &or an inde'ed &ile hich is converted to DB2 tale. -n such cases the &ile status &or these commented

    &iles have to e set u+ +ro+erly so that +rogram +rocessing continues normally. %his can e done ysetting the &ile status to ** &or the &ile OP05 hich as commented out.

    11

  • 7/26/2019 VSAM to DB2 Conversion

    10/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.1 Batch Program Translation

    3.1.1 Specific Translation Rules

    )olloing sections s+eci&y the translation strategy &or each o& the valid &ile -9O o+eration &or VSAM &iles.

    %he rules are organi

  • 7/26/2019 VSAM to DB2 Conversion

    11/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    arra#>n>table>'>col>' )irst column in the &irst tale corres+onding to the nth array

    db!>arra#>n>table>'>col>'>fld>' )ield in the nely de&ined record corres+onding to the &irst &ield o& the

    nth array hich has ma++ing column in the &irst tale

    arra#>n>table>'>col>n 5th column in the &irst tale corres+onding to the nth array

    db!>arra#>n>table>'>col>n>fld>n )ield in the nely de&ined record corres+onding to the nth &ield o& thenth array hich has ma++ing column in the &irst tale

    arra#>n>table>n 5th tale corres+onding to the nth array

    arra#>n>table>n>col>' )irst column in the nth tale corres+onding to the nth array

    db!>arra#>n>table>n>col>'>fld>' )ield in the nely de&ined record corres+onding to the &irst &ield o& thenth array hich has ma++ing column in the nth tale

    arra#>n>table>n>col>n 5th column in the nth tale corres+onding to the nth array

    db!>arra#>n>table>n>col>n>fld>n )ield in the nely de&ined record corres+onding to the nth &ield o& thenth array hich has ma++ing column in the nth tale

    b!>arra#>n>si.e 5ely generated data item to store the si'>?e#>col>' )irst ey column in the &irst tale containing columns corres+onding

    to the scalar &ields o& the record

    table>'>?e#>col>n 5th ey column in the &irst tale containing columns corres+onding to

    the scalar &ields o& the record

    at>end>statements -m+erative statements to e e'ecuted on end o& &ile

    not>at>end>statements -m+erative statements to e e'ecuted on not end o& &ile

    Invalid>?e#>statements -m+erative statements to e e'ecuted on invalid ey

    ,ot>invalid>?e#>statements -m+erative statements to e e'ecuted on valid ey

    b!>count 5ely generated data item to ee+ the loo+ count.

    3.1.2 Sequential Organization Sequential ccess

    All the -9O o+erations in &iles ith se8uential organiO)2,>C:*SO*

    05D;0:0C

    13

  • 7/26/2019 VSAM to DB2 Conversion

    12/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.1.2.2 !%O

    Cursor efinition @

    OP05;C6>SO>

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 O+en the de&ined cursor. 0:0C S/,

    OP05 file'>O)2,>C:*SO*05D;0:0C.

    >0AD Se8uential;>ead;OP05;C6>SO>

    >0=>-%0 >andom;>erite

    C,OS0 Close the o+ened cursor. 0:0C S/,C,OS0 file'>O)2,>C:*SO*

    05D;0:0C

    3.1.2.3 O$T#$T&'(T'")

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 Comment C,OS0 statement 5one

    =>-%0 -nsert ne ros into res+ective tales. -nsert

    C,OS0 Comment the C,OS0 statement. 5one

    3.1.3 !nde*ed Organization Sequential ccess

    All the -9O o+erations in a &ile ith inde' organi%. )or &iles o+ened in

    -5P6% or -;O mode 8uery translation varies ased on the e'istence o& S%A>% on the &ile. -n each o& the

    aove to o+en modes there are to sections S%A>% 0:-S%S and S%A>% DO0S 5O% 0:-S%s+eci&ying the corres+onding translation strategies.

    3.1.3.1 !"#$T

    3.1.3.1.1 STRT '(!STS

    %his section s+eci&ies the translation strategy &or VSAM &iles ith inde'ed organi% is used.

    De&ine a cursor &or each VSAM &ile to select all the ros in the corres+onding tales.

    -& S%A>% is used and i& it uses &ull record ey in ey com+arison de&ine a cursor to select all the ros in

    the corres+onding tales here ey columns have values greater than or e8ual to the record ey values.

    De&ine the aove cursors to e O>D0> B? +rimary ey columns o& one o& the tales.

    De&ine a condition name in the oring storage section to e set and reset y S%A>% and OP05

    statements hen they o+en and close the cursor. %his condition name ill indicate the current o+enedcursor to e used y other o+erations.

    De&inition o& the condition name ill e

    *1 file'>C:*SO* P-C $ VA,60 *.

    "" file'>O)2, value 1.

    "" file'>STA*T>*% value 2.

    =here file'>O)2,ill e set hen the cursor corres+onding to OP05 is o+ened

    file'>STA*T>*% ill e set hen the cursor corres+onding to S%A>% is o+ened.

    Cursor definition for O)2, @

    1(

  • 7/26/2019 VSAM to DB2 Conversion

    13/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    OP05;C6>SO>

    Cursor definition for STA*T @

    S%A>%;C6>SO>

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 O+en the cursor file'>O)2,>C:*SO* . %his

    ill select all the ros in the tale. Set this cursorto e the current valid cursor hich can then eused y successive -9O o+erations till S%A>%

    re+ositions the &ile +osition indicator or C,OS0

    closes the &ile.

    0:0C S/,

    OP05 file'>O)2,;C:*SO*

    05D;0:0C.

    MOV0 1 %O file'>C:*SO* .

    S%A>% Start re+ositions the &ile +osition indicator y

    +o+ulating record ey &ields ith a++ro+riate

    values. -& the corres+onding cursor is already

    o+ened close the cursor and o+en it again.>eo+ening the cursor ill select the ros ased on

    the current value o& the host variales used in the

    =@0>0 clause. Set H&ile1;S%A>%;>I;

    C6>SO> to e the current valid cursor hich can

    e used y successive -9O o+erations till anotherS%A>% re+ositions the &ile +osition indicator or

    C,OS0 closes the &ile.

    -) H&ile1;S%A>%;>I

    %@05

    0:0C S/,

    C,OS0 file'>STA*T>

    *%>C:*SO*05D;0:0C

    05D;-).

    0:0C S/,

    OP05 file'>STA*T>*%>C:*SO*

    05D;0:0C.

    MOV0 2 %O file'>C:*SO* .

    >0AD or

    >0AD

    50:%

    -n se8uential access &iles >0AD 50:% is same as

    >0AD. Both o& them are se8uential read.

    >0AD 9 >0AD 50:% can &ollo either any one

    o& OP05 S%A>% or another >0AD9>0AD50:%.

    -& S%A>% e'ists then cursor to &etch ill e

    decided ased on the &lag hich states the current

    valid cursor. COBO, 0VA,6A%0 statement ill

    e used to mae the decision.

    0VA,6A%0 file'>C:*SO*

    =@05 file'>O)2,

    Se8uential;>ead;OP05;

    C6>SO>=@05 file'>STA*T>*%

    Se8uential;>ead;S%A>%;

    C6>SO>

    05D;0VA,6A%0

    C,OS0 -& S%A>% e'ists there ill e to o+ened cursors.

    Close oth the cursors at that +oint. Set the &lag toindicate no cursors are availale.

    0:0C S/,

    C,OS0 file'>O)2,;C:*SO*

    05D;0:0C

    0:0C S/,

    C,OS0 file'>STA*T>*%>C:*SO*

    05D;0:0C

    MOV0 * %O file'>C:*SO* .

    3.1.3.1.2 STRT )O'S "OT '(!ST

    %his section s+eci&ies the translation strategy &or VSAM &iles ith inde'ed organi% is not used.

    De&ine a cursor &or each VSAM &ile to select all the ros in the corres+onding tale O>D0> B? +rimary

    ey columns.

    Cursor definition for O)2, @

    OP05;C6>SO>

    1

  • 7/26/2019 VSAM to DB2 Conversion

    14/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 O+en the cursor file'>O)2,>C:*SO* . 0:0C S/,

    OP05 file'>O)2,;

    C:*SO*05D;0:0C.

    >0AD or

    >0AD50:%

    -n se8uential access &iles >0AD 50:% is same as

    >0AD. Both o& them are se8uential read. )0%C@the cursor de&ined on the corres+onding tale.

    Se8uential;>ead;OP05;C6>SO>

    C,OS0 Close the o+ened cursor. 0:0C S/,C,OS0 file'>O)2,;

    C:*SO*

    05D;0:0C

    3.1.3.2 !%O

    3.1.3.2.1 STRT%'(!STS

    %his section s+eci&ies the translation strategy &or VSAM &iles ith inde'ed organi% is used.

    De&ine a cursor &or each VSAM &ile to select all the ros in the corres+onding tale.

    -& start is used and i& start uses &ull record ey in ey com+arison de&ine a cursor to select all the ros inthe corres+onding tales here ey columns have values greater than or e8ual to the record ey values.

    De&ine the aove cursors to e O>D0> B? +rimary ey columns.

    De&ine a condition name in the oring storage section to e set and reset y S%A>% and OP05

    statements hen they o+en and close the cursor. %his condition name ill indicate the current o+ened

    cursor to e used y other o+erations.

    De&inition o& the condition name ill e

    *1 file'>C:*SO* P-C $ VA,60 *."" file'>O)2, value 1.

    "" file'>STA*T>*% value 2.

    =here H&ile1;OP05 ill e set hen the cursor corres+onding to OP05 is o+ened

    file'>STA*T>*% ill e set hen the cursor corres+onding to S%A>% is o+ened.

    Cursor definition for O)2, @

    OP05;C6>SO>

    Cursor definition for STA*T @

    S%A>%;C6>SO>

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 O+en the cursor file'>O)2,>C:*SO* .

    %his ill select all the ros in the tale. Set

    file'>O)2,>C:*SO* to e the current

    valid cursor hich can then e used ysuccessive -9O o+erations till S%A>%

    re+ositions the &ile +osition indicator or

    C,OS0 closes the &ile.

    0:0C S/,

    OP05 file'>O)2,>C:*SO*

    05D;0:0C.

    MOV0 1 %O file'>C:*SO* .

    S%A>% Start re+ositions the &ile +osition indicator

    y +o+ulating record ey &ields itha++ro+riate values. -& the corres+onding

    cursor is already o+ened close the cursor

    and o+en it again. >eo+ening the cursor ill

    -) H&ile1;S%A>%;>I

    %@050:0C S/,

    C,OS0 file'>STA*T>*%>

    C:*SO*

    1#

  • 7/26/2019 VSAM to DB2 Conversion

    15/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    select the ros ased on the current value o&

    the host variales used in the =@0>0

    clause. Set H&ile1;S%A>%;>I;C6>SO> to

    e the current valid cursor hich can eused y successive -9O o+erations till

    another S%A>% re+ositions the &ile +osition

    indicator or C,OS0 closes the &ile.

    05D;0:0C

    05D;-).

    0:0C S/,

    OP05 file'>STA*T>*%>C:*SO*

    05D;0:0C.

    MOV0 2 %O file'>C:*SO*"

    >0AD -n se8uential access &iles >0AD 50:% is

    same as >0AD. Both o& them are se8uential

    read.

    >0AD 9 >0AD 50:% can &ollo either anyone o& OP05 S%A>% or another

    >0AD9>0AD 50:%.

    -& S%A>% e'ists then cursor to &etch ill e

    decided ased on the &lag hich states thecurrent valid cursor. COBO, 0VA,6A%0

    statement ill e used to mae the decision.

    0VA,6A%0 file'>C:*SO*

    =@05 file'>O)2,

    Se8uential;>ead;OP05;C6>SO>

    =@05 file'>STA*T>*%Se8uential;>ead;S%A>%;C6>SO>

    05D;0VA,6A%0

    >0=>-%0 >andom;>erite

    =>-%0 -nsert the ne ros into res+ective tales. -nsert

    D0,0%0 Delete

    C,OS0 As there ill e to o+ened cursors one y

    the OP05 statement and another y S%A>%

    statement oth the cursors ill e closed at

    this +oint.

    0:0C S/,

    C,OS0 file'>O)2,>C:*SO*

    05D;0:0C

    0:0C S/,C,OS0 file'>STA*T>*%>

    C:*SO*

    05D;0:0CMOV0 * %O file'>C:*SO*

    3.1.3.2.2 STRT+)O'S "OT '(!ST

    %his section s+eci&ies the translation strategy &or VSAM &iles ith inde'ed organi% is not used.

    De&ine a cursor &or each VSAM &ile to select all the ros in the corres+onding tale O>D0> B? +rimary

    ey columns.

    De&ine the aove cursors to e O>D0> B? +rimary ey columns.

    Cursor definition for O)2, @

    OP05;C6>SO>

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 O+en the cursor de&ined &or the

    corres+onding &ile.

    0:0C S/,

    OP05 file'>O)2,>C:*SO*

    05D;0:0C.

    >0AD -n se8uential access &iles >0AD 50:% is

    same as >0AD. Both o& them are se8uentialread.

    >0AD 9 >0AD 50:% can &ollo either any

    one o& OP05 S%A>% or another

    >0AD9>0AD 50:%. )etch the file'>O)2,>C:*SO*.

    Se8uential;>ead;OP05;C6>SO>

    >0=>-%0 >andom;>erite

    =>-%0 -nsert ne ros into res+ective tales. -nsert

    1!

  • 7/26/2019 VSAM to DB2 Conversion

    16/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    D0,0%0 Delete

    C,OS0 Close the cursor o+ened corres+onding to

    the OP05 statement.

    0:0C S/,

    C,OS0 file'>O)2,>C:*SO*

    05D;0:0C

    3.1.3.3 O$T#$T & '(T'")

    -n this mode there ill e no >0AD 9 >0AD 50:% 9 S%A>% statements. Only alloed o+erations areOP05 =>-%0 and C,OS0.

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 Comment OP05 statement. 5one

    =>-%0 -nsert the ne ro into the corres+onding

    tale.Multi+le -5S0>%

    -nsert

    C,OS0 Comment C,OS0 statement 5one

    3.1., !nde*ed Organization Random ccess

    All the -9O o+erations in a &ile ith inde' organi0 condition.

    3.1.,.1 !"#$T

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 Comment the OP05 statement. 5one

    >0AD Select the record ith +rimary ey

    columns having values e8ual to record ey

    values.

    >andom;>ead

    C,OS0 Comment the C,OS0 statement 5one

    3.1.,.2 !%O

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 Comment the OP05 statement 5one

    >0AD Select the ro ith +rimary ey columns

    having values e8ual to record ey values.

    >andom;>ead

    >0=>-%0 6+date the ro ith +rimary ey columns

    having values e8ual to record ey values.Multi+le 6PDA%0

    >andom;>erite

    -5S0>% -nsert the ne ro into the tale

    corres+onding to the &ile.

    -nsert

    D0,0%0 Delete the ro ith +rimary ey columnshaving values e8ual to record ey values.

    Delete

    C,OS0 Comment C,OS0 statement. 5one

    3.1.,.3 O$T#$T

    O5era()*' "ecr)5()*' Tra'a(e C*eOP05 Comment the OP05 statement 5one

    =>-%0 -nsert the ne ro into the tale

    corres+onding to the &ile.

    -nsert

    C,OS0 Comment the C,OS0 statement 5one

    3.1.- !nde*ed Organization )namic ccess

    -9O o+erations in &iles ith inde'ed organi

  • 7/26/2019 VSAM to DB2 Conversion

    17/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    re+ositioned using S%A>% or random >0AD. >ecords can e read se8uentially using >0AD 50:% and

    randomly using >A5DOM >0AD.

    %ranslation strategy varies ased on the e'istence o& S%A>% >0AD and >0AD 50:%. )ile +osition

    indicator can e re+ositioned using either random >0AD or S%A>%.

    )or &iles o+ened in -5P6% or -;O mode &ile -9O o+erations can e se8uential or random or oth ased on

    the e'istence o& >0AD 50:% >A5DOM >0AD and S%A>%.)olloing are si' +ossile cases classi&ying the &ile o+eration to e se8uential or random or oth ased onthe e'istence o& >0AD 50:% >A5DOM >0AD and S%A>%.

    S.N*. REA"

    NE!T

    RAN"OM REA" START O5era()*'

    1 ?es 5o 5o Se8uential

    2 ?es ?es 5o Se8uential and >andom

    3 ?es 5o ?es Se8uential and >andom

    ( ?es ?es ?es Se8uential and >andom

    5o ?es ?es >andom

    # 5o ?es 5o >andom

    /uery translation &or

    Case 1 is same as &or &iles ith inde'ed organi

  • 7/26/2019 VSAM to DB2 Conversion

    18/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    OP05 O+en the cursor file'>O)2,>C:*SO* . 0:0C S/,

    OP05 file'>O)2,>

    C:*SO*

    05D;0:0C.MOV0 1 %O file'>C:*SO*.

    >A5DOM

    >0AD

    >A5DOM >0AD translates to S0,0C% ith

    =@0>0 clause. As >A5DOM >0ADre+ositions the &ile +osition indicator any+reviously o+ened cursor should e closed to

    +revent o+erations &olloing >A5DOM >0AD

    &rom using the cursor.

    >andom;>ead

    0VA,6A%0 file'>C:*SO*=@05 file'>O)2,0:0C S/,

    C,OS0 file'>O)2,>

    C:*SO*

    05D;0:0C=@05 file'>*2A>*%

    0:0C S/,

    C,OS0 file'>*2A>*%>

    C:*SO*05D;0:0C

    05D;0VA,6A%0

    MOV0 * %O file'>C:*SO*

    >0AD50:%

    >0AD 50:% is a se8uential o+eration andshould &ollo success&ul OP05 or >A5DOM

    >0AD or >0AD 50:%.

    -& the +revious o+eration is OP05 then that

    ould have o+ened the a++ro+riate cursor andhence )0%C@ on the cursor corres+onding to

    OP05 ill get the correct ro.

    -& the +revious o+eration is >A5DOM >0AD

    then that ould have selected the correct record.>ecord ey &ieldsE host variales F ould have

    got +rimary ey column values o& the selected

    record. O+ening the cursor file'>*2A>*%>

    C:*SO* ill select all the ros in thecorres+onding tale ith +rimary ey columns

    have values greater than record ey values and)0%C@ on that cursor ill get the correct

    record.-& the +revious o+eration is >0AD 50:% it

    ould have o+ened the a++ro+riate cursor and

    hence &etch on that cursor ill get the correctrecord.

    0VA,6A%0 file'>C:*SO*=@05 file'>O)2,

    Se8uential;>ead;OP05;

    C6>SO>

    =@05 file'>*2A>*%Se8uential;>ead;>0AD;

    C6>SO>

    =@05 *

    0:0C S/,OP05 file'>*2A>*%;

    C:*SO*.

    05D;0:0C

    Se8uential;>ead;>0AD;C6>SO>MOV0 2 %O file'>C:*SO*

    05D;0VA,6A%0

    C,OS0 Close the o+ened cursors. -) file'>O)2,>C:*SO*

    %@05

    0:0C S/,

    C,OS0 file'>O)2,;C6>SO>

    05D;0:0C

    05D;-).-) file'>*2A>*%>C:*SO*%@05

    0:0C S/,

    C,OS0 file'>*2A>*%;

    C:*SO*05D;0:0C

    05D;-).

    2*

  • 7/26/2019 VSAM to DB2 Conversion

    19/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.1.-.1.2 /ase ,

    %his section s+eci&ies the translation strategy &or VSAM &iles ith inde'ed organi0AD e'ists >A5DOM >0AD e'ists and S%A>% e'ists.

    De&ine a cursor &or each VSAM &ile to select all the ros in the corres+onding tale.

    -& >A5DOM >0AD is used and i& it uses record ey in ey com+arison de&ine a cursor to select all the

    ros in the corres+onding tale here ey columns have values greater than the record ey values.

    -& S%A>% is used and i& it uses record ey in ey com+arison de&ine a cursor to select all the ros in thecorres+onding tale here ey columns have values greater than or e8ual to the record ey values.

    De&ine the aove cursors to e O>D0> B? +rimary ey columns.

    De&ine a condition name in the oring storage section to e set and reset y >A5DOM >0AD S%A>%

    and OP05 statements hen they o+en and close the cursor. %his condition name ill indicate the current

    o+ened cursor to e used y other o+erations.

    De&inition o& the condition name ill e*1 file'>C:*SO* P-C $ VA,60 *.

    "" file'>O)2, value 1.

    "" file'>*2A>*% value 2.

    "" file'>STA*T>*% value 3.

    =here file'>O)2,ill e set hen the cursor corres+onding to OP05 is o+enedfile'>*2A>*%ill e set hen the cursor corres+onding to >0AD is o+ened

    file'>STA*T>*% ill e set hen the cursor corres+onding to S%A>% is o+ened.

    Cursor definition for O)2, @

    OP05;C6>SO>

    Cursor definition for STA*T @

    S%A>%;C6>SO>

    Cursor definition for *2A @

    >0AD;C6>SO>

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 O+en the cursor de&ined corres+onding to OP05statement.

    0:0C S/,OP05 file'>O)2,;

    C:*SO*

    05D;0:0C.

    MOV0 1 %O file'>C:*SO*.

    S%A>% Start re+ositions the &ile +osition indicator y

    +o+ulating record ey &ields ith a++ro+riate

    values.

    -& the corres+onding cursor is already o+enedclose the cursor and o+en it again. >eo+ening

    the cursor ill select the ros ased on the

    current value o& the host variales used in the=@0>0 clause. Set H&ile1;S%A>%;>I;C6>SO> to e the current valid cursor hich

    can e used y successive -9O o+erations till

    another S%A>%9>A5DOM >0AD re+ositions

    the &ile +osition indicator or C,OS0 closes the&ile.

    -) H&ile1;S%A>%;>I

    %@05

    0:0C S/,

    C,OS0 file'>STA*T>*%>C:*SO*

    05D;0:0C

    05D;-).0:0C S/,OP05 file'>STA*T>*%>

    C:*SO*

    05D;0:0C.

    MOV0 3 %O file'>C:*SO*.

    >A5DOM

    >0AD

    >A5DOM >0AD translates to S0,0C% ith

    =@0>0 clause. As >A5DOM >0AD

    >andom;>ead

    0VA,6A%0 file'>C:*SO*

    21

  • 7/26/2019 VSAM to DB2 Conversion

    20/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    re+ositions the &ile +osition indicator any

    +reviously o+ened cursor should e closed to

    +revent o+erations &olloing >A5DOM >0AD

    &rom using the cursor.

    =@05 file'>O)2,

    0:0C S/,

    C,OS0 file'>O)2,;

    C:*SO*05D;0:0C

    =@05 file'>*2A>*%

    0:0C S/,C,OS0 file'>*2A>*%;C:*SO*

    05D;0:0C

    =@05 file'>STA*T>*%

    0:0C S/,C,OS0 file'>STA*T>*%>

    C:*SO*

    05D;0:0C

    05D;0VA,6A%0MOV0 * %O file'>C:*SO*

    >0AD

    50:%

    >0AD 50:% is a se8uential o+eration and

    should &ollo either success&ul OP05 or

    >A5DOM >0AD or >0AD 50:% or S%A>%.-& the +revious o+eration is OP05 or S%A>%

    then that ould have o+ened the a++ro+riate

    cursor and hence )0%C@ on the cursor

    corres+onding to OP05 or S%A>% ill get thecorrect ro.

    -& the +revious o+eration is >A5DOM >0AD

    then that ould have selected the correct record.

    >ecord ey &ieldsE host variales F ould havegot +rimary ey column values o& the selected

    record. O+ening the cursor file'>*2A>*%>

    C:*SO* ill select all the ros in the

    corres+onding tale ith +rimary ey columnshave values greater than or e8ual to record ey

    values and )0%C@ on that cursor ill get thecorrect record.

    -& the +revious o+eration is >0AD 50:% itould have o+ened the a++ro+riate cursor and

    hence on that cursor ill get the correct record.

    0VA,6A%0 file'>C:*SO*

    =@05 file'>O)2,

    Se8uential;>ead;OP05;C6>SO>

    =@05 file'>*2A>*%

    Se8uential;>ead;>0AD;

    C6>SO>=@05 file'>STA*T>*%

    Se8uential;>ead;S%A>%;

    C6>SO>

    =@05 *0:0C S/,

    OP05 file'>*2A>*%;

    C:*SO*"

    05D;0:0CSe8uential;>ead;>0AD;C6>SO>

    MOV0 2 %O file'>C:*SO*05D;0VA,6A%0

    C,OS0 Close the o+ened cursors. Set the &lag to indicatethat there are no cursors availale.

    -) file'>O)2,>C:*SO*%@05

    0:0C S/,

    C,OS0 file'>O)2,;

    C:*SO*05D;0:0C

    05D;-).

    -) file'>*2A>*%>C:*SO*

    %@050:0C S/,

    C,OS0 file'>*2A>*%;

    C:*SO*

    05D;0:0C05D;-).

    -) file'>STA*T>*%>C:*SO*

    %@05

    0:0C S/,C,OS0 file'>STA*T>*%>

    22

  • 7/26/2019 VSAM to DB2 Conversion

    21/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    C:*SO*

    05D;0:0C

    05D;-).

    MOV0 * %O file'>C:*SO*

    3.1.-.2 !%O

    3.1.-.2.1 /ase 2

    %his section s+eci&ies the translation strategy &or VSAM &iles ith inde'ed organi0AD e'ists >A5DOM >0AD e'ists and S%A>% does not e'ist.

    De&ine a cursor &or each VSAM &ile to select all the ros in the corres+onding tale.

    -& >A5DOM >0AD is used and i& it uses record ey in ey com+arison de&ine a cursor to select all the

    ros in the corres+onding tale here ey columns have values greater than record ey values.

    De&ine the aove cursors to e O>D0> B? +rimary ey columns.

    De&ine a condition name in the oring storage section to e set and reset y >A5DOM >0AD andOP05 statements hen they o+en and close the cursor. %his condition name ill indicate the current

    o+ened cursor to e used y other o+erations.

    De&inition o& the condition name ill e

    *1 file'>C:*SO* P-C $ VA,60 *."" file'>O)2, value 1.

    "" file'>*2A>*% value 2.

    =here file'>O)2,ill e set hen the cursor corres+onding to OP05 is o+ened

    H&ile2;>0AD;>I ill e set hen the cursor corres+onding to >0AD is o+ened.

    Cursor definition for O)2, @

    OP05;C6>SO>

    Cursor definition for *2A @

    >0AD;C6>SO>

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 O+en the cursor file'>O)2,>C:*SO* de&ined corres+onding to OP05 statement.

    0:0C S/,OP05 file'>O)2,;

    C:*SO*

    05D;0:0C.

    MOV0 1 %O file'>C:*SO*.

    >A5DOM

    >0AD

    >A5DOM >0AD translates to S0,0C% ith

    =@0>0 clause. As >A5DOM >0AD

    re+ositions the &ile +osition indicator any

    +reviously o+ened cursor should e closed to+revent o+erations &olloing >A5DOM >0AD

    &rom using the cursor.

    >andom;>ead

    0VA,6A%0 file'>C:*SO*

    =@05 file'>O)2,

    0:0C S/,C,OS0 file'>O)2,;

    C:*SO*

    05D;0:0C=@05 file'>*2A>*%

    0:0C S/,

    C,OS0 file'>*2A>*%;

    C:*SO*05D;0:0C

    05D;0VA,6A%0

    23

  • 7/26/2019 VSAM to DB2 Conversion

    22/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    MOV0 * %O file'>C:*SO*

    >0AD

    50:%

    >0AD 50:% is a se8uential o+eration and

    should &ollo success&ul OP05 or >A5DOM

    >0AD or >0AD 50:%.-& the +revious o+eration is OP05 then that

    ould have o+ened the a++ro+riate cursor and

    hence )0%C@ on the cursor corres+onding toOP05 ill get the correct ro.-& the +revious o+eration is >A5DOM >0AD

    then that ould have selected the correct record.

    >ecord ey &ieldsE host variales F ould have

    got +rimary ey column values o& the selectedrecord. O+ening the cursor file'>*2A>*%>

    C:*SO* ill select all the ros in the

    corres+onding tale ith +rimary ey columns

    have values greater than record ey values and)0%C@ on that cursor ill get the correct

    record.

    -& the +revious o+eration is >0AD 50:% it

    ould have o+ened the a++ro+riate cursor andhence &etch on that cursor ill get the correct

    record.

    0VA,6A%0 file'>C:*SO*

    =@05 file'>O)2,

    Se8uential;>ead;OP05;C6>SO>

    =@05 file'>*2A>*%

    Se8uential;>ead;>0AD;C6>SO>=@05 *

    0:0C S/,

    OP05 file'>*2A>*%;

    C:*SO*.05D;0:0C

    Se8uential;>ead;>0AD;C6>SO>

    MOV0 2 %O file'>C:*SO*

    05D;0VA,6A%0

    >0=>-%0 >ecord to e reritten is s+eci&ied y the value

    contained in the +rime >0CO>D I0?.>0=>-%0 ill translate to 6PDA%0 ith

    =@0>0 clause.

    >andom;>erite

    D0,0%0 >ecord to e deleted is s+eci&ied y the value

    contained in the +rime >0CO>D I0?.D0,0%0 ill translate to D0,0%0 ith

    =@0>0 clause.

    Delete

    =>-%0 >ecord to e ritten is s+eci&ied y the value

    contained in the +rime >0CO>D I0?. =>-%0ill translate to -5S0>% ith =@0>0 clause.

    -nsert

    C,OS0 Close the o+ened cursors. Set the &lag to indicatethat there are no cursors availale.

    -) file'>O)2,>C:*SO*%@05

    0:0C S/,C,OS0 file'>O)2,;

    C:*SO*

    05D;0:0C

    05D;-).-) file'>*2A>*%>C:*SO*

    %@05

    0:0C S/,

    C,OS0 file'>*2A>*%;C:*SO*

    05D;0:0C

    05D;-).MOV0 * %O file'>C:*SO*

    3.1.-.2.1 /ase ,

    De&ine a cursor &or each VSAM &ile to select all the ros in the corres+onding tale.

    -& >A5DOM >0AD is used and i& it uses record ey in ey com+arison de&ine a cursor to select all the

    ros in the corres+onding tale here ey columns have values greater than record ey values.

    2(

  • 7/26/2019 VSAM to DB2 Conversion

    23/63

  • 7/26/2019 VSAM to DB2 Conversion

    24/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    05D;0:0C

    =@05 file'>STA*T>*%

    0:0C S/,

    C,OS0 file'>STA*T>*%>C:*SO*

    05D;0:0C

    05D;0VA,6A%0MOV0 * %O file'>C:*SO*

    >0AD

    50:%

    >0AD 50:% is a se8uential o+eration and

    should &ollo either success&ul OP05 or

    >A5DOM >0AD or >0AD 50:% or S%A>%.

    -& the +revious o+eration is OP05 or S%A>%then that ould have o+ened the a++ro+riate

    cursor and hence )0%C@ on the cursor

    corres+onding to OP05 or S%A>% ill get the

    correct ro.-& the +revious o+eration is >A5DOM >0AD

    then that ould have selected the correct record.

    >ecord ey &ieldsE host variales F ould have

    got +rimary ey column values o& the selectedrecord. O+ening the cursor file'>*2A>*%>

    C:*SO* ill select all the ros in the

    corres+onding tale ith +rimary ey columns

    have values greater than record ey values and)0%C@ on that cursor ill get the correct record.

    -& the +revious o+eration is >0AD 50:% it

    ould have o+ened the a++ro+riate cursor and

    hence &etch on that cursor ill get the correctrecord.

    0VA,6A%0 file'>C:*SO*

    =@05 file'>O)2,

    Se8uential;>ead;OP05;

    C6>SO>=@05 file'>*2A>*%

    Se8uential;>ead;>0AD;

    C6>SO>

    =@05 file'>STA*T>*%Se8uential;>ead;S%A>%;

    C6>SO>

    =@05 *

    0:0C S/,OP05 file'>*2A>*%;

    C:*SO*"

    05D;0:0C

    Se8uential;>ead;>0AD;C6>SO>MOV0 2 %O file'>C:*SO*

    05D;0VA,6A%0

    >0=>-%

    0

    >ecord to e reritten is s+eci&ied y the value

    contained in the +rime >0CO>D I0?.

    >0=>-%0 ill translate to 6PDA%0 ith=@0>0 clause.

    >andom;>erite

    D0,0%0 >ecord to e deleted is s+eci&ied y the valuecontained in the +rime >0CO>D I0?. D0,0%0

    ill translate to D0,0%0 ith =@0>0 clause.

    Delete

    =>-%0 >ecord to e ritten is s+eci&ied y the value

    contained in the +rime >0CO>D I0?. =>-%0

    ill translate to -5S0>% ith =@0>0 clause.

    -nsert

    C,OS0 Close the o+ened cursors. -) file'>O)2,>C:*SO*%@05

    0:0C S/,

    C,OS0 file'>O)2,;

    C:*SO*05D;0:0C

    05D;-).

    -) file'>*2A>*%>C:*SO*%@050:0C S/,

    C,OS0 file'>*2A>*%>

    C:*SO*

    05D;0:0C05D;-).

    -) file'>STA*T>*%>C:*SO*

    %@05

    2#

  • 7/26/2019 VSAM to DB2 Conversion

    25/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    0:0C S/,

    C,OS0 file'>STA*T>*%>

    C:*SO*

    05D;0:0C05D;-).

    MOV0 * %O file'>C:*SO*

    3.1.0.3 O$T#$T

    -n this mode there ill e no >0AD 9 >0AD 50:% 9 S%A>% statements. Only alloed o+erations are

    OP05 =>-%0 and C,OS0.

    O5era()*' "ecr)5()*' Tra'a(e C*e

    OP05 Comment OP05 statement. 5one

    =>-%0 -nsert the record into the corres+onding

    tale.

    -nsert

    C,OS0 Comment C,OS0 statement 5one

    2!

  • 7/26/2019 VSAM to DB2 Conversion

    26/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2 Online Program Translation

    0ach original +rogram ith emedded VSAM access call is assumed to have &olloing tem+late structure.

    %em+late also identi&ies some record structures that ill e added to the oring storage section o& the

    +rogram.

    -D05%-)-CA%-O5 D-V-S-O5.

    P>O7>AM;-D. Cics+rgm.

    05V->O5M05% D-V-S-O5.

    DA%A D-V-S-O5.

    =O>I-57;S%O>A70 S0C%-O5.

    *1 DA%A;>0CO>D.

    * DA%A;)-0,D;1 J.

    * DA%A;)-0,D;2 J..

    .

    *1 I0?;>0CO>D.

    * I0?;)-0,D;1 J.

    * I0?;)-0,D;2 J.

    *1 DA%A;>0C;,057%@J.

    1 I0?;>0C;,057%@J.

    1 %OI05;)-0,DJ.

    1 >0/-D;)-,0DJ1 CO65%;)-0,DJ

    *1 56M0>-C;CO65%J

    KKKK record structures elo needs to e added in the ne code KKKK

    1 DC,705;>0CO>D.

    DC,705;I0?.

    1* DC,705;I0?;)-0,D11* DC,705;I0?;)-0,D2

    .

    .

    DC,705;DA%A.1* DC,705;DA%A;)-0,D1

    1* DC,705;DA%A;)-0,D2

    .

    .

    9K this de&inition needs to e re+eated a++ro+riately K9

    9K &or each %OI05 used in +rogram K9*1 %OI05;DC,705;I0?.

    %OI05;DC,705;I0?;)-0,D1

    %OI05;DC,705;I0?;)-0,D2

    .

    .

    2"

  • 7/26/2019 VSAM to DB2 Conversion

    27/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    9K-ndicator to identi&y i& the cursor is de&ined &or a >0AD50:% or >0ADP>0V o+eration K9

    *1 =S;)65C%-O5;C6>SO> P-C :E*1F VA,60 .

    "" =S;50:%;C6>SO> VA,60 5."" =S;P>0V;C6>SO> VA,60 P.

    "" =S;5O;C6>SO> VA,60 .

    9K this de&inition needs to e re+eated a++ro+riately &or each >0S0%B> on a VSAM &ile using di&&erentrose criteria K9

    *1 =S;)65C%-O5;C6>SO>;1 P-C :E*1F VA,60 .

    "" =S;50:%;C6>SO>;1 VA,60 5."" =S;P>0V;C6>SO>;1 VA,60 P.

    "" =S;5O;C6>SO>;1 VA,60 .

    KKKK 0nd o& the ne addition KKKK

    P>OC0D6>0 D-V-S-O5.

    .

    .0:0C C-CS

    Vsam access call

    05D;0:0C.

    .

    .

    Discussion elo ill assume this +rogram tem+late and ill identi&y necessary changes to the code

    corres+onding to translation o& each command.

    2$

  • 7/26/2019 VSAM to DB2 Conversion

    28/63

  • 7/26/2019 VSAM to DB2 Conversion

    29/63

  • 7/26/2019 VSAM to DB2 Conversion

    30/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -) E >0AD is &or 6PDA%0 F

    L

    9K i& toen is s+eci&ied e'+licitly in +rogram &ind a++ro+riate %OI05;DC,705;I0? K99K corres+ondingly. K9

    MOV0 DC,705;I0? to %OI05;DC,705;I0?

    3.2.2 STRTR

    3.2.2.1 unction

    Start rose o& a &ile. %his is used to +osition the &ile +osition indicator at the desired record so thatVSAM read can e done &rom this record onards.

    3.2.2.2 /!/S Snta*

    0:0C C-CS

    S%A>%B>

    )-,0 E VSAM;)-,05AM0 F M &ile to e read

    >-D),D E I0?;>0CO>DF M ey record need to e +o+ulatede&ore call

    I0?,057%@ E I0?;>0C;,057%@F O no o& +osition o& ey to e matched

    &or +artial9generic search E

    mandatory hen generic o+tion iss+eci&iedF

    7050>-C O +artial ey match

    7%0/ 9 0/6A, O match ey &or 08ual or 7reaterthan or 08ual condition

    >BA O hen this o+tion is s+eci&ied

    >-D),D contains actual relativeyte address

    >>5 O hen this o+tion is s+eci&ied

    >-D),D contains actual >elative>ecord 5umer

    >0/-D E >0/-D;)-0,D F O used to identi&y is there are more

    than one rose on same &ile

    05D;0:0C

    &"!"!"& Translation of S#nta$

    .

    .

    -) E >0/-D;)-0,D is s+eci&ied F

    L

    32

  • 7/26/2019 VSAM to DB2 Conversion

    31/63

  • 7/26/2019 VSAM to DB2 Conversion

    32/63

  • 7/26/2019 VSAM to DB2 Conversion

    33/63

  • 7/26/2019 VSAM to DB2 Conversion

    34/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2.3.3 Translation of Snta*

    =O* *2A,24T COMMA,

    -) =S;50:%;C6>SO>E 0:0C S/,

    )0%C@ 50:%;C6>SO>5AM0

    -5%O 4DC,705;>0CO>D

    05D;0:0CF

    0,S0

    -) =S;P>0V;C6>SO>

    E0:0C S/,

    C,OS0 P>0V;C6>SO>5AM0

    05D;0:0C

    Move the VSAM ey values to the dclgen;record &ields to use in the =@0>0 clauseS0% =S;50:%;C6>SO> %O %>60

    0:0C S/,

    OP05 50:%;C6>SO>5AM005D;0:0C

    0:0C S/,

    )0%C@ 50:%;C6>SO>5AM0-5%O 4DC,705;>0CO>D

    05D;0:0C

    F

    05D;-)

    K this logic is to tae care o& the >0S0%B> done on the &ile ith di&&erent criteria than the S%A>%B>

    -) =S;50:%;C6>SO>;1E 0:0C S/,

    )0%C@ 50:%;C6>SO>5AM0 ;1

    -5%O 4DC,705;>0CO>D

    05D;0:0CF

    0,S0

    -) =S;P>0V;C6>SO>;1

    E0:0C S/,

    C,OS0 P>0V;C6>SO>5AM0;1

    05D;0:0C

    Move the VSAM ey values to the dclgen;record &ields to use in the =@0>0 clause

    S0% =S;50:%;C6>SO> %O %>60

    0:0C S/,OP05 50:%;C6>SO>5AM0;1

    05D;0:0C

    0:0C S/,)0%C@ 50:%;C6>SO>5AM0;1

    3#

  • 7/26/2019 VSAM to DB2 Conversion

    35/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -5%O 4DC,705;>0CO>D

    05D;0:0C

    F

    05D;-)

    =O* *2A)*2V COMMA,

    -) =S;P>0V;C6>SO>

    E 0:0C S/,

    )0%C@ P>0V;C6>SO>5AM0

    -5%O 4DC,705;>0CO>D05D;0:0C

    F

    0,S0

    -) =S;50:%;C6>SO>E

    0:0C S/,

    C,OS0 50:%;C6>SO>5AM0

    05D;0:0C

    Move the VSAM ey values to the dclgen;record &ields to use in the =@0>0 clause

    S0% =S;P>0V;C6>SO>;1 %O %>60

    0:0C S/,OP05 P>0V;C6>SO>5AM0

    05D;0:0C

    0:0C S/,)0%C@ P>0V;C6>SO>5AM0

    -5%O 4DC,705;>0CO>D

    05D;0:0C

    F05D;-)

    K this logic is to tae care o& the >0S0%B> done on the &ile ith di&&erent criteria than the S%A>%B>

    -) =S;P>0V;C6>SO>;1

    E 0:0C S/,

    )0%C@ P>0V;C6>SO>5AM0;1

    -5%O 4DC,705;>0CO>D05D;0:0C

    F

    0,S0

    -) =S;50:%;C6>SO>;1E

    0:0C S/,

    C,OS0 50:%;C6>SO>5AM0;105D;0:0C

    Move the VSAM ey values to the dclgen;record &ields to use in the =@0>0 clause

    S0% =S;P>0V;C6>SO>;1 %O %>60

    0:0C S/,OP05 P>0V;C6>SO>5AM0;1

    05D;0:0C

    0:0C S/,

    3!

  • 7/26/2019 VSAM to DB2 Conversion

    36/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    )0%C@ P>0V;C6>SO>5AM0;1

    -5%O 4DC,705;>0CO>D

    05D;0:0C

    F05D;-)

    MOV0 DC,705;>0CO>D %O DA%A;>0CO>D..

    .

    3"

  • 7/26/2019 VSAM to DB2 Conversion

    37/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2., 4R!T'

    3.2.,.1 unction

    =rite a record using the ey values s+eci&ied.

    3.2.,.2 /!/S Snta*

    0:0C C-CS

    =>-%0

    )-,0 E vsam;&ilename F M &ile to e read

    )>OM E DA%A;>0CO>D F M data area &rom here to recordneeds to e ritten

    ,057%@ E DA%A;>0C;,057%@F O length o& data record to e ritten

    >-D),D E I0?;>0CO>DF M ey record need to e +o+ulated

    e&ore call

    I0?,057%@ E I0?;>0C;,057%@F O generally this is s+eci&ied as lengtho& com+lete ey &ield

    >BA O hen this o+tion is s+eci&ied

    >-D),D contains actual relative

    yte address>>5 O hen this o+tion is s+eci&ied

    >-D),D contains actual >elative

    >ecord 5umer

    05D;0:0C

    3.2.,.3 Translation of Snta*

    .

    .

    MOV0 DA%A;>0CO>D %O DC,705;>0CO>D.

    0:0C S/,

    -5S0>% -5%O L d2;talename corres+onding to vsam;&ilename VA,60S A>0 L 4DC,705;>0CO>D &ields

    05D;0:0C

    3$

  • 7/26/2019 VSAM to DB2 Conversion

    38/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2.- R'4R!T'

    3.2.-.1 unction

    6+date a record in a &ile &or the ey values s+eci&ied. >0=>-%0 can e done a&ter e'ecuting a >0AD )O>

    6PDA%0 or it can e a random >0=>-%0 also.

    3.2.-.2 /!/S Snta*

    0:0C C-CS

    >0=>-%0

    )-,0 E vsam;&ilename F M &ile to e read

    )>OM E DA%A;>0CO>D F M data area &rom here to record

    needs to e ritten

    ,057%@ E DA%A;>0C;,057%@F O length o& data record to e reritten

    %OI05 E %OI05;)-0,D F O used to identi&y multi+le records

    read &or 6PDA%09>0=>-%005D;0:0C

    3.2.-.3 Translation of Snta*

    .

    .

    MOV0 DA%A;>0CO>D %O DC,705;>0CO>D

    -& E toen is e'+licitly s+eci&ied in command

    L

    use it to identi&y corres+onding %OI05;DC,705;I0?

    hich can e used in here clause

    0:0C S/,

    6PDA%0 L d2;talename corres+onding to vsam;&ilename S0% d2;column;names 4DC,705;>0CO>D &ields

    =@0>0 d2;column;names 4%OI05;DC,705;I0? or DC,705;>0CO>D;I0?

    05D;0:0C

    .

    (*

  • 7/26/2019 VSAM to DB2 Conversion

    39/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2.0 )'5'T'

    &"!"8"' =unction

    Delete a record &rom a &ile

    3.2.0.2 /!/S Snta*

    0:0C C-CS

    D0,0%0

    )-,0 E vsam;&ilename F M &ile &or delete

    >-D),D E I0?;>0CO>DF O ey record need to e +o+ulatede&ore call

    I0?,057%@ E I0?;>0C;,057%@F O no o& +osition o& ey to e matched&or +artial9generic match E

    mandatory hen generic o+tion is

    s+eci&iedF

    7050>-C O +artial ey match

    >BA O hen this o+tion is s+eci&ied

    >-D),D contains actual relative

    yte address

    >>5 O hen this o+tion is s+eci&ied

    >-D),D contains actual >elative

    >ecord 5umer

    %OI05 E %OI05;)-0,D F O used to identi&y record to e

    deleted hich as identi&ied y

    read &or 6PDA%09>0=>-%056M0>-C E 56M0>-C;CO65% F O %his variale is +o+ulated ith

    numer o& records deleted

    05D;0:0C

    3.2.0.3 Translation Of Snta*

    -) E %oen is S+eci&ied F

    LMOV0 %OI05;DC,705;I0? %O DC,705;I0?.

    -) E >-D),D is s+eci&ied FL

    MOV0 I0?;>0CO>D to DC,705;I0? N

    (1

  • 7/26/2019 VSAM to DB2 Conversion

    40/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -& E I0?,057%@ is s+eci&ied F

    L

    identi&y e'act &ields &rom I0?;>0CO>DNcorres+onding to these &ields identi&y DC,705;I0? &ields

    else

    Lall &ields o& DC,705;I0? ill +artici+ate in =@0>0 clause

    >elational O+erator is

    using DB2 columnnames and corres+onding DC,705;I0? &ields as identi&ied e&ore and y using

    relational o+erator &orm the =@0>0 clause N

    0:0C S/,

    D0,0%0 Ed2;talename corres+onding to vsam;&ilename F

    =@0>0 E here clause as &ormated e&ore F05D;0:0C

    MOV0 S/,0>>DE3F %O 56M0>-C;CO65%

    (2

  • 7/26/2019 VSAM to DB2 Conversion

    41/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2.6 $"5O/7

    3.2.6.1 unction

    >elease e'clusive control o& the &ile. 65,OCI &ile is usually done a&ter a >0AD )O> 6PDA%0 is

    e'ecuted on the &ile and it is decided that no u+date needs to e done to the record. 65,OCI also needs to

    e +er&ormed a&ter VSAM MASS-5S0>%.

    3.2.6.2 /!/S Snta*

    0:0C C-CS

    65,OCI

    )-,0 E vsam;&ilename F M &ile to e unloced

    %OI05 E %OI05;)-0,D F O 0'+licitly s+eci&ied >0AD &oru+date to e unloced

    05D;0:0C

    3.2.6.3 Translation of Snta*

    5o S/, statement ill e added &or this ecause DB2 taes care o& data locing de+ending on theind o+tions used. Any resources loced ill e released a&ter a COMM-%.

    Since the >0AD ith 6PDA%0 o+tion is eing translated to a S/, S0,0C% and the corres+onding

    >0=>-%0 is eing translated to the an 6PDA%0 on the tale the scenario o& the )-,0 65,OCI does

    not a++ear in the tale o+eration.

    >e+lace this command ith initialiecords &or >0AD ith 6PDA%0.

    -& s+eci&ic %OI05 is s+eci&ied then initiali

  • 7/26/2019 VSAM to DB2 Conversion

    42/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2.8 '")R

    3.2.8.1 unction

    0nd rose o& a &ile.

    3.2.8.2 /!/S Snta*

    0:0C C-CS

    05DB>

    )-,0 E vsam;&ilename F M &ile to e read

    >0/-D E >0/-D;)-0,D F O used to identi&y i& there are more

    than one rose on same &ile05D;0:0C

    3.2.8.3 Translation Of Snta*

    -) E >0/-D;)-0,D is s+eci&ied F

    L

    use it in determining 50:%;C6>SO>5AM0 and P>0V;C6>SO>5AM0

    -& E >0AD50:% o+eration e'istsF

    L

    0:0C S/,C,OS0 50:%;C6>SO>5AM0

    05D;0:0C

    else-& E >0ADP>0V o+erations e'ists F

    L

    0:0C S/,

    C,OS0 P>0V;C6>SO>5AM005D;0:0C

    ((

  • 7/26/2019 VSAM to DB2 Conversion

    43/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    3.2.9 R'S'TR

    3.2.9.1 unction

    >eset start o& rose. %he &ile +osition indicator is set to the +osition at the record ith the ne ey values

    s+eci&ied.

    3.2.9.2 /!/S Snta*

    0:0C C-CS

    >0S0%B>

    )-,0 E VSAM;)-,05AM0 F M &ile to e read

    >-D),D E I0?;>0CO>DF M ey record need to e +o+ulatede&ore call

    I0?,057%@ E I0?;>0C;,057%@F O no o& +osition o& ey to e matched&or +artial9generic search E

    mandatory hen generic o+tion iss+eci&iedF

    7050>-C O +artial ey match

    7%0/ 9 0/6A, O match ey &or 08ual or 7reaterthan or 08ual condition

    >BA O hen this o+tion is s+eci&ied

    >-D),D contains actual relativeyte address

    >>5 O hen this o+tion is s+eci&ied

    >-D),D contains actual >elative>ecord 5umer

    >0/-D E >0/-D;)-0,D F O used to identi&y is there are more

    than one rose on same &ile05D;0:0C

    3.2.9.3 Translation Of Snta*

    -) E >0/-D;)-0,D is s+eci&ied FL

    use it in determining 50:%;C6>SO>5AM0 and P>0V;C6>SO>5AM0

    Move the ey values s+eci&ied in the >0S0%B> to the DC,705 &ields.

    C:*SO* 2CLA*ATIO,

    %he >0S0%B> can use either the same criteria that the S%A>%B> used or it can reset the &ile +osition

    indicator using some other criteria e'am+le the S%A>%B> may e having a 0/6A, condition ut the

    (

  • 7/26/2019 VSAM to DB2 Conversion

    44/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    >0S0%B> can use a 7%0/ condition. Veri&y i& the conditions s+eci&ied in the >0S0%B> is di&&erent than

    in the S%A>%B>. -& the conditions are di&&erent then ne cursors ill have to e de&ined &or >0S0%B>

    using the ne criteria.

    -n case ne cursors have to e de&ined i& only >0AD50:% o+eration is +resent in the +rogram &or the

    VSAM &ile then declare only the cursor &or readne't E50:%;C6>SO>5AM0F. -& only >0ADP>0V

    o+eration is +resent in the +rogram &or a VSAM &ile then declare only the cursor &or read+rev EP>0V;

    C6>SO>5AM0F. Both the cursors ill e declared i& >0ADP>0V and >0AD50:% is eing done on a&ile in the +rogram.

    0:0C S/,

    D0C,A>0 C6>SO> 50:%;C6>SO>5AM0;1 )O>S0,0C% K

    )>OM L d2;talename corres+onding to vsam;&ilename

    =@0>0 L a++ro+riate here clause ith tale&ields and o+erator

    05D;0:0C

    0:0C S/,

    D0C,A>0 C6>SO> P>0V;C6>SO>5AM0;1 )O>

    S0,0C% K

    )>OM L d2;talename corres+onding to vsam;&ilename =@0>0 L a++ro+riate here clause ith tale&ields and H o+erator

    05D;0:0C

    *2)LACI,+ T(2 *2S2TB* COMMA,

    -& =S;50:%;C6>SO>L

    S0% =S;5O;C6>SO> %O %>60

    0:0C S/,

    C,OS0 50:%;C6>SO>5AM005D;0:0C

    else

    -& =S;P>0V;C6>SO>L

    S0% =S;5O;C6>SO> %O %>60

    0:0C S/,

    C,OS0 P>0V;C6>SO>5AM005D;0:0C

    .

    -& =S;50:%;C6>SO>;1L

    S0% =S;5O;C6>SO>;1 %O %>60

    0:0C S/,C,OS0 50:%;C6>SO>5AM0;105D;0:0C

    else

    -& =S;P>0V;C6>SO>;1L

    S0% =S;5O;C6>SO>;1 %O %>60

    0:0C S/,C,OS0 P>0V;C6>SO>5AM0;1

    (#

  • 7/26/2019 VSAM to DB2 Conversion

    45/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    05D;0:0C

    .

    %he =@0>0 0:-S%S clause is used &irst to do a S0,0C% on the tale. -& any ros are &ound ith

    matching condition then only the cursor is o+ened. )or this +ur+ose the Standard Dummy tale

    S?S-BM.S?SD6MM?1 is used.%he translated code ill loo as given elo 4

    0:0C S/, S0,0C% -BM>0/D )>OM S?S-BM.S?SD6MM?1

    -5%O 4=S;-BM>0/D=@0>0 0:-S%S

    ES0,0C% K )>OM d2;tale;name

    =@0>0 d2;column;name For D G 4 dclgen;record &ieldsF

    05D;0:0C.

    (!

  • 7/26/2019 VSAM to DB2 Conversion

    46/63

  • 7/26/2019 VSAM to DB2 Conversion

    47/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    4 Otimi!ing "or Performance

    4.1 Selecting only the require !iels

    -t is +re&erred that the only the re8uired columns are selected in the 8uery.

    4.2 Aing "ommit logic

    Batch +rograms hich handle large volume o& data and do u+dates inserts or deletes on the DB2 tales illhave etter +er&ormance i& commit logic is added to commit the changes a&ter the numer o& ros

    +rocessed reaches a +redetermined value. @oever &or any cursor o+erations &or hich the commit logic is

    used should have the cursor de&ined ith o+tion =-%@ @O,D otherise the cursor +osition is lost a&ter

    the commit.

    4.3 #$ate only the require columns

    Only columns re8uired to e u+dated should e retained in the u+date statements. %his is es+ecially true i&

    the column is inde'ed and is eing u+dated unnecessarily.

    ($

  • 7/26/2019 VSAM to DB2 Conversion

    48/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    # Aendi$

    -.1.1 Sequential Read O#'"%/$RSOR

    0:0C S/,)0%C@ file'>O)2,>C:*SO*

    -5%O Hres+ective;&ields

    05D;0:0C

    -) S/,COD0 1**%@05

    at>end>imperative>stmtsQ 50:% S05%05C0

    0,S0

    -) S/,COD0 *%@05

    0:0C S/,

    OP05 C6>SO>de+endant;cursor;1

    05D;0:0CMOV0 1 %O db!>count

    P0>)O>M)0%C@;PA>A;165%-, Hdb!>count Hdb!>arra#>'>si.e A5D

    S/,COD0 1**

    0:0C S/,C,OS0 C6>SO> de+endant;cursor;1

    05D;0:0C

    ...

    0:0C S/,OP05 C6>SO>de+endant;cursor;n

    05D;0:0C

    MOV0 1 %O db!>count

    P0>)O>M)0%C@;PA>A;n65%-, Hdb!>count Hdb!>arra#>n>si.e A5DS/,COD0 1**

    0:0C S/,

    C,OS0 C6>SO> de+endant;cursor;n05D;0:0C

    not>at>end>imperative>stmts

    0,S0

    D-SP,A? R 0>>O> -5 )0%C@ R05D;-)

    05D;-).

    *

  • 7/26/2019 VSAM to DB2 Conversion

    49/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -.1.2 Sequential Read STRT%/$RSOR

    0:0C S/,

    )0%C@ file'>STA*T>C:*SO*

    -5%O Hres+ective;&ields

    05D;0:0C-) S/,COD0 1**

    %@05

    at>end>imperative>stmtsQ 50:% S05%05C0

    0,S0-) S/,COD0 *

    %@05

    0:0C S/,

    OP05 C6>SO>de+endant;cursor;105D;0:0C

    MOV0 1 %O db!>count

    P0>)O>M)0%C@;PA>A;165%-, Hdb!>count Hdb!>arra#>'>si.e A5D

    S/,COD0 1**

    0:0C S/,C,OS0 C6>SO> de+endant;cursor;1

    05D;0:0C

    ...0:0C S/,

    OP05 C6>SO>de+endant;cursor;n

    05D;0:0C

    MOV0 1 %O db!>countMOV0 arra#>n>si.e%O B!>A**A;>n>SIH2

    P0>)O>M)0%C@;PA>A;n65%-, Hdb!>countH Hdb!>arra#>n>si.e A5D

    S/,COD0 1**

    0:0C S/,C,OS0 C6>SO> de+endant;cursor;n

    05D;0:0C

    not>at>end>imperative>stmts

    0,S0D-SP,A? R 0>>O> -5 )0%C@ R

    05D;-)

    05D;-).

    1

  • 7/26/2019 VSAM to DB2 Conversion

    50/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -.1.3 Sequential Read R')%/$RSOR

    0:0C S/,

    )0%C@ file'>*2A>C:*SO*

    -5%O Hres+ective;&ields

    05D;0:0C-) S/,COD0 1**

    %@05

    at>end>imperative>stmtsQ 50:% S05%05C0

    0,S0-) S/,COD0 *

    %@05

    0:0C S/,

    OP05 C6>SO>de+endant;cursor;105D;0:0C

    MOV0 1 %O db!>count

    P0>)O>M)0%C@;PA>A;165%-, db!>count db!>arra#>'>si.e A5D

    S/,COD0 1**

    0:0C S/,C,OS0 C6>SO> de+endant;cursor;1

    05D;0:0C

    ...0:0C S/,

    OP05 C6>SO>de+endant;cursor;n

    05D;0:0C

    MOV0 1 %O db!>countP0>)O>M)0%C@;PA>A;n65%-, Hdb!>count Hdb!>arra#>n>si.e A5D

    S/,COD0 1**

    0:0C S/,

    C,OS0 C6>SO> de+endant;cursor;n05D;0:0C

    not>at>end>imperative>stmts

    0,S0

    D-SP,A? R 0>>O> -5 )0%C@ R05D;-)

    05D;-).

    2

  • 7/26/2019 VSAM to DB2 Conversion

    51/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -.1., Random Read

    0:0C S/,S0,0C% table>'>col>'... table>'>col>n

    ...

    table>n>col>'...table>n>col>n

    )>OM table>'...table>n-5%O Hres+ective;&ields

    05D;0:0C

    -) S/,COD0 *

    %@050:0C S/,

    OP05 C6>SO> de+endant;cursor;1

    05D;0:0C

    MOV0 1 %O db!>countP0>)O>M)0%C@;PA>A;165%-, db!>count db!>arra#>'>si.e A5D S/,COD0

    1**

    0:0C S/,

    C,OS0 C6>SO> de+endant;cursor;1

    05D;0:0C...

    0:0C S/,

    OP05 C6>SO> de+endant;cursor;n05D;0:0C

    MOV0 1 %O db!>count

    P0>)O>M)0%C@;PA>A;n65%-, Hdb!>count Hdb!>arra#>n>si.e A5D S/,COD0 1**

    0:0C S/,C,OS0 C6>SO> de+endant;cursor;n

    05D;0:0C

    not>invalid>?e#>imperative>stmts

    0,S0invalid>?e#>imperative>statementsQ 50:% S05%05C0

    05D;-).

    3

  • 7/26/2019 VSAM to DB2 Conversion

    52/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -.1.- !nsert

    0:0C S/,-5S0>% -5%O table>'Etable>'>col>'... table>'>col>nF

    VA,60S EHres+ective;&ieldsF

    05D;0:0C.

    -) S/,COD0 *%@05

    0:0C S/,

    -5S0>% -5%O table>!Ftable>!>col>' """ table>!>col>nG

    VA,60S EHres+ective;&ieldsF05D;0:0C

    05D;-)

    ...

    -) S/,COD0 *%@05

    0:0C S/,

    -5S0>% -5%O table>nEtable>n>col>'... table>n>col>nF

    VA,60S EHres+ective;&ieldsF

    05D;0:0C05D;-)

    -) S/,COD0 *

    %@05MOV0 1 %O db!>count

    P0>)O>M-5S0>%;PA>A;165%-, db!>count db!>arra#>'>si.e A5D S/,COD0 *

    ...

    MOV0 1 %O db!>countP0>)O>M-5S0>%;PA>A;n65%-, Hdb!>count Hdb!>arra#>n>si.e A5D S/,COD0 *

    05D;-)

    -) S/,COD0 *

    %@05not>invalid>?e#>statementsQ 50:% S05%05C0

    0,S0

    invalid>?e#>statementsQ D-SP,A? R0rror -n -nsert R

    05D;-)

    (

  • 7/26/2019 VSAM to DB2 Conversion

    53/63

  • 7/26/2019 VSAM to DB2 Conversion

    54/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    05D;-)

    -) S/,COD0 *

    %@05

    not>invalid>?e#>statementsQ 50:% S05%05C00,S0

    invalid>?e#>statementsQ D-SP,A? R0rror -n 6+date R

    05D;-)

    #

  • 7/26/2019 VSAM to DB2 Conversion

    55/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -.1.6 )elete

    0:0C S/,D0,0%0 table>'

    =@0>0table>'>?e#>col>' table>'>?e#>col>'>?e#>fld>'

    ...

    table>'>?e#>col>n D table>'>?e#>col>n>?e#>fld>n05D;0:0C.

    -) S/,COD0 *

    %@05

    0:0C S/,D0,0%0 table>!

    =@0>0table>!>?e#>col>' D table>!>?e#>col>'>?e#>fld>'

    """

    table>!>?e#>col>n D table>!>?e#>col>n>?e#>fld>n05D;0:0C.

    05D;-)

    ...

    -) S/,COD0 *

    %@05 0:0C S/,

    D0,0%0 table>n

    =@0>0table>n>?e#>col>' D table>n>?e#>col>'>?e#>fld>'"""

    table>n>?e#>col>n D table>n>?e#>col>n>?e#>fld>n

    05D;0:0C.

    05D;-)-) S/,COD0 *

    %@05

    not>invalid>?e#>statementsQ 50:% S05%05C0

    0,S0invalid>?e#>statementsQ D-SP,A? R0rror -n DeleteR

    05D;-)

    !

  • 7/26/2019 VSAM to DB2 Conversion

    56/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -.1.8 O#'"%/$RSOR

    -& &ile organi0 file'>O)2,>C:*SO* C6>SO> )O>

    S0,0C% table>'>col>'... table>'>col>n...

    table>n>col>'...table>n>col>n

    )>OM table>'...table>n05D;0:0C

    -& &ile organiO)2,>C:*SO* C6>SO> )O>

    S0,0C% table>'>col>'... table>'>col>n...

    table>n>col>'...table>n>col>n

    )>OM table>'...table>n

    O>D0> B? table>'>?e#>col>'... table>'>?e#>col>n05D;0:0C

    "

  • 7/26/2019 VSAM to DB2 Conversion

    57/63

  • 7/26/2019 VSAM to DB2 Conversion

    58/63

    VSAM to DB2 Online and Batch Program Conversion Strategy

    -.1.1; R')%/$RSOR

    0:0C S/,D0C,A>0 Hfile'>*2A>*%>C:*SO*C6>SO> )O>

    S0,0C% table>'>col>'... table>n>col>n

    ...

    table>n>col>'...table>n>col>n)>OM table>'...table>n

    =@0>0 table>'>?e#>col>' rec>?e#>fld>'

    table>'>?e#>col>n rec>?e#>fld>n

    table>!>?e#>col>n table>'>?e#>col>'table>!>?e#>col>n table>'>?e#>col>n

    ...

    table>n>?e#>col>n table>'>?e#>col>'

    table>n>?e#>col>n table>'>?e#>col>nO>D0> B? table>'>?e#>col>'... table>'>?e#&g