View previous topic :: View next topic
|
Author |
Message |
srinathangya
New User
Joined: 19 Dec 2005 Posts: 77
|
|
|
|
Im having one main program in cobol,
and having one sub program
in that sub prorgram im reading record from (input) one file
from that sub program im calling another sub program
in that second sub program im writing in a file(output).
if im executing main program load module
where to mention these input and output files dd names...
Please provide me the solution if possible with codings
( i hope i typed my question clearly...) |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
...in that second sub program im writing in a file(output).
There you have do declare the file.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DRUCKER0 ASSIGN DRUCKER0.
DATA DIVISION.
FILE SECTION.
FD DRUCKER0
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS F.
01 DRUCKER0-LISTE.
10 DRU0-ZEILE PIC X(0132).
WORKING-STORAGE SECTION.
...Field declarations
Regards, Umeysan |
|
Back to top |
|
|
srinathangya
New User
Joined: 19 Dec 2005 Posts: 77
|
|
|
|
ThanQ..but how will I read the file in the first subprogram if I am just declaring the file only in the second sub-program??
Pls..let me know..
Srinath. |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
hi srinathangya,
As of my understanding you are not Updating the input file.
If not then you need to declare input file in the SUB-PROGRAM1 and output file in SUB-PROGRAM2.
~Vamsi |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
It's always the same. There, where you do an Open/Close against a dataset, there you have to declare the file specifications.
Regards, UmeySan |
|
Back to top |
|
|
wastedmaky
New User
Joined: 06 Oct 2006 Posts: 5 Location: manila, philippines
|
|
|
|
Hi,
You can DECLARE and OPEN the dataset in the SUBPROGRAM1 and try to make a PASS-AREA from SUBPROGRAM1 and LINKAGE SECTION in SUBPROGRAM2 where you can put the data file that you've just read. This might help if you're trying to access the same file from SUBPROGRAM1 to SUBPROGRAM2.
I hope this helps...
Regards,
MAky |
|
Back to top |
|
|
toddnugen
New User
Joined: 01 Nov 2006 Posts: 9
|
|
|
|
Several ways. With structured design:
open close files, select clauses in main program
read file in sub program1 then passing record from working-storage.
write record in sub program2 with record in linkage section.
Good luck. |
|
Back to top |
|
|
toddnugen
New User
Joined: 01 Nov 2006 Posts: 9
|
|
|
|
General STRUCTURED TECHNIQUE looks like this:
Main program:
Open
read first
Call subprogram1 using recorddata
close
subprogram1:
loop until eof
call subprogram2 using recorddata
read file
goback.
subprogram2:
write record
goback.
Additionally, need to pass record from working-storage of main program
and pick it up in linkage section of sub program1. |
|
Back to top |
|
|
premnath.mls
New User
Joined: 16 Aug 2006 Posts: 9
|
|
|
|
hi..
In the subprogram1
In the file section define the read file
In the procedure division include the read statement and then call the subprogram2 which do write operation.Mainly make the called program to run from top to bottom rather from the procedure division.
In the subprogram2
In the file section define write file
In procedure division include the write statement.
i give you more clear idea in another 20 minutes |
|
Back to top |
|
|
premnath.mls
New User
Joined: 16 Aug 2006 Posts: 9
|
|
|
|
hi..
if you give 'CANCEL' after your call satement or like
PROGRAM-ID. name IS INITIAL PROGRAM.
This will make the called program to run from the begining.. |
|
Back to top |
|
|
|