View previous topic :: View next topic
|
Author |
Message |
Vidya Kajale
New User
Joined: 01 Jun 2010 Posts: 43 Location: India
|
|
|
|
Hi,
I need help for the sort card that will write or insert some characters into output file if input file is empty.
Can someone please help me in this case. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Vidya Kajale wrote: |
Hi,
I need help for the sort card that will write or insert some characters into output file if input file is empty.
Can someone please help me in this case. |
If you tell us more about "some characters", such as - at what position in o/p you want to insert the character/s, what character/s along with LRECL/RECFM of input and output - it'll help us to help you. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What do you want to happen if your input file does contain data? |
|
Back to top |
|
|
Vidya Kajale
New User
Joined: 01 Jun 2010 Posts: 43 Location: India
|
|
|
|
Some characters means just a string saying "This functionality does not apply for given input".
Lrec=511, Recfm=fb
I need this sort card because my job has the next step after this sort step in which program is getting executed and this pgm abends if input is empty.so in order pgm should
not abend I need to put some statement into the input.
If valid input is present then I want to copy input data to output and pass this valid data to program. So that for valid data program functionality gets performed |
|
Back to top |
|
|
Vidya Kajale
New User
Joined: 01 Jun 2010 Posts: 43 Location: India
|
|
|
|
I tried to achieve this usung sort inrec but fail to do so.Need sort card urgently. Is there any way we can achieve the same. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
A forum is not the place for "urgent" especially over a long holiday period.
How do you expect to use INREC if you have no input records?
The correct way to resolve this is to fix the program so that it does the appropriate action if the there is no data for it - e.g. issue message and terminate processing, with or without a zero return code. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
As Nic told, usually this needs to be handled in the application program instead of modifying and making JOB complex.
However, if I understood correctly you may wants to add below two steps before your actual program gets executed,
Step 1: to set the RC in case of empty file
Code: |
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...
//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
/*
|
Step 2: To add the literal as the program expect
Code: |
// IF STEP1.RC = 8 THEN
//STEP2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DSN=Your output file,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,HEADER1=('This functionality does not apply for given input')
/* |
If you want the SORTIN to be DUMMY instead of DD *, you can use:
Code: |
//SORTIN DD DUMMY,RECFM=FB,LRECL=80 |
I hope this would be close to what you expect to happen, but again, this is not advised to have it than having simply program changed. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
One of the advantages files with headers and trailers (and there is more than one advantage of them) is that if they are physically empty, you know there is a problem, if they are logically empty, the program can know whether or not that is valid.
A program which fails with an empty file, but which works with a spurious record on it and no actual data is just wrong.
Depending on whether the file in quesiton is SORTOUT or an OUTFIL dataset, look at NULLOUT or NULLOFL. An RC, with a limited set of values, can be generated for empty output datasets.
Once you have an RC, you can do something specific for an empty file.
Personally I'd go with NicC's suggestion, and fix the stupid program which falls over. |
|
Back to top |
|
|
|