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

JCL to empty the input flat file without deleting it


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krishnadevanur

New User


Joined: 02 Aug 2006
Posts: 8

PostPosted: Mon Jan 15, 2007 5:19 pm
Reply with quote

hi folks,

I want to write a JCL in which the executing program will empty the input flatfile and empties it.(It should not delete). there may be any kind of record format for the flat file
Also my question is, if we write a COBOL program to do the operation and the input file is of FB format, how will the cobol program calculate the length and how does t empties ?

Please help me in coding the JCL.

Thanks,

Krishna
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Jan 15, 2007 5:31 pm
Reply with quote

krishnadevanur wrote:
I want to write a JCL in which the executing program will empty the input flatfile and empties it.(It should not delete). there may be any kind of record format for the flat file
Empty? You can use the utility of your choice and open the file for output with a disp of OLD.
Quote:
Also my question is, if we write a COBOL program to do the operation and the input file is of FB format, how will the cobol program calculate the length and how does t empties ?
The operation? The COBOL program had better know the length of the record but doesn't need to know the length of the file. Like the above utility, open for output with a disp of OLD.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Jan 15, 2007 9:45 pm
Reply with quote

Hello,

If you have an input file and after successfully reading the data your requirement is to "empty" the file you can do this within your COBOL program that reads the file.

Open the file as input and read until end-of-file. When the AT END is reached, close the file. NOW - open the file as output and close the file. What remains will be an empty file. In the DD statement, specify DISP=OLD.

Keep in mind that when you do this, you will not be able to re-run that program without first re-creating the input data.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Jan 16, 2007 4:28 am
Reply with quote

Krishna, This JCL will empty you dataset

Code:

//JS00100  EXEC PGM=IDCAMS               
//DDDMMY   DD DUMMY                     
//DDOUT    DD DSN=YOUR.SEQ.FILE,         
//            DISP=OLD                   
//SYSIN    DD *                         
  REPRO IFILE(DDDMMY) OFILE(DDOUT)       
//SYSPRINT DD SYSOUT=*                   
//SYSOUT   DD SYSOUT=*                   
Back to top
View user's profile Send private message
krishnadevanur

New User


Joined: 02 Aug 2006
Posts: 8

PostPosted: Mon Feb 19, 2007 8:00 pm
Reply with quote

Thanks William, The info you gave me was of great help.
Thank you.

Krishna






William Thompson wrote:
krishnadevanur wrote:
I want to write a JCL in which the executing program will empty the input flatfile and empties it.(It should not delete). there may be any kind of record format for the flat file
Empty? You can use the utility of your choice and open the file for output with a disp of OLD.
Quote:
Also my question is, if we write a COBOL program to do the operation and the input file is of FB format, how will the cobol program calculate the length and how does t empties ?
The operation? The COBOL program had better know the length of the record but doesn't need to know the length of the file. Like the above utility, open for output with a disp of OLD.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1209
Location: Bangalore,India

PostPosted: Tue Feb 20, 2007 10:26 am
Reply with quote

Hi There,
You can also use sort for this
Code:

//STEP010 EXEC PGM=SORT                           
//SORTIN  DD  DSN=YOUR.DATASET,DISP=SHR
//SORTOUT DD  DSN=YOUR.DATASET,,DISP=SHR
//SYSOUT  DD SYSOUT=*                             
//SYSIN   DD *                                     
  OPTION COPY                                     
  OMIT COND=ALL                                   
/*   
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Tue Feb 20, 2007 11:58 am
Reply with quote

One more way of empting the file,
Code:

//*THIS JOB IS USED TO CREATE EMPTY DATASET OR EMPTY DATA IN A DATASET 
//STEP1 EXEC PGM=IEBGENER                                               
//SYSUT1 DD DUMMY                                                       
//SYSUT2 DD DSN=file name,                 
//         DISP=SHR                                                     
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN DD *                                                           
  GENERATE MAXFLDS=1                                                   
/*                                                                     
//SYSOUT  DD SYSOUT=*                                                   
//*                                           
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Wed Feb 21, 2007 10:48 am
Reply with quote

Hey,

What does this GENERATE MAXFIELDS do?
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1209
Location: Bangalore,India

PostPosted: Wed Feb 21, 2007 11:47 am
Reply with quote

Hi There,

Please refer the below link

virtual.clemson.edu/dcit/sig/docs/os390/o440.html
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts IGYPG3178-I when compiling a pgm read... COBOL Programming 6
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts Sorting date into YYYYMMDD, and creat... DFSORT/ICETOOL 13
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts To Populate Trailer cnt in the file w... SYNCSORT 1
Search our Forums:


Back to Top