Page 1 of 1

Assign numeric value of count to a variable

Posted: Thu Dec 01, 2011 4:40 pm
by karentina
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!

Posted: Thu Dec 01, 2011 5:37 pm
by MrSpock
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 ...

Posted: Thu Dec 01, 2011 10:57 pm
by Frank Yaeger
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.

Posted: Mon Dec 05, 2011 1:11 pm
by karentina
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
//*------------------------------------------

Posted: Mon Dec 05, 2011 11:24 pm
by Frank Yaeger
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
/*