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

Questions related to EXIT-PROGRAM.


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

New User


Joined: 29 Nov 2005
Posts: 49

PostPosted: Fri Mar 17, 2006 5:23 pm
Reply with quote

Hi,

Could you please answer for these questions.

1. Difference between EXIT & EXIT-PROGRAM?

2. Difference between EXIT & GOBACK?

3. What will happen if i code GOBACK & STOP RUN in same program?

4. I have a following structure.

01 A PIC X(100) VALUE 'NAME SALARY NAME SALARY NAME SALARY
...........'
Like that 100 characters. Now i want to display the above one is as follows.

NAME SALARY

NAME SALARY
.
.
.
NAME SALARY.

Please tell me the code for this.

Please let me know the answers for above questions.

Thanks,
Sunny.
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Fri Mar 17, 2006 6:03 pm
Reply with quote

hy sunnybunny,

1. EXIT means EXIT from a paragraph you just performed,
EXIT-PROGRAM you finish the program.

2. GOBACK you code normally for subroutines,
it is like EXIT-PROGARM but returns to the caller.

3. EXIT-PROGRAM is like STOP-RUN...
finishing the program

4. 01 A PIC X(100) VALUE 'NAME SALARY NAME SALARY NAME SALARY...
i assume NAME and SALARY alre always from different length.
if so, then STRING/UNSTRING this stuff. if the sizes for NAME and SALARY
are from the same length, i.e. NAME PIC X(20), SALARY PIC 9(05),
then you can redefine your variable with an array, and display its value
in a loop....

martin9
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Mar 17, 2006 6:25 pm
Reply with quote

Hi Martin,

Quote:
2. GOBACK you code normally for subroutines,
it is like EXIT-PROGARM but returns to the caller.

Is there any difference between GOBACK & EXIT-PROGRAM. Basically GOBACK returns the control to caller if coded in a called module or simply STOP FUNCTIONS if coded in Main module.
And Isn't EXIT-PROGRAM doing the same.

Regards,
Priyesh.
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Fri Mar 17, 2006 7:44 pm
Reply with quote

hy priyesh,

actually yes,
STOP RUN will break any flow...
therefore you are right.

martin9
Back to top
View user's profile Send private message
cheryala

New User


Joined: 20 Mar 2006
Posts: 46

PostPosted: Mon Mar 20, 2006 7:05 pm
Reply with quote

Hi Everybody,

Just i need to add some more info ..

EXIT-PROGRAM-------> No action will be taken if you use it in your main program ..but if you use it in any sub program then the control will transfer to calling program.

GOBACK---------> When it is used in the main program, stops the program when executed and control will be returned to OS....where is when it is used in subprogram, control will be returned to the calling program..

STOP RUN ---> When it is executed either in main program or sub program, program execution will be stopped and the control will be returned to OS.

Please let me know if i'm wrong any where..

Thanks and Regards,
RS
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Thu Mar 23, 2006 9:28 am
Reply with quote

Hi,

Just wanted to add a point regarding this.
I saw the replies and found one of the answers as
"EXIT means EXIT from a paragraph you just performed"

As far as I know, it doesnt do that !!
A paragraph identifies that it is done when it encounters a new PARA AND NOT when it encounters exit. So basically EXIT does nothing and is just a way of coding.

Any corrections and always welcome.

ap_mainframes
Back to top
View user's profile Send private message
gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Fri Mar 24, 2006 10:04 am
Reply with quote

ap_mainframes wrote:
Hi,

Just wanted to add a point regarding this.
I saw the replies and found one of the answers as
"EXIT means EXIT from a paragraph you just performed"

As far as I know, it doesnt do that !!
A paragraph identifies that it is done when it encounters a new PARA AND NOT when it encounters exit. So basically EXIT does nothing and is just a way of coding.

Any corrections and always welcome.

ap_mainframes


i too support ap_mainframes. to add with, a paragraph also ends when it finds there are no more statement to be executed from it. an EIXT statement does nothing other than to exit from the paragraph. if an EXIT statement is coded, it should be the only statement in the paragraph.

sorry if i'm revisiting the grounds agains.

kind regards,

gowtham
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Mar 28, 2006 1:47 pm
Reply with quote

EXIT statement does nothing. It never exists from a paragraph. A paragraph ends when we reach another para or section.

As every peragraph needs to have at least one statement, we use EXIT as its more meaningful.

I hope this makes it clear that why EXIT is used and what it does.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Mar 28, 2006 1:54 pm
Reply with quote

cheryala wrote:
Hi Everybody,

Just i need to add some more info ..

EXIT-PROGRAM-------> No action will be taken if you use it in your main program ..but if you use it in any sub program then the control will transfer to calling program.

GOBACK---------> RS


Are you sure that EXIT-PROGRAM does nothing when used in main program? I doubt it does nothing.

Anyone please clear this topic, as most of the replies are contradictory.
What is diff bet EXIT-PROGRAM , GOBACK and STOP RUN.

What is know is:
STOP RUN -- stops current rununit (wherever it is used main or sub program)
GOBACK = EXIT-PROGRAM --- (if used in main program they are = STOP RUN and if used in sub-program they return control to main program).

Please correct if I am wrong.
Back to top
View user's profile Send private message
tusharguptait

New User


Joined: 15 Feb 2006
Posts: 32

PostPosted: Wed Mar 29, 2006 9:32 am
Reply with quote

Hi,

->STOP RUN is the last executable statement of the main program ( or sub program ). It returns control back to OS.

->GOBACK can be coded in main program as well as sub-program as the last statement. It just gives the control back from where it received the control.

->EXIT PROGRAM is the last executable statement of sub-program. It returns control back to main program. However in main program the EXIT PROGRAM will act as a NULL statement and execution will continue from next impertative statement.

->EXIT acts as a NULL statement and does nothing. If used it should be the only statement in the para.

Thanks.
TG
Back to top
View user's profile Send private message
mubashir.surury

New User


Joined: 29 Sep 2005
Posts: 23
Location: Pune

PostPosted: Wed Mar 29, 2006 5:12 pm
Reply with quote

hi sunnybunny;
for your last question u can use REDEFINES clause in the foolowing manner.assuming name and sakary both are 5 bytes long.

Code:

 01 A PIC X(100) VALUE 'NAME SALARY NAME SALARY NAME SALARY
 01 B REDEFINES A.
      05  NAME-SALARY OCCURS 10 TIMES INDEXED BY X.
           10 NAME        PIC X(5).
           10 SALARY     PIC 9(5).


and then you can use PERFORM statement to display the same on a new line each.
Code:

             PERFORM VARYING X FROM 1 BY 1 UNTIL X = 10
                 DISPLAY NAME-SALARY(X)
             END-PERFORM.

just check on the use of index for an array.i am not sure of the syntax.
hope that helps.
corrections are welcome
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 Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts Use of Perform Thru Exit COBOL Programming 6
Search our Forums:

Back to Top