View previous topic :: View next topic
|
Author |
Message |
ankit.jain
New User
Joined: 02 Jul 2009 Posts: 18 Location: Mumbai
|
|
|
|
Hi,
In my code, I observed weird program flow when I added the keyword “SECTION” to a paragraph. Consider the following code as an example:
100-PROCESS SECTION.
<steps>
GO TO 100-EXIT.
100-ERROR.
<steps>
100-EXIT.
EXIT.
200-PROCESS SECTION.
<steps>
200-EXIT.
EXIT.
300-PROCESS SECTION.
<steps>
300-EXIT.
EXIT.
In this code, the keyword “SECTION” is not used in 100-ERROR. In this case, when the control reaches GO TO 100-EXIT, it executes the 100-EXIT and returns to the next line from where 100-PROCESS section was called.
But when I added the keyword “SECTION” after 100-ERROR (so it will appear as 100-ERROR SECTION), the flow of the program changed. In this case, when the control reaches GO TO 100-EXIT, it executes the 100-EXIT, but after that it executes 200-PROCESS section, then 300-PROCESS section and so on.
Is this correct and why does it happen?
Thanks in advance,
Ankit Jain |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Ankit,
Its been sometime since i have come across SECTION concept. I will tell what i remember.
SECTIONs can be considered to logical parititions within a DIVISION. In your case here SECTION is supposed to be logical divisions to your PROCEDURE division.
Now I hope u know the general difference between GOTO and PERFORM. The general idea is when we do a PERFORM statement to call a paragraph it executes the same and control returns back. When we do a GOTO para it executes the same para but continues the execution with the next paragraph in line.
When a PERFORM to a section is done ( in this case 100-PROCESS ), if i remember correctly, the whole SECTION is executed. In the example given above, you have basically given a GOTO within the SECTION. As far as the initial PERFORM is concerned the control is still within the SECTION hence after executing 100-EXIT it returns back to the statment after the PERFORM 100-PROCESS statement. Please note that if there were other paragraphs after 100-EXIT ( before the next SECTION ) it would execute those paragraphs also and then only return back to the initial PERFORM statment.
In the second case you have mentioned when you are doing a GOTO to a completely new SECTION, the initial PERFORM looses its flow as it has come out of the expected flow and hence the initial PERFORM is terminated. Hence after executing the 100-EXIT SECTION it continues on with the next paragraph.
Hope i have been of help. |
|
Back to top |
|
|
ankit.jain
New User
Joined: 02 Jul 2009 Posts: 18 Location: Mumbai
|
|
|
|
Thanks a lot Binop, your explanation is really helpful and I appreciate the way you explained it. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Nice to hear that... |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Procedure Division "SECTIONS" have been steadily falling out of favor, except when they are mandated, such as COBOL INPUT and OUTPUT SORT PROCEDURE SECTIONS. However, USING and GIVING t/w the FASTSRT compile option instead, seems to be more of the rule.
When compiling a program which uses SECTIONS and specifying the OPT compiler option, you'll find that the generated Load Module tends to be slightly larger than a program without SECTIONS, excluding the SORT PROCEDURE SECTIONS as outlined above.
FWIW, INPUT and OUTPUT SORT PROCEDURE SECTIONS are akin to E15 and E35 Sort Exits, respectively.
Regards, |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
However, USING and GIVING t/w the FASTSRT compile option instead, seems to be more of the rule. |
Lots of code specifies using/giving - with or without fastsrt. This is usually because the people who implemented these did not understand input/output procedure or they had an extract process a sort and an output process and combined them into one set of code so they would not be required to document 3 steps or they were just plain lazy.
All of the timing tests i've seen or conducted show that input/out procedure performs better than using/giving. One reason is that using/giving requires at least 2 complete extra passes of all of the data.
FASTSRT can help the performance of code with using/giving but it does nothing for input/output procedure (at least not that i've seen). |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Thanks Dick. I had thought just the opposite in regards to performance as IBM touts USING/GIVING as a faster way to perform sorts in COBOL.
Yes and that's a true statement that FASTSRT has no effect on INPUT and OUTPUT Procedures.
Heaven forbid, but do you think they've not been entirely forthcoming regarding USING/GIVING?
Never would have thunk it....
Regards, |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
IBM touting something that increases the need for hardware? Who woulda thunk it? |
|
Back to top |
|
|
|