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

Need Clarification on Return-Code Register


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

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu May 28, 2009 6:41 pm
Reply with quote

Hi,

In my COBOL program, i have to error out the program by populating Return-Code register with value of '1000',
so that i can trigger a mail in JCL with RC = 1000. to achieve the above condition, it's enough to populate return-code register with '1000'? Please clarify.

Thanks,
Murali
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu May 28, 2009 6:47 pm
Reply with quote

The manual isn't clear enough? See the manuals link at the top of the page.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 28, 2009 6:50 pm
Reply with quote

RETURN-CODE Clear enough??
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu May 28, 2009 7:07 pm
Reply with quote

A "STOP" , or "STOP RUN" afterwards would help.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu May 28, 2009 7:09 pm
Reply with quote

In as much as COBOL defines this as a "REGISTER" (really a misnomer), the compiler treats it as a signed binary-halfword, which has a maximum signed positive value of +32767.

However, there should not be any problem with a value of +1000.

Regards,
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 28, 2009 7:39 pm
Reply with quote

Craq Giegerich wrote:
A "STOP" , or "STOP RUN" afterwards would help.


a GOBACK would suffice, also.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri May 29, 2009 12:57 am
Reply with quote

Hello,

For a bit of entertainment/education, try:
Code:

MOVE 4444 TO RETURN-CODE.
GOBACK.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Mon Jun 22, 2009 12:51 pm
Reply with quote

I used the Below piece of code in Pgm and

Code:

        MOVE '04'             TO RETURN-CODE         
        MOVE 'Data Err in App-def:'                   
                              TO ERROR-ERR-DESC(1:19)
        PERFORM Z1000-DISP-ERR-INFO                   
           THRU Z1000-EXIT                           
        PERFORM Z9999-EXIT-PROGRAM                   
           THRU Z9999-EXIT                           
.
.
 Z9999-EXIT-PROGRAM.     
     STOP RUN.           
 Z9999-EXIT.             
     EXIT.               



In Jcl

Code:

//*EXECUTION OF PROGRAM
//P243CA02   EXEC PGM=IKJEFT1A,TIME=800
.
.
//      IF   P243CA02.RC<4  THEN                                       
//P243BA02   EXEC PGM=IEBGENER,TIME=800                                 
//*                                                                     
//SYSUT1   DD DSN=R243PB.EPC.P7932.EPC.MAILHEAD.COMMON,                 
//            DISP=SHR                                                 
//         DD DSN=R243PB.EPC.M243CA10.ERRLOG,                           
//            DISP=SHR                                                 
//*        DD DSN=R243PB.EPC.P7932.EPC.MAILTRLR.P243CA1S,               
//*           DISP=SHR                                                 
//*                                                                     
//SYSUT2     DD   SYSOUT=(B,SMTP)                                       
//SYSIN      DD   DUMMY,DCB=BLKSIZE=80                                 
//SYSTSPRT   DD   SYSOUT=*                                             
//SYSPRINT   DD   SYSOUT=*                                             
//SYSOUT     DD   SYSOUT=*                                             
//SYSUDUMP   DD   SYSOUT=*                                             
//      ENDIF                                                           
//      IF   P243CA01.RC=4 THEN                                         
//P243BA03   EXEC PGM=IEBGENER,TIME=800                                 
//*                                                                     
//SYSUT1   DD DSN=R243PB.EPC.P7932.EPC.MAILHEAD.ERROR,                 
//            DISP=SHR                                                 
//         DD DSN=R243PB.EPC.M243CA10.ERRLOG,                           
//            DISP=SHR                                                 
//*                                                                     
//SYSUT2     DD   SYSOUT=(B,SMTP)                                       
//SYSIN      DD   DUMMY,DCB=BLKSIZE=80                                 
//SYSTSPRT   DD   SYSOUT=*                                             
//SYSPRINT   DD   SYSOUT=*                                             
//SYSOUT     DD   SYSOUT=*                                             
//SYSUDUMP   DD   SYSOUT=*                                             
//      ENDIF       




my JESMSGLG is

Code:


-J243CA1  P243CA02    04    672    779    .00
-J243CA1  P243BA02 FLUSH      0      0    .00
-J243CA1  P243BA03 FLUSH      0      0    .00


Please let me know why after execution of my program, the Job is not picking up my RC.

Thanks,
Murali
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 22, 2009 1:57 pm
Reply with quote

code correctly:

// IF P243CA01.RC=4 THEN
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Mon Jun 22, 2009 2:17 pm
Reply with quote

Thanks,

Dick
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Jun 22, 2009 7:35 pm
Reply with quote

Hello,

I still believe something could be learned from this. . . .

Quote:
For a bit of entertainment/education, try:
Code:
MOVE 4444 TO RETURN-CODE.
GOBACK.



Hint: the return code will NOT be 4444. . .
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Mon Jun 22, 2009 7:49 pm
Reply with quote

Hi Dick,

I got RC as 0348. Wondering... icon_wink.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 22, 2009 7:51 pm
Reply with quote

RC=0348 is expected ....
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Mon Jun 22, 2009 8:05 pm
Reply with quote

Hi Robert,

Could you please explain it?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 22, 2009 8:34 pm
Reply with quote

A return code is only allowed in the range of 0 to 4095; this limit is mentioned in the JCL Language Reference several times. If a return code greater than 4095 is set, the system reduces it using modulus arithmetic (4096).

4444 - 4096 = 0348, so the return code set in COBOL at 4444 becomes 0348 as far as JES and z/OS are concerned.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Jun 23, 2009 9:25 am
Reply with quote

Hi Robert,

Strange but a very good point.

Quote:
If a return code greater than 4095 is set, the system reduces it using modulus arithmetic (4096).


If I move 4096 to the RETURN-CODE register then will 0 get moved to the same after using modulus arithmetic?

If yes, we should be very careful as RETURN-CODE zero is fine.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Jun 23, 2009 9:35 am
Reply with quote

Hello,

Yes, 4096 will cause a return-code zero. . .

Which is why the experiment was suggested. . . . icon_wink.gif
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Jun 23, 2009 9:50 am
Reply with quote

Hi Dick,

Quote:
Which is why the experiment was suggested. . . .


Thanks and we welcome all your experiments icon_biggrin.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 23, 2009 5:02 pm
Reply with quote

Aaru: when doing batch FTP with the EXIT parameter, this becomes relevant as FTP errors set the return code as a 5-digit number: 2 digits for the FTP command being executed (16 for GET and 27 for PUT, for example) followed by the 3-digit response code from the server. A common code is 16550, which occurs when you attempt to GET a file that isn't there. The 16550 turns into a 0166 return code for the job step due to modulus arithmetic.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Jun 23, 2009 5:23 pm
Reply with quote

Hi Robert,

That was indeed a good information. Will keep this in mind.

Thanks a ton.
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top