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

To create an empty file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Kumar Sandeep

New User


Joined: 24 Apr 2020
Posts: 10
Location: India

PostPosted: Sun Dec 13, 2020 2:48 pm
Reply with quote

I have a requirement to create an empty file using COBOL.
The file should contain only header and trailer and should be of below format.
HDR120320000000000+000000000000
TRL120320000000000+000000000000

The fields from 04th to 09th is current date of form MMDDYY.
The program should create an empty file with mentioned format everyday (with current date).

Thank you.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


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

PostPosted: Sun Dec 13, 2020 3:22 pm
Reply with quote

Honestly, use DFSORT for such a simple task.
Code:
//INIT     EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
DUMMY                                                           
/*                                                             
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  OUTFIL IFTHEN=(WHEN=INIT,BUILD=(DATE1)),                     
    IFTHEN=(WHEN=NONE,                                         
      BUILD=(1:C'HDR',1,8,Y4T,DTNS(MDY),                       
             +0,LENGTH=9,EDIT=(TTTTTTTTT),                     
             +0,LENGTH=13,EDIT=(STTTTTTTTTTTT),SIGNS=(+,,,),/, 
             1:C'TRL',1,8,Y4T,DTNS(MDY),                       
             +0,LENGTH=9,EDIT=(TTTTTTTTT),                     
             +0,LENGTH=13,EDIT=(STTTTTTTTTTTT),SIGNS=(+,,,)))   
  END                                                           
/*

Output:
Code:
*********************************
HDR121320000000000+000000000000 
TRL121320000000000+000000000000 
*********************************
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Sun Dec 13, 2020 5:16 pm
Reply with quote

Why can you not code this simple COBOL program yourself? You should have at least tried before posting here. This is not a 'do my work for me' site.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 924
Location: Maryland

PostPosted: Sun Dec 13, 2020 9:10 pm
Reply with quote

Kumar Sandeep wrote:
I have a requirement to create an empty file using COBOL.
The file should contain only header and trailer and should be of below format.
HDR120320000000000+000000000000
TRL120320000000000+000000000000

The fields from 04th to 09th is current date of form MMDDYY.
The program should create an empty file with mentioned format everyday (with current date).

Thank you.

It all sounds as if you was a manager who assigns a new task to his employees in this forum?

At the same time, the task itself is a sort of simple test for first grade school kids.
Back to top
View user's profile Send private message
Kumar Sandeep

New User


Joined: 24 Apr 2020
Posts: 10
Location: India

PostPosted: Mon Dec 14, 2020 7:12 pm
Reply with quote

I am getting an error in date when I am trying with COBOL so need inputs here to proceed. Also, if this could also be done through JCL I will proceed with the same.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8569
Location: Dubuque, Iowa, USA

PostPosted: Mon Dec 14, 2020 7:32 pm
Reply with quote

Quote:
I am getting an error in date when I am trying with COBOL so need inputs here to proceed. Also, if this could also be done through JCL I will proceed with the same.
What kind of error are you getting in COBOL? Is it a compile error? Is it a run-time error? If there is a message number for the error, what is it? You've pretty much told us nothing that would allow us to help you.

And this cannot be done "through JCL" since JCL only allows programs to execute. You have been provided a working program using SORT to do what you want.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Converting a file from PD to display ... SYNCSORT 4
No new posts Record count of RECFM=U tape file DFSORT/ICETOOL 17
This topic is locked: you cannot edit posts or make replies. Write Character to Hexadecimal file w... COBOL Programming 8
No new posts Checking the total counts inside a re... JCL & VSAM 5
No new posts File-aid batch how to repeat a line... Compuware & Other Tools 2
Search our Forums:

Back to Top