Page 1 of 1

need explanation on flow of perform stmt?

Posted: Thu Dec 16, 2010 2:20 am
by nikilkarna
can some one explain the flow of this one?

Code: Select all

procedure division.
    DISPLAY "In TopLevel. Starting to run program"
    PERFORM OneLevelDown
    DISPLAY "Back in TopLevel.".
    DISPLAY " Now in TwoLevelsDown."
    PERFORM ThreeLevelsDown.
    DISPLAY " Back in TwoLevelsDown.".
    DISPLAY " Now in OneLevelDown"
    PERFORM TwoLevelsDown
    DISPLAY " Back in OneLevelDown".
    DISPLAY " Now in ThreeLevelsDown".
[ CODE ] [ / code ] tags added by dbz
refer here for explanation of BBCode

Posted: Thu Dec 16, 2010 2:07 pm
by dbzTHEdinosauer
nikilkarna wrote:can some one explain the flow of this one?
what is the output when you run the program?

each paragraph has a
  • DISPLAY enter paragraph
  • PERFORM someother-para
  • DISPLAY exit (back in) paragraph
rather straight forward.

Posted: Thu Dec 16, 2010 3:46 pm
by Vamsi99
TopLevel para executes Oneleveldown para.. in which it will call .. twoleveldown para.. in whcih it will call Threeleveldown para...

Might be .. this is an example.. to explain.. how PERFORM will work in COBOL.
and how control pass thru this program.

When you run.. based on output you can understand how control passed between threse paras.

PERFORM - It will execute the sepcified para and control return back to next statement after PERFORM.

Posted: Thu Dec 16, 2010 7:19 pm
by nikilkarna
i need output of this program and the control flow. As vamsi said that it will execute the specific para(OneLevelDown) and will the control comes back to statement(display in the para and stop run will encounter) or will it pass to the next statement(next perform).

Posted: Thu Dec 16, 2010 7:28 pm
by dbzTHEdinosauer

you need to RTFM and learn basics for COBOL. Learn about the Perform Statement.

compile and execute the program and gather your own output.

Posted: Tue Dec 28, 2010 12:42 pm
by Anuj Dhawan
I agree with Dick and suggest to compile/execute the program to know (understand) the flow of the Program.

And why don't you do it (compile/execute) as the first thing, by the way!

Posted: Sun Jan 02, 2011 8:56 pm
by Natarajan
following cobol material from mainframegurukul , may be useful to you to learn cobol. ... orial.html