View previous topic :: View next topic
|
Author |
Message |
Kumar Sandeep
New User
Joined: 24 Apr 2020 Posts: 10 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1257 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2024 Location: USA
|
|
|
|
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 |
|
|
Kumar Sandeep
New User
Joined: 24 Apr 2020 Posts: 10 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|