Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Zux995 Absent Member.
Absent Member.
717 views

Reading Program Names from Indexed File

Hi All,

I need your help again guys i have a indexed file here Called "CalledProgs", this file stored Program names now i am required to write a program that will loop through all these program names and search for program names stored in each. 

Don't be confused these program names also contained different program names stored, i have written a code here below which i used to retrieve these names from an input file called Mainmenu.cbl. now i am required to continue with this code by means of reading this indexed file with was an output file when i was calling for the program names. 

now i am tasked to read from each program name the program names written on it and Add to the same output file "CalledProgs".

i hope its clear, below is the program i used to retrieve these called program names that are in the output file.

 

 

PROCEDURE DIVISION.
*===================*

*----------------------------------------------------------------

DECLARATIVES.
io-error section.
use after error procedure on

sort-file
Main-out
Mainmenu-Input
Main-ProgCall.
END DECLARATIVES.

*----------------------------------------------------------------*



a100-Main.
*----------

open input MainMenu-Input.
open output Main-out.
open output Main-ProgCall.

if mmStatus > "02"
move "Open input error on Mainmenu" to cdmRecord
move mmStatus to cdmRecord
write cdmRecord.
move zeroes to countRec.
perform a100-read thru a100-exit.
go to a100-close.

a100-close.
*-----------
close

* Sort-file
Main-out
Mainmenu-Input
Main-ProgCall.

Sort Sort-file
ON ASCENDING KEY sortProgName
Using Main-out
giving Main-ProgCall.

a100-read.
*----------
move zeroes to CAll-COUNT.
move zeroes to QouteMM.
move zeroes to wsInvalidCall.

read Mainmenu-Input next at end go to a100-main.
if mmStatus > "02"
go to a100-close.

add 1 to countRec.

* Skip commented parts.
IF mmRecord(7:1)= "*"
go to a100-read.

* validate calls for menus
INSPECT mmRecord Tallying wsInvalidCall for all
wsMenu.

if wsInvalidCall >= 1
go to a100-read.

*//// THIS IS WHERE YOU WILL FIND THE PROG THAT HAS BEEN CALLED
INSPECT mmRecord TALLYING
CALL-COUNT FOR ALL " call ".

IF CALL-COUNT >= 1
PERFORM a100-Search
ELSE
go to a100-read.

 


a100-exit.
*-----------
exit.

a200-read.
*----------
read Main-out next at end go to a100-close.
if outStatus > "02"
go to a100-close.

 


a100-Search.
*------------
INSPECT mmRecord Tallying
QouteMM for all wsQoute.

if QouteMM >= 1
* Checking names in Double qoutes
Perform get-Progname
else
go to a100-read.

get-progname.
*--------------
* Retrieve program names and move to indexed file.
unstring mmRecord delimited by wsQoute
into wspart1,wspart2,wspart3.

move wspart2 to Pname.

* Converting all Programe names to Upper-case
call "c$toupper" using Pname
value length of Pname.

move Pname to outProgname.
move "MAINMENU" to outCallingProg.
write outRecord.

go to a100-read.


**==============================================================*

best regards

Zux

0 Likes
5 Replies
Micro Focus Expert
Micro Focus Expert

RE: Reading Program Names from Indexed File

Please descibe the FD for this indexed file. It's possible that the FD for the indexed file has a field - like 05 program-name
If so, you open the file, read a record, take the value in program-name (if there is a value) and then do whatever you want with that value. You do a read next, process the next record in the index file and read next until you get to the end of the file.
0 Likes
Zux995 Absent Member.
Absent Member.

RE: Reading Program Names from Indexed File

Yes i do have a program-Name as field like this.
here i am required to read each program name listed then when using it, i have to go through the whole program of the specified Program-name and search for any calls there. for every names in the listed indexed file.

hope you get me.
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Reading Program Names from Indexed File

This seems very much like the program you created for Reading Acucobol program using another program. Lets call that program - readprog. Now you make a program that opens the file, reads each record, when the record has a filled field - progname, you then call readprog using the progname. readprog would need to be made so it can be called - procedure division using, and the new program "readfile" would use the linkage section, you move the value from progname to the linkage variable and that matches the variable in readprog - procedure division using.
0 Likes
Zux995 Absent Member.
Absent Member.

RE: Reading Program Names from Indexed File

Hello Shjerpe,
could you please demonstrate in a way of example?

Program-Check.
*--------------
open i-o Main-ProgCall.
open output Main-Read.

read Main-ProgCall next at end go to Program-Check.
if cdmStatus > "02"
go to a100-close.
c
String cdmProgName delimited by space ".cbl"
into outputRead.
write ReadRecord.

move cdmProgname to newProgname.
go to Program-Check.
i have written this in my program as part of checking program names from the indexed file. but i am getting errors like "perform stack overflow..."
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Reading Program Names from Indexed File

read Main-ProgCall next at end perform Program-Check.
if cdmStatus > "02"
perform a100-close.

what other file status errors .. I would run the program in debug and monitor the cmdStatus, see if you get an 02 or something else


The stack overflow pretty much means you're not getting to the exit of the program
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.