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

Reading Empty Dataset


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 11
Location: India

PostPosted: Mon Jul 08, 2024 8:47 pm
Reply with quote

Hi All,

I have an input dataset with LRECL=230. I want to read my i/p dataset and if i/p dataset is empty then it should write as 'NO RECORDS' in the same i/p dataset.

If my i/p dataset has records then it should write those records in the same i/p dataset. I am trying the below SORT program but it is giving the error:

Quote:
//JOB CARD
//REPORT EXEC PGM=SORT
//SORTIN DD DSN=ABCD.RAVI(MY INPUT DATASET),DISP=SHR
// DD *

NO RECORDS
//SORTOUT DD DSN=ABCD.RAVI(MY INPUT DATASET),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSMSG DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
/*


Quote:
Error : Maxcc=0
Invalid dataset attributes: SORTIN LRECL - REASON CODE IS 05


If my i/p dataset is of LRECL=80 and has records then the above SORT PGM is working but it is writing the word 'NO RECORDS' along with the records that are there in the i/p dataset.

Scenario 1 : If my i/p d/s has records then the o/p should be:

RECORD 1
RECORD 2
RECORD 3

Scenario 2 :If my i/p d/s has NO records then the o/p should be:

NO RECORDS

Both scenarios are working for LRECL=80 but in scenario 1 it is also writing 'NO RECORDS', something as below:

RECORD 1
RECORD 2
RECORD 3
NO RECORDS

Can you please help me to modify this code which can be used for LRECL=230 & it should write only

RECORD 1
RECORD 2
RECORD 3
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1198
Location: Dublin, Ireland

PostPosted: Mon Jul 08, 2024 9:01 pm
Reply with quote

Suggest you look at ibmmainframes.com/about62719.html which had similar requirements.

Garry.
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 11
Location: India

PostPosted: Tue Jul 09, 2024 12:18 am
Reply with quote

Hi Garry,

Thank you for the provided link. I used IF condition as well in my code and is working fine. But I am getting the final maxcc=8 since my i/p dataset is empty.

When my i/p dataset is empty step1 will terminate and gives RC=8 but after completion of step 2 it should give RC=0. I am using the below code and it should give RC=0, instead of RC=8:

Code:
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=MY I/P FILE,DISP=SHR
//TOOLIN DD *
* SET RC=8 IF THE 'IN' DATA SET IS EMPTY, OR
* SET RC=0 IF THE 'IN' DATA SET IS NOT EMPTY
 COUNT FROM(IN) EMPTY RC8
/*
// IF STEP1.RC = 8 THEN
//STEP2 EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD *                     
//SORTOUT  DD DSN=MY I/P FILE,DISP=SHR
//SYSIN    DD *                     
  SORT FIELDS=COPY                   
  OUTFIL REMOVECC,HEADER1=('This functionality does not apply for given input')
/*         
//  ENDIF


I also tried to use the below:

Code:
//STEP3 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
   SET MAXCC=0


Though step1 gives RC=8, I wanted the final return code as 'zero'
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2081
Location: USA

PostPosted: Tue Jul 09, 2024 1:19 am
Reply with quote

cravisankar wrote:

I also tried to use the below:

Code:
//STEP3 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
   SET MAXCC=0


Though step1 gives RC=8, I wanted the final return code as 'zero'


SET MAXCC=0 can set the RC for the job step where it is used (e.g. STEP3.RC), but under no circumstances it can change the RC returned from other steps of this job.

Instead, you can try to check for empty dataset using IDCAMS utility - control statement PRINT INFILE(...) OUTFILE(...)

It returns RC=4 when dataset is empty. This value is typical for warning messages, and the job RC=4 is typically considered as the acceptable one.

It is also not clear: why not to use parameter EMPTY RC4?
Back to top
View user's profile Send private message
cravisankar

New User


Joined: 12 Feb 2024
Posts: 11
Location: India

PostPosted: Tue Jul 09, 2024 1:33 am
Reply with quote

I just used JOBRC=(STEP,STEP2) in my job card and it worked. It is giving what exactly I am looking for. Thank you for all your support.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2081
Location: USA

PostPosted: Tue Jul 09, 2024 1:40 am
Reply with quote

cravisankar wrote:
I just used JOBRC=(STEP,STEP2) in my job card and it worked. It is giving what exactly I am looking for. Thank you for all your support.


Why not just to use parameter EMPTY RC4?
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Email attachment from mainframe is empty PC Guides & IT News 9
No new posts Mainframe Dataset Binary or ASCII Mainframe Interview Questions 4
No new posts SPOOL to Mainframe dataset in batch mode JCL & VSAM 7
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
Search our Forums:

Back to Top