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

Senior Member


Joined: 15 Aug 2015
Posts: 1257
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: 2455
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

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

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: 8697
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top