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

Insert trailer for non empty file only


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

New User


Joined: 29 Aug 2014
Posts: 2
Location: China

PostPosted: Mon Mar 06, 2023 3:38 pm
Reply with quote

We have a requirement for insert/add trailer for non empty file.

Please find the sample below.

Input file is non empty:
> Input file is non empty as below.
abc 1234

> Output file will be as below.
abc 1234
1A(1A is the trailer record)

Input file is empty:
> Output file is empty.

Would anyone can help?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1335
Location: Bamberg, Germany

PostPosted: Mon Mar 06, 2023 5:02 pm
Reply with quote

Please, use the Code Button when presenting Code/Data. Have you tried anything yourself so far?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Mon Mar 06, 2023 9:52 pm
Reply with quote

Use two JCL steps:

1)
Code:
//NORMAL EXEC PGM=SORT,PARM='NULLOUT=RC4'

Create your output as if it was not empty

2)
Code:
//DUMMY EXEC PGM=SORT,COND=(4,EQ,NORMAL)

When empty, override the same output from //NORMAL with the special record(s)
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1335
Location: Bamberg, Germany

PostPosted: Mon Mar 06, 2023 10:39 pm
Reply with quote

This snippet does the job from IN to OUT

Code:
//ICETOOL  EXEC PGM=ICETOOL         
//IN       DD *                     
abc 1234                             
/*                                   
//OUT      DD SYSOUT=*               
//TRLUCNTL DD *                     
  OUTFIL FNAMES=(OUT),               
    TRAILER1=(C'1A')                 
/*                                   
//DFSMSG   DD SYSOUT=*               
//TOOLMSG  DD SYSOUT=*               
//TOOLIN   DD *                     
  MODE STOP                         
  COUNT FROM(IN) EMPTY RC8           
  COPY FROM(IN) USING(TRLU)         
/*
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Tue Mar 07, 2023 12:01 am
Reply with quote

Joerg.Findeisen wrote:
This snippet does the job from IN to OUT

Code:
//ICETOOL  EXEC PGM=ICETOOL         
//IN       DD *                     
abc 1234                             
/*                                   
//OUT      DD SYSOUT=*               
//TRLUCNTL DD *                     
  OUTFIL FNAMES=(OUT),               
    TRAILER1=(C'1A')                 
/*                                   
//DFSMSG   DD SYSOUT=*               
//TOOLMSG  DD SYSOUT=*               
//TOOLIN   DD *                     
  MODE STOP                         
  COUNT FROM(IN) EMPTY RC8           
  COPY FROM(IN) USING(TRLU)         
/*


Is this not required to be marked as:
Quote:

Input file is empty:
>
Code:
Output file is empty.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1335
Location: Bamberg, Germany

PostPosted: Tue Mar 07, 2023 10:37 am
Reply with quote

sergeyken wrote:
Is this not required to be marked as..

I have read it as adding a single line trailer ("1A") when DSN is not empty.
Back to top
View user's profile Send private message
james chen

New User


Joined: 29 Aug 2014
Posts: 2
Location: China

PostPosted: Wed Mar 08, 2023 8:14 am
Reply with quote

sergeyken wrote:
Joerg.Findeisen wrote:
This snippet does the job from IN to OUT

Code:
//ICETOOL  EXEC PGM=ICETOOL         
//IN       DD *                     
abc 1234                             
/*                                   
//OUT      DD SYSOUT=*               
//TRLUCNTL DD *                     
  OUTFIL FNAMES=(OUT),               
    TRAILER1=(C'1A')                 
/*                                   
//DFSMSG   DD SYSOUT=*               
//TOOLMSG  DD SYSOUT=*               
//TOOLIN   DD *                     
  MODE STOP                         
  COUNT FROM(IN) EMPTY RC8           
  COPY FROM(IN) USING(TRLU)         
/*


Is this not required to be marked as:
Quote:

Input file is empty:
>
Code:
Output file is empty.
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 Unable to interpret a hex value to De... COBOL Programming 7
No new posts how to eliminate null indicator value... DB2 7
No new posts Reading Empty Dataset DFSORT/ICETOOL 5
No new posts Email attachment from mainframe is empty PC Guides & IT News 9
No new posts Format Binary file to EBCDIC JCL & VSAM 4
Search our Forums:

Back to Top