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

Need help to write the sort card for empty input


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

New User


Joined: 01 Jun 2010
Posts: 43
Location: India

PostPosted: Sun Apr 20, 2014 6:58 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sun Apr 20, 2014 8:57 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Apr 20, 2014 9:09 pm
Reply with quote

What do you want to happen if your input file does contain data?
Back to top
View user's profile Send private message
Vidya Kajale

New User


Joined: 01 Jun 2010
Posts: 43
Location: India

PostPosted: Sun Apr 20, 2014 9:59 pm
Reply with quote

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
View user's profile Send private message
Vidya Kajale

New User


Joined: 01 Jun 2010
Posts: 43
Location: India

PostPosted: Sun Apr 20, 2014 10:24 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sun Apr 20, 2014 11:19 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Mon Apr 21, 2014 1:51 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Apr 21, 2014 3:56 am
Reply with quote

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
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top