Assign numeric value of count to a variable

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
karentina
Member
Posts: 2
Joined: Thu Dec 01, 2011 4:08 pm

Assign numeric value of count to a variable

Post by karentina » Thu Dec 01, 2011 4:40 pm

Hi,

I would just like to ask how can I get the numeric value of record count from sortcard then use it in an if statement.

Here's my sortcard:

Code: Select all

  SORT FIELDS=COPY                
  OUTFIL REMOVECC,NODETAIL,       
     TRAILER1=(COUNT=(M11,LENGTH=8))
Thanks!

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Thu Dec 01, 2011 5:37 pm

An IF statement of what? The same SORT step? Obviously, from your code example, you'll have the records count value in the SORTOUT dataset, which can, of course, be used as input to another step or job. Maybe if you would provide some more details as to what you want the output to be ...

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Dec 01, 2011 10:57 pm

karentina,

An if statement? Do you mean a DFSORT IFTHEN statement or something else? What exactly?

You need to do a better job of explaining what you're trying to do. Show and explain exactly how you want to use this numeric value.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

karentina
Member
Posts: 2
Joined: Thu Dec 01, 2011 4:08 pm

Post by karentina » Mon Dec 05, 2011 1:11 pm

Hi,

I got an exact solution to my problem. I used this code but I didn't understand how did the return code set up to 0 if the record is full. Here is the code. I want if possible to have RC = 4 if record is full, then RC= 0 if not. Thanks!

Code:

//* filtering on specifi value
//*
//HASERR1 EXEC PGM=SORT
//SORTIN DD DSN=&&MyDataset,DISP=SHR
//SHOWERR DD DSN=&&TEMP,DISP=(,PASS),
// SPACE=(CYL,(1,1))
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(18,5,ZD,GT,0)
OUTFIL FNAMES=SHOWERR
/*
//* raise an error if showerr is full
//*
//HASERR2 EXEC PGM=IDCAMS
//IN1 DD DSN=*.HASERR1.SHOWERR,DISP=(OLD,DELETE)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT INFILE(IN1) COUNT(1)
/*
//* RC: 0 full
//* RC: 4 empty
//*
// IF (HASERR2.RC = 0) THEN
//ABEND EXEC PGM=IEFBR15
// ENDIF
//*------------------------------------------

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Dec 05, 2011 11:24 pm

Why didn't you say that's what you wanted in the first place? If you just want RC=4 if the output is empty or RC=0 if the output is not empty, you can do that with a DFSORT job like the following:

Code: Select all

//HASERR1 EXEC PGM=SORT
//SORTIN DD DSN=...  input file
//SHOWERR DD DSN=&&TEMP,DISP=(,PASS),
// SPACE=(CYL,(1,1))
//SYSOUT DD SYSOUT=*
//SYSIN DD *
  SORT FIELDS=COPY
  INCLUDE COND=(18,5,ZD,GT,0)
  OUTFIL FNAMES=SHOWERR,NULLOFL=RC4
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others