Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need help to write the sort card for empty input

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Need help to write the sort card for empty input
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

Senior Member


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

PostPosted: Sun Apr 20, 2014 8:57 pm    Post subject: Re: Need help to write the sort card for empty input
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Sun Apr 20, 2014 9:09 pm    Post subject: Reply to: Need help to write the sort card for empty input
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    Post subject: Reply to: Need help to write the sort card for empty input
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    Post subject:
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: 1717
Location: UK

PostPosted: Sun Apr 20, 2014 11:19 pm    Post subject: Reply to: Need help to write the sort card for empty input
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Mon Apr 21, 2014 1:51 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Mon Apr 21, 2014 3:56 am    Post subject: Reply to: Need help to write the sort card for empty input
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us