Data availability in subprogram

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Data availability in subprogram

Postby isai_22 » Wed Mar 30, 2011 5:27 pm


I have read a file & displayed the necessary field n the main program. The value s correct.
After tat i make a call to another pgm (sub pgm) and wen i try to dispaly the same field,it displays junk values.

Select clause is the same in both programs.
Both programs are compiled succesfully.
The control goes to the sub program.

Please help me solving this scenario.
Thank U!!!
Posts: 5
Joined: Mon Jul 26, 2010 8:34 am
Has thanked: 0 time
Been thanked: 0 time

Re: Data availability in subprogram


Re: Data availability in subprogram

Postby BillyBoyo » Wed Mar 30, 2011 5:56 pm

You say you have a "select clause" in both programs. Don't. If you want to use a sub-program, don't try to read/write the same file as another program. Just asking for trouble.

What is your requirement, such that you feel the need to do this?
Global moderator
Posts: 3735
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 254 times

Re: Data availability in subprogram

Postby Robert Sample » Wed Mar 30, 2011 5:59 pm

Why do you have a SELECT clause in the subprogram? SELECT statements are used to identify files, and you normally pass data to a subprogram by using CALL <subprogram> USING <variable list> with the subprogram having PROCEDURE DIVISION USING <variable list> and LINKAGE SECTION variables to match. There's no reason to have a SELECT statement in the subprogram.
Robert Sample
Global moderator
Posts: 3100
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 177 times

Return to IBM Cobol


  • Related topics
    Last post