Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
HELP IN understanding the PERFORM STATEMENT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sophia

New User


Joined: 30 Jun 2007
Posts: 19
Location: United States

PostPosted: Fri Jul 02, 2010 10:42 pm    Post subject: HELP IN understanding the PERFORM STATEMENT
Reply with quote

Hi can anyone give me a refresher about perform statement. I'm reading a code

here's the part of the code

Code:
WS-T-COUNT-4 = 4

PERFORM VARYING WS-T-COUNT FROM 1 BY 1
             UNTIL WS-T-SORTED-YES
                OR WS-T-COUNT > WS-T-COUNT-4
               SET WS-T-CHANGE-NO TO TRUE

               PERFORM VARYING WS-T-INDEX FROM 2 BY 1
                       UNTIL   WS-T-INDEX > WS-T-COUNT-4
                   COMPUTE WS-T-PREV = WS-T-INDEX - 1

                   IF WS-T-ARRAY1-SRT (WS-T-INDEX) >
                      WS-T-ARRAY1-SRT (WS-T-PREV)
                       SET WS-T-CHANGE-YES TO TRUE
                       MOVE WS-TABLE-ROW (WS-T-INDEX) TO
                            WS-TABLE-ROW (WS-T-LAST)
                       MOVE WS-TABLE-ROW (WS-T-PREV)  TO
                            WS-TABLE-ROW (WS-T-INDEX)
                       MOVE WS-TABLE-ROW (WS-T-LAST)  TO
                            WS-TABLE-ROW (WS-T-PREV)
                   END-IF

                   IF WS-T-ARRAY1-SRT (WS-T-INDEX) =
                      WS-T-ARRAY1-ID-SRT (WS-T-PREV)
                       IF WS-T-ARRAY2-SRT (WS-T-INDEX) <
                          WS-T-ARRAY2-SRT (WS-T-PREV)
                           SET WS-T-CHANGE-YES TO TRUE
                           MOVE WS-DECL-TABLE-ROW (WS-T-INDEX) TO
                                WS-TABLE-ROW (WS-T-LAST)
                           MOVE WS-TABLE-ROW (WS-T-PREV)  TO
                                WS-TABLE-ROW (WS-T-INDEX)
                           MOVE WS-TABLE-ROW (WS-T-LAST)  TO
                                WS-TABLE-ROW (WS-T-PREV)
                       END-IF
                   END-IF
               END-PERFORM
               IF WS-T-CHANGE-NO
                   SET WS-T-SORTED-YES TO TRUE
               END-IF
           END-PERFORM.



My question is after the first loop of the program does it stays in the second perform first until the condition are met or because of the end-perform it goes back to the first perform statement check condition then goes again to the second perform for condition check and processing?
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8201
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jul 02, 2010 10:58 pm    Post subject:
Reply with quote

It will stay in the second (inner) PERFORM until the condition is met. It will then do the IF statement and go back for the outer PERFORM. COBOL tracks which PERFORM is associated with which END-PERFORM for you.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Jul 02, 2010 11:00 pm    Post subject:
Reply with quote

If I understand the question correctly, the first (inner) END-PERFORM only deals with second (inner) PERFORM.
The second (inner) PERFORM will loop back from the first (inner) END-PERFORM until a condition of that PERFORM is met.
Logic will then continue with the first (outer) PERFORM looping to the second (outer) END-PERFORM until a condition of that PERFORM is met.
Back to top
View user's profile Send private message
sophia

New User


Joined: 30 Jun 2007
Posts: 19
Location: United States

PostPosted: Fri Jul 02, 2010 11:11 pm    Post subject:
Reply with quote

Thanks! so perform number two will be repetitively called inside performing the IF condition until it would reach to a point that it will satisfy the until condition then goes back to perform one. Then the counter in perform 1 will be incremented then calls again perform 2. is that the correct looping here?
icon_confused.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jul 03, 2010 12:00 am    Post subject:
Reply with quote

Hello,

Suggest you put in a display within each loop to "track" what happens. . .

Seeing each iteration displayed may help clarify.
Back to top
View user's profile Send private message
sophia

New User


Joined: 30 Jun 2007
Posts: 19
Location: United States

PostPosted: Sat Jul 03, 2010 12:09 am    Post subject:
Reply with quote

Is there an available PC cobol for download that I can use to test this?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jul 03, 2010 12:20 am    Post subject:
Reply with quote

Hello,

You might try here:
http://www.cobug.com/cobug/docs/freeCompilers0098.html
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts ON 2 AND EVERY 1 - Statement ??? UmeySan COBOL Programming 2 Tue Jul 25, 2017 1:20 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us