View previous topic :: View next topic
|
Author |
Message |
cravisankar
New User
Joined: 12 Feb 2024 Posts: 14 Location: India
|
|
|
|
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 |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
Back to top |
|
|
cravisankar
New User
Joined: 12 Feb 2024 Posts: 14 Location: India
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2131 Location: USA
|
|
|
|
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 |
|
|
cravisankar
New User
Joined: 12 Feb 2024 Posts: 14 Location: India
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2131 Location: USA
|
|
|
|
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 |
|
|
|