need explanation on flow of perform stmt?

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
nikilkarna
Member
Posts: 2
Joined: Thu Dec 16, 2010 2:08 am
Location: IN

need explanation on flow of perform stmt?

Post by nikilkarna » Thu Dec 16, 2010 2:20 am

can some one explain the flow of this one?

Code: Select all

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

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Dec 16, 2010 2:07 pm

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.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

User avatar
Vamsi99
Active Member
Posts: 183
Joined: Wed Nov 05, 2008 11:20 am

Post by Vamsi99 » Thu Dec 16, 2010 3:46 pm

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.

nikilkarna
Member
Posts: 2
Joined: Thu Dec 16, 2010 2:08 am
Location: IN

Post by nikilkarna » Thu Dec 16, 2010 7:19 pm

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).

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Dec 16, 2010 7:28 pm

nikilkarna,

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

compile and execute the program and gather your own output.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Tue Dec 28, 2010 12:42 pm

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!
Regards,
Anuj

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Sun Jan 02, 2011 8:56 pm

following cobol material from mainframegurukul , may be useful to you to learn cobol.

http://www.mainframegurukul.com/tutoria ... orial.html
Natarajan
Chennai

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others