Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

File Description and Subprogram

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: File Description and Subprogram
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: 743
Location: Germany

PostPosted: Mon Oct 30, 2006 5:48 pm    Post subject:
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    Post subject:
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    Post subject:
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: 743
Location: Germany

PostPosted: Tue Oct 31, 2006 2:04 pm    Post subject: Re: File Description and Subprogram
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    Post subject: RE: File Description and Subprogram
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    Post subject:
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    Post subject:
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    Post subject: Re: File Description and Subprogram
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    Post subject: clear idea for my previous post
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts TWS EQQYCAIN - not sure how to get ap... mbenaud IBM Tools 0 Wed Dec 14, 2016 8:45 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us