COBOL_Training_Class-8.ppsx

Embed Size (px)

Citation preview

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    1/14

    Control SequenceVerbs

    COBOL Training Class-8

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    2/14

    STOP RUN

    GOTO

    GOBACK

    EXIT

    EXIT-PROGRAM

    PERFORM

    Control Sequence Verbs

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    3/14

    CONTROL VERBS

    STOPRUNis used to stop programs and return the control

    back to OS (MVS). Do not use STOP RU in sub programs.

    EXITis used to e!it paragraph or program i" #$%T %S US#D the

    its must be the onl& entr& in that paragraph. the e!itstatement does nothing. %" EXIT-PROR!"is used to e!it a

    subprogram

    OB!C#is used to e!it programs. 'hen used in called

    program it has the same e""ect o" #$%TPROR*Mstatement

    and +hen used in main program +orks as STOPRU.

    OTOis used to trans"er control to another part o" the

    program, -ontrol +ill not return back.

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    4/14

    PERFORM: Passes the control to specified paragraph, But

    control will return back.

    Perform is of two types: 1. INLIN P!"#!$

    %.#&'LIN P!"#!$

    ININEPERFORM: 'he statements lie In between the scope of

    perform ( P!"#!$ ) N*+P!"#!$

    OUTINEPERFROM: 'he statements lie with+in a paragraph,

    control returns back to the ne-t statement of it.

    PERFORM IN !ETAI

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    5/14

    T$%es O& Per&or's(

    1. impleperformis used to e-ecute the referenced code one time

    %. PerformNtimesis used to e-ecute the code multiple times. theactual number of times is indicated by identifier or integer.

    /. Perform&ntilconditionis used to e-ecute the code multipletimes but dependent upon the &N'ILcondition. 'he conditionwill be tested before the code is actually testes unless the 0I'

    ''2"'!is included.

    3. Perform'hruis used to e-ecute code from one particularparagraph to another in se4uence.

    5. Perform6aryingis used to e-ecute multiple times by using72!8IN9phase used to count in a 6ariable.

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    6/14

    ynta- :

    P!"#!$ P!"#!$N'I$ P!"#!$&N'IL#N*I'I#N

    '2'$N'1 '2'$N'1 '2'$N'1

    '2'$N'% '2'$N'% '2'$N'%" " "

    . . .

    N*+P!"#!$. N*+P!"#!$. N*+P!"#!$.

    Note# No I$%l&c&t ter$&n'tor &n bet(een t)e sco%e"

    ININE PERFORM

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    7/14

    Nee) to #no*

    'he P!"#!$and N*+P!"#!$statements bracket all

    #B#L II statements between them.

    In line P!"#!$swork as long as there are no internal

    9#'#s, not e6en to an ;I'. 'he inline P!"#!$ forreadability should not e-ceed a page length it would be better

    to put the code in a separate Para and use P!"#!$

    Para+name rather than in+line perform.

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    8/14

    OUTLINE PER+OR"

    #&'LIN perform statement causes the program to transfer control to

    another paragraph, e-ecute all the statement within the paragraph, and

    return to the statement following the P!"#!$ statement.

    S*nt'+

    PERFORMPARANAME"

    PERFORMPARANAMEN TIMES"

    PERFORMPARANAMEUNTICON!ITION"

    PERFORMPARANAME,TRUPARANAME."

    PARANAME"

    STATEMENT,"

    STATEMENT."

    . . . . .

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    9/14

    TEST BE+ORE , !+TER

    If ''B"#!is specified, the condition is

    tested at the beginning of each repeated e-ecution

    of the specified P!"#!$ range.

    If ''2"'!is specified, the condition is

    tested at the end of the each repeated e-ecution of

    the P!"#!$ range. 0ith ''2"'!, the

    range is e-ecuted at least once.

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    10/14

    I! !IVISION"

    PROGRAM-I!" EMP!ETPG"

    ENVIROMENT !IVISION"

    !ATA !IVISION"

    /ORKING-STORAGE SECTION"

    0, /S-EMP!ET"

    01 EMPI! PIC X213 VAUE SPACES"

    01 ENAME PIC X2,03 VAUE SPACES"

    01 EOC PIC X2,03 VAUE SPACES"

    01 ESA PIC 4213V42.3 VAUE SPACES"

    PROCE!URE !IVISION"

    MAIN-PARA"

    PERFORMACCEPT EMPI!

    ACCEPT ENAME

    ACCEPT EOC

    ACCEPT ESA

    !ISPA5 /S-EMP!ET

    EN!-PERFORM" STOP RUN"

    EXAMPE-,

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    11/14

    P!#*&! *I7II#N.

    $2IN+P2!2.

    P!"#!$ 2P'+P2!2.

    P!"#!$ *IPL28+P2!2.

    '#P !&N.2P'+P2!2.

    2P' $PI*.

    2P' N2$.

    2P' L#. 2P' 2L.

    *IPL28+P2!2.

    *IPL28 0+$P*'.

    EXAMPE-.

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    12/14

    +e* Ti%s to Re'e'ber

    1. &se the P!"#!$statement to access code which needs to bee-ecuted from more than one location.

    %. &se the P!"#!$ statement to structure your code. $ake a mainroutine that P!"#!$#'! !#&'IN.

    /. &se the 0I' ''2"'!option to force the code toP!"#!$* at least once.

    3. If the number of lines in the routine is relati6ely small. &se an in+lineP!"#!$ instead of outline P!"#!$.

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    13/14

    Tr$ Out

    0, /S-NPIC 42.3VAUE 6ERO"

    A-PARA"

    MOVE 1TO /S-N"

    PERFORM B-PARA/S-NTIMES"

    B-PARA"

    MOVE ,0TO /S-N"

    O/ MAN5 TIMES /I B-PARA BE EXECUTE! 7

  • 7/27/2019 COBOL_Training_Class-8.ppsx

    14/14

    Tan. /ou