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

File Description and Subprogram


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

New User


Joined: 19 Dec 2005
Posts: 77

PostPosted: Mon Oct 30, 2006 4:48 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Mon Oct 30, 2006 5:48 pm
Reply with quote

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
View user's profile Send private message
srinathangya

New User


Joined: 19 Dec 2005
Posts: 77

PostPosted: Tue Oct 31, 2006 8:05 am
Reply with quote

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
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Tue Oct 31, 2006 10:08 am
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Oct 31, 2006 2:04 pm
Reply with quote

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
View user's profile Send private message
wastedmaky

New User


Joined: 06 Oct 2006
Posts: 5
Location: manila, philippines

PostPosted: Thu Nov 02, 2006 6:49 am
Reply with quote

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
View user's profile Send private message
toddnugen

New User


Joined: 01 Nov 2006
Posts: 9

PostPosted: Thu Nov 02, 2006 8:18 am
Reply with quote

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. icon_wink.gif
Back to top
View user's profile Send private message
toddnugen

New User


Joined: 01 Nov 2006
Posts: 9

PostPosted: Thu Nov 02, 2006 8:40 am
Reply with quote

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
View user's profile Send private message
premnath.mls

New User


Joined: 16 Aug 2006
Posts: 9

PostPosted: Thu Nov 02, 2006 10:14 am
Reply with quote

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
View user's profile Send private message
premnath.mls

New User


Joined: 16 Aug 2006
Posts: 9

PostPosted: Thu Nov 02, 2006 10:22 am
Reply with quote

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
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