Page 1 of 2

Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 6:45 pm
by pranav283
Hi,
I have a COBOL-DB2 program where I am setting the value of RETURN-CODE register as 4200 (greater than 4095).
Thus, I expect the job to abend with RC-104 (4200-4095). Instead, the job is abending with a RC-12 only.

However, the return code register still contains the value of 4200 as I checked by routing its value in an error file and opening the file in a proper format considering the fact that RETURN-CODE has an implicit definition of S9(4) USAGE BINARY.
Also, there is no information in the CEEDUMP, SYSUDUMP and even SYSABEND so that I could at least figure out if in case moving a value greater than 4095 would make the job abend with RC-12 in my language environment:
z/OS - V1.13.
COBOL - OS/390.

Let me know in case someone needs further details.

Thanks,
Pranav

Re: Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 7:17 pm
by Akatsukami
  1. You are not describing an abend, but a normal ending with a non-zero return code; this need not indicate an error.
  2. You cannot set a return code (or, indeed, an abend code), outside the range of 0-4095. Period.

Re: Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 8:10 pm
by pranav283
Akatsukami,

1.You are not describing an abend, but a normal ending with a non-zero return code; this need not indicate an error.
- What do you mean by this ? And yes, while moving a value of 99 to the return-code register, my job does abend withe rc of 99.

2.You cannot set a return code (or, indeed, an abend code), outside the range of 0-4095. Period.
- Yeah, I will correct my statement. I am not setting it, rather moving 4200 to it. However, I believe the return-code register can contain a value more than 4095. I checked it. Pay a visit to this link - http://ibmmainframes.com/about40962.html.

Please help me out with this. I guess assembly language will only set the registers. But I want to understand what exactly happens while passing the return-code to the job.

Thanks,
Pranav

Re: Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 8:43 pm
by Robert Sample
However, I believe the return-code register can contain a value more than 4095.
What you believe is not important. The fact is, the return code is limited to 12 bits and hence values in the range 0 to 4095 are all you are allowed to use. And "COBOL OS/390" is not a version of COBOL that has ever run on the mainframe -- COBOL for MVS & VM, for example, is a version that did run on the mainframe.

Re: Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 8:43 pm
by Akatsukami
pranav283 wrote:Akatsukami,

1.You are not describing an abend, but a normal ending with a non-zero return code; this need not indicate an error.
- What do you mean by this ? And yes, while moving a value of 99 to the return-code register, my job does abend withe rc of 99.

Again: your terminology is incorrect. Setting a return code does not cause the program to abend. Use the dispositive processing of a data set by JCL to see this.

AFAIK, there is no way through COBOL alone to cause a program to abend, although a COBOL program can easily call the LE services CEE3ABD and CEE3AB2 to terminate a program with an actual abend.

2.You cannot set a return code (or, indeed, an abend code), outside the range of 0-4095. Period.
- Yeah, I will correct my statement. I am not setting it, rather moving 4200 to it. However, I believe the return-code register can contain a value more than 4095. I checked it. Pay a visit to this link - http://ibmmainframes.com/about40962.html.

But, as Mr. Sample points out in that thread, the value will be interpreted modulo 4096. This is because the high nybble is not interpreted as part of the value, but as flags (which are set by the machine code, so you cannot manipulate them by using a return code greater than 4095.

Re: Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 10:06 pm
by BillyBoyo
A non-zero RC/CC is not an abend.

The RETURN-CODE special-register can indeed have a value outside the range 0-4095, but if so, it will be reported by JES as though it were within that range. If you look at the hex value of the decimal value you are setting, pretend the left-most nybble is zero, and convert that value to decimal, you get your 12.

The COBOL special-register can accurately contain values beyond 4095. JES cares not one jot about that, so it is no use for attempting see an RC/CC greater than 4095. You can make use of a higher value within your COBOL program.

Re: Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 10:37 pm
by UserName
If you are moving 4200 to RETURN-CODE then you should get RC=0104 (considering it's a normal end).

If you are moving correctly but not getting RC as 0104 then something else must be interfering.

Re: Set Return code higher than 4095

PostPosted: Thu Dec 17, 2015 11:50 pm
by BillyBoyo
You're right, UserName.

I didn't notice the DB2 bit.

pranav283, can you show your JCL? Also, are there any messages in the output from your job?

Re: Set Return code higher than 4095

PostPosted: Fri Dec 18, 2015 3:43 am
by UserName
What utility are you using to run the cobol-db2 program?

I believe your program is issuing an abend before you could set the return code and you are using IKJEFT01 to get RC=12.

Re: Set Return code higher than 4095

PostPosted: Fri Dec 18, 2015 12:22 pm
by pranav283
Hi @usrname, @BilliBoyo, I am using IKJEFT01 to execute the program.
No. the program is issung the abend only when I want it to.
I am deliberately making the program abend when there is not even a single row fetched in the cursor. Hence, SQLCODE 100.
So, using a IF structure, if SQLCODE is 100 and the cursor-counter is zero, I am treating this as an abend by moving 4200 to return-code immediately followed by a STOP RUN.

@BilliBoyo

This is my step:

//R010     EXEC PGM=IKJEFT01
//STEPLIB  INCLUDE MEMBER=SLIBDUMM
//         INCLUDE MEMBER=SLIBDEV1
//         INCLUDE MEMBER=SLDBTDB2
//FILEO1   DD DSN=TSOPKUL.GMRFTCSD.R010,DISP=(,CATLG,),
//         DCB=(LRECL=50,RECFM=FB),
//         SPACE=(TRK,(10,20),RLSE),
//         UNIT=SYSDA,
//         STORCLAS=PERM
//FILEE1   DD DSN=TSOPKUL.ERRFILE.R010,DISP=(,CATLG,),
//         DCB=(LRECL=48,RECFM=FB),
//         SPACE=(TRK,(10,20),RLSE),
//         UNIT=SYSDA,
//         STORCLAS=PERM
//*        AVGREC=K
//SYSOUT   DD SYSOUT=*
//CEEDUMP  DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSUDUMP DD DSN=TSOPKUL.GMRFTCSD.R010.SYSUDUMP,DISP=(,CATLG,),
//            DCB=(RECFM=VB,BLKSIZE=800),
//            SPACE=(TRK,(90,90),RLSE),
//            UNIT=SYSDA,
//            STORCLAS=PERM
//SYSABEND DD DSN=TSOPKUL.GMRFTCSD.R010.SYSABEND,DISP=(,CATLG,),
//            DCB=(RECFM=VB,BLKSIZE=800),
//            SPACE=(TRK,(90,90),RLSE),
//            UNIT=SYSDA,
//            STORCLAS=PERM
//SYSTSIN  DD *
      DSN SYSTEM(TDB2)
      RUN PROGRAM(CDFETCSP) PLAN(CDFETCSP)
      END


This is the SYSOUT O/P:
SQLCODE: 0000000100
WS-CURS01-PTR: 000000000
NO ROWS FOUND FOR
DB2 ABEND


This is the error file that was loaded with the value of the return-code passed: TSOPKUL.ERRFILE.R010
FILEE1-STATIC-REC     FILEE1-RETURN-CODE  FILLER
C(20) (1-20)          B(4) (21-22)        C(26) (23-48)
--------------------  ------------------  --------------------------
********************************* TOP OF DATA **********************
RETURN-CODE:          4200                ..........................