IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Want to know the diff between PERFORM and PERFORM-THRU


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vivek_mvs1

New User


Joined: 25 Apr 2006
Posts: 12

PostPosted: Sat Feb 17, 2007 11:22 am
Reply with quote

Hi,

i would like to know about PERFORM statement in COBOL.

I want to know the diff between PERFORM and PERFORM-THRU,and how the controls are passed in both.

For eg:
PERFORM L-1
-----------
-----------
L-1.
--------
--------
EXIT.
L-2.
-------
-------
Will the control be passed back the to statements after PERFORM,before L-2 is executed?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Feb 17, 2007 3:30 pm
Reply with quote

Yes, as long as L-1 logic does not branch anywhere else.
Back to top
View user's profile Send private message
krishna_sureka

New User


Joined: 05 Sep 2006
Posts: 7
Location: Pune

PostPosted: Wed Feb 21, 2007 3:50 pm
Reply with quote

Different forms of Perform:

1. Simple PERFORM
PERFORM Paragraph-Name.
(In this case the execution returns to the statement after the perform statemetnt once the para is executed.)

2. In-line PERFORM
PERFORM
logic
END-PERFORM

3. PERFORM . . . THRU

PERFORM C1000-BEGIN-CALC-PARA THRU C5000-END-CALC-PARA
(In this case the execution starts with the first statement in C1000-BEGIN-CALC-PARA and ends with the last statement of C5000-END-CALC-PARA)

4. PERFORM . . . UNTIL
PERFORM Paragraph-Name-1 UNTIL condition

5. PERFORM . . . TIMES
PERFORM Paragraph-Name-1 integer TIMES.

6. PERFORM . . . VARYING

PERFORM Paragraph-Name-1 [ { THRU, THROUGH }Paragraph-Name-2 ] VARYING identifier-1 FROM
{identifier-2, integer-1} BY { identifier-3, integer-2 }
UNTIL condition.

Eg.
PERFORM 500-WRITE-PARA VARYING I FROM 1 BY 1 UNTIL I > 5.

Let me know if more explanation required on any of the above way of using PERFORM.
Back to top
View user's profile Send private message
DeepaBala

New User


Joined: 20 Feb 2007
Posts: 13
Location: Trivandrum

PostPosted: Thu Feb 22, 2007 10:45 am
Reply with quote

Hi Friends,

I have one doubt. plz clear that.

I want to Know What is the Difference b/w Perform with after and prform with before...
plz give some examples for easy understanding
Back to top
View user's profile Send private message
krishna_sureka

New User


Joined: 05 Sep 2006
Posts: 7
Location: Pune

PostPosted: Thu Feb 22, 2007 12:17 pm
Reply with quote

If the TEST BEFORE phrase is specified, the condition is tested before any statements are executed and if the TEST AFTER phrase is specified, the statements to be performed are executed at least once before the condition is tested

Format: PERFORM procedure-name-1 [{THRU, THROUGH} procedure-name-2] UNTIL condition
[WITH TEST {AFTER, BEFORE}].

Examples:
Assume that EOF is already set to "Y"

1. TEST AFTER:

PERFORM READ-PARA UNTIL EOF = ?Y? WITH TEST AFTER.

Now even though the EOF is already "Y", READ-PARA will be executed once and then condition will be checked later.


2. TEST BEFORE

PERFORM READ-PARA UNTIL EOF = ?Y? WITH TEST BEFORE.

In this case the condition is checked before any statement is executed so as EOF is already "Y", READ-PARA will not be executed even one time also.
Back to top
View user's profile Send private message
DeepaBala

New User


Joined: 20 Feb 2007
Posts: 13
Location: Trivandrum

PostPosted: Thu Feb 22, 2007 2:17 pm
Reply with quote

Thanks for the information
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Thu Feb 22, 2007 4:09 pm
Reply with quote

DeepaBala wrote:
Hi Friends,

I have one doubt. plz clear that.

I want to Know What is the Difference b/w Perform with after and prform with before...
plz give some examples for easy understanding


ANSWER;
MOSTLY THIS TERM IS COMES ACROSS WHEN YOU USE MULTIDIMENTION TABLE
I GIVE YOU EXAMPLE
SUPPOSE IN ONE SHCOOL/CLASS THERE ARE STUDENTS AND E THEY HAVE 5 SUBJECTS EACH SO I WANT TO MAKE TABLE FOR THIS THEN
SO I SEE YOU STRUCTURE
STUDENT 1. HARISH HIS 5 SUBJECTS 1.VVV
2.YYY
3.TTT
4.YYY
.HHH
2.SACHIN 1.VVV
2.YYY
3.TTT
4.YYY
5.HHH
SO I WANT TO MAKE TABLE FOR THIS
THEN PROGRAME IS
ID DIVISION.
PROGRAM-ID.
WORKING-STORAGE SECTION.
O1 CLASS
02 STUDEN-NAME PIC X(10) OCCURES 10 TIMES INDEXED BY I.
O2 SUBJECTS PIC X(3) OCCURS 5 TIMES INDEXED BY J.
PROCEDURE DIVISION.
ACCEPT I.
PERFORM WITH VARYING BEFORE I FROM 1 BY 1 UNTIL I >10
ACCEPT J
PERFORM WITH TEST AFTER J FROM 1 BY 1 UNTIL J>5
DISPLAY I , J.
STOP RUN.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 22, 2007 4:47 pm
Reply with quote

sachin,

Try at least to use the correct syntax in your examples.... icon_rolleyes.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Use of Perform Thru Exit COBOL Programming 6
No new posts Sort on different fields, removing du... SYNCSORT 8
No new posts How syntax check at Bind time is diff... DB2 5
No new posts How to perform Digest Access Authenti... All Other Mainframe Topics 0
No new posts Compare PD Values with same storage &... JCL & VSAM 5
Search our Forums:

Back to Top