For Programmers: Free Programming Magazines  


Home > Archive > Cobol > October 2007 > copylib cross-reference?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author copylib cross-reference?
Maxine

2007-10-17, 6:55 pm

Hi. I want to create a cross-reference between my cobol programs and
copylib members (in a zOS environment). Are there tools which can help me
with that? Obviously, this information is known at compile time, but is
there any way to access it?

Thanks,
Maxine
Robert

2007-10-17, 9:55 pm

On Wed, 17 Oct 2007 23:27:32 GMT, Maxine <mg@nospam.com> wrote:

>Hi. I want to create a cross-reference between my cobol programs and
>copylib members (in a zOS environment). Are there tools which can help me
>with that? Obviously, this information is known at compile time, but is
>there any way to access it?


Here is a program that creates a Rules file for the Unix and Windows MAKE program.
A rules file contains the base program name (executable) followed by the names of the
source program and all its copybook files, called 'dependencies' The MAKE program decides
whether a program needs to be compiled by comparing timestamps. If any of the source files
changed after the executable was built. a compilation is needed.

You could easily remove the Unix oriented stuff so it lists the main program followed by
the names of its copylib files. Getting a list of programs (done here with an ls command)
and reading copylib source would need to be changed for z/OS.

* Create rules file for 'make'
* getting dependencies from Cobol source
*
* This program reads Cobol source from ../cbl/*.cbl, picks out INCLUDEs
* and COPYs, writes a rule file named 'makerule.mak'. A typical rule:

* cs170bp.gnt: $(cbl)/cs170bp.cbl $(publish)\
* $(copydir)/cs_data_feed_status.cpy\
* $(copydir)/cs_log_app_message.cpy\
* ;$(run) cob $(options) $(cbl)/cs170bp.cbl\
* && date "%D %R cs170bp compiled by `logname`" >>$(root)/compile.log\
* && cp (bin)/cs170bp.+(gnt|idy) $(root)/../clntshr/bin/\
* || date "%D %R cs170bp did not compile for `logname`" >>$(root)/compile.log

$SET SOURCEFORMAT"FREE"
identification division
. program-id. makerule
*> author. Robert Wagner
*> Create makerule.mak for a library of Cobol programs.

. data division
. working-storage section
. 01 global-variables value low-values global
. 05 pic x
. 88 end-of-sentence value 'e' false low-value
. 05 pic x
. 88 end-of-source value 'e' false low-value
. 05 pic x
. 88 end-of-dir value 'e' false low-value
. 05 source-file-words.
. 10 source-file-word occurs 6 pic x(50).
. 01 word-area global
. 05 word-count binary pic s9(04)
. 05 word-limit value 2000 binary pic s9(04)
. 05 word-entry occurs 1 to 2000 depending on word-count
. 10 word-length binary pic s9(04)
. 10 word-text
. 15 word-byte occurs 50 pic x(01)
. 01 line-text-area global
. 05 line-length value zero binary pic s9(04)
. 05 line-limit value 256 binary pic s9(04)
. 05 line-text
. 10 line-byte occurs 1 to 256 depending on line-length pic x
. 01 copybook-area global
. 05 copybook-count binary pic s9(04)
. 05 copybook-limit value 200 binary pic s9(04)
. 05 copybook-entry occurs 1 to 200 depending on copybook-count
. 10 copybook-text pic x(50).
. 01 source-file-name global value low-values pic x(50).

. procedure division.
perform one-program until end-of-dir
call 'write-rule'
goback

. one-program.
call 'read-dir'
if end-of-dir exit paragraph end-if
move zero to copybook-count
set end-of-source to false
* display source-file-name
perform one-sentence until end-of-source or
copybook-count not less than copybook-limit
call 'write-rule'

. one-sentence.
set end-of-sentence to false
move zero to word-count
perform one-word until end-of-sentence or end-of-source or
word-count not less than word-limit
call 'syntax'

. one-word.
call 'parser'

. identification division
. program-id. write-rule
*> Writes entries for one program to makerule.mak
. environment division
. input-output section
. file-control
. select rule-file assign to '../makerule.mak'
organization is line sequential

. data division
. file section
. fd rule-file
. 01 rule-record pic x(256)

. working-storage section
. 01 persistent-variables
. 05 value low-value pic x(01)
. 88 file-open value 'y' false low-value
. 05 n value zero binary pic s9(04)
. 05 which-system pic x(02)
. 05 other-directory pic x(08)

. procedure division.
if not file-open
open output rule-file
set file-open to true
write rule-record from '# This file was generated by makerule'
write rule-record from space
end-if
if end-of-dir
close rule-file
set file-open to false
goback
end-if

move spaces to rule-record
string source-file-word (5) delimited by space
'.gnt: $(bin)/' delimited by size
source-file-word (5) delimited by space
'.gnt' delimited by size
into rule-record
if source-file-word (5) equal to 'makerule'
move spaces to rule-record
string source-file-word (5) delimited by space
': $(bin)/' delimited by size
source-file-word (5) delimited by space
into rule-record
end-if
write rule-record
move spaces to rule-record
string '$(bin)/' delimited by size
source-file-word (5) delimited by space
'.gnt: $(cbl)/' delimited by size
source-file-word (5) delimited by space
'.cbl $(publish)' delimited by size
into rule-record
if source-file-word (5) equal to 'makerule'
move spaces to rule-record
string '$(bin)/' delimited by size
source-file-word (5) delimited by space
': $(cbl)/' delimited by size
source-file-word (5) delimited by space
'.cbl $(publish)' delimited by size
into rule-record
end-if
write rule-record

perform varying n from 1 by 1 until n > copybook-count
if copybook-text (n) not = 'sqlca' and 'SQLCA'
move spaces to rule-record
string ' $(copydir)/' delimited by size
copybook-text (n) delimited by space
'.cpy' delimited by size
into rule-record
write rule-record
end-if
end-perform

move spaces to rule-record
string ' ;@echo Compiling ' delimited by size
source-file-word (5) delimited by space
'' delimited by size
into rule-record
write rule-record
move spaces to rule-record
string ' && $(run) cob $(options) $(cbl)/' delimited by size
source-file-word (5) delimited by space
'.cbl' delimited by size
into rule-record
if source-file-word (5) equal to 'makerule'
move spaces to rule-record
string ' && $(run) cob -x $(cbl)/' delimited by size
source-file-word (5) delimited by space
'.cbl' delimited by size
into rule-record
end-if
write rule-record

move spaces to rule-record
string ' && date +"%D %R ' delimited by size
source-file-word (5) delimited by space
' compiled by `logname`" >>$(root)/compile.log' delimited by size
into rule-record
write rule-record

move spaces to rule-record
string ' && chmod 664 ' delimited by size
source-file-word (5) delimited by space
'.*' delimited by size
into rule-record
write rule-record

move spaces to rule-record
string ' && mv ' delimited by size
source-file-word (5) delimited by space
'.* $(bin)' delimited by size
into rule-record
write rule-record

move spaces to rule-record
string ' || date +"%D %R ' delimited by size
source-file-word (5) delimited by space
' did not compile for `logname`" >>$(root)/compile.log' delimited by size
into rule-record
write rule-record

write rule-record from space

goback
. end program write-rule

. identification division
. program-id. syntax
*> Looks for the words 'copy' and 'include', adds next word to the list

. data division
. working-storage section
. 01 unqualified-variables
. 05 n value zero binary pic s9(04)
. 05 n-plus-1 binary pic s9(04)

. procedure division.
perform varying n from 1 by 1 until n > word-count
evaluate word-text (n)
when 'copy'
when 'COPY'
when 'include'
when 'INCLUDE'
perform pickup-copy
end-evaluate
end-perform
goback
. pickup-copy.
add 1 to copybook-count
compute n-plus-1 = n + 1
move word-text (n-plus-1) to copybook-text (copybook-count)
* display ' ' word-text (n-plus-1)
. end program syntax

. identification division
. program-id. read-dir
*> Returns the name of the next source file
. environment division
. input-output section
. file-control
. select dir-file assign to 'makerule.dir'
organization is line sequential

. data division
. file section
. fd dir-file
. 01 dir-record pic x(256)

. working-storage section
. 01 persistent-variables
. 05 value low-value pic x(01)
. 88 file-open value 'y' false low-value

. procedure division.
if not file-open
call 'SYSTEM' using z'ls ../cbl/*.cbl > makerule.dir'
open input dir-file
set file-open to true
end-if

read dir-file at end
set end-of-dir to true
close dir-file
set file-open to false
call 'SYSTEM' using z'rm makerule.dir'
goback
end-read

move spaces to source-file-name
move dir-record to source-file-name
move spaces to source-file-words
unstring source-file-name delimited by '.' or '/' into
source-file-word (1) source-file-word (2) source-file-word (3)
source-file-word (4) source-file-word (5) source-file-word (6)
*> word (5) is the program name
goback
. end program read-dir

. identification division
. program-id. parser
*> Parser. Returns the next word on a line.

. data division
. working-storage section
. 01 unqualified-variables
. 05 n value 1 binary pic s9(04)
. 05 n-plus-1 binary pic s9(04)
. 05 m binary pic s9(04)
. 05 byte-type pic x(01)
. 88 in-a-word value 'x' '9'
. 88 full-stop value '.'
. 05 quote-character pic x(01)
. 88 in-a-quote value x'22' x'27'
. 05 a-byte pic x(01)

. procedure division.
move space to byte-type
perform varying n from n by 1 until in-a-word or in-a-quote
if n greater than line-length
call 'read-source'
move 1 to n
if end-of-source goback end-if
else
perform pickup-byte
move a-byte to quote-character
compute n-plus-1 = n + 1
if full-stop and
(n less than line-length or
line-byte (n-plus-1) equal to space)
set end-of-sentence to true
add 1 to n
goback
end-if
end-if
end-perform

add 1 to word-count
move spaces to word-text (word-count)
subtract 1 from n

perform varying word-length (word-count) from 1 by 1 until
not (in-a-word or in-a-quote) or
word-length (word-count) not less length of word-text
move word-length (word-count) to m
move a-byte to word-byte (word-count, m)
if in-a-quote and a-byte equal to quote-character and
word-length (word-count) greater than 1
move space to quote-character
end-if
add 1 to n
if n greater than line-length goback end-if
perform pickup-byte
end-perform
subtract 1 from word-length (word-count)

goback

. pickup-byte.
move line-byte (n) to a-byte, byte-type
inspect byte-type converting
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM
NOPQRSTUVWXYZ-_0123456789' to
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx9999999999'

. identification division
. program-id. read-source
*> Returns the next line in a source file
*> Deletes comments
. environment division
. input-output section
. file-control
. select source-file assign to source-file-name
organization is line sequential

. data division
. file section
. fd source-file
. 01 input-record pic x(256)
. 01 input-card.
. 05 columns-1-6 pic x(06)
. 05 columns-7-72
. 10 pic x(01)
. 10 columns-8-72 pic x(65)
. 05 columns-73-80 pic x(08)

. working-storage section
. 01 persistent-variables
. 05 value low-value pic x(01)
. 88 file-open value 'y' false low-value
. 05 value 'f' pic x(01) *> default to freeform
. 88 free-form value 'f'.
. 88 fixed-form value low-value.
. 01 unqualified-variables.
. 05 n binary pic s9(04)
. 05 n-plus-1 binary pic s9(04)

. procedure division.
if not file-open
open input source-file
set file-open to true
end-if

read source-file at end
close source-file
set end-of-source to true
set file-open to false
move zero to line-length
goback
end-read

if fixed-form
move 66 to line-length, line-limit
move columns-7-72 to line-text
else
move 256 to line-length, line-limit
move input-record to line-text
end-if

if columns-7-72 equal to '$SET SOURCEFORMAT"FREE"' or
columns-7-72 equal to '$set sourceformat"free"' or
columns-8-72 equal to '@OPTIONS SRF(FREE,FREE)'
set free-form to true
move zero to line-limit
end-if
if columns-7-72 equal to '$SET SOURCEFORMAT"FIXED"' or
columns-8-72 equal to '@OPTIONS SRF(FIX,FIX)'
set fixed-form to true
move zero to line-limit
end-if
if line-byte (1) equal to '*' or '/'
move zero to line-limit
end-if
move zero to line-length
perform varying n from 1 by 1 until n greater than line-limit
compute n-plus-1 = n + 1
if line-byte (n) equal to '*' and
n less than line-limit and
line-byte (n-plus-1) equal to '>'
compute line-length = n - 1
exit perform
end-if
if line-byte (n) not equal to space
move n to line-length
end-if
end-perform
goback
. end program read-source
. end program parser
. end program makerule
William M. Klein

2007-10-18, 7:55 am

Yes, there are a number of products on the z/OS platform that do this type of
thing. You may want to post to IBM-MAIN to get some recommendations. Off the
top of my head, I can't remember which ones are still being sold.

There are ALSO products that do this for <IBM> mainframe code - where
development is done on the PC. I know that Micro Focus' Revolve technology does
it - but I think there are others as well.

--
Bill Klein
wmklein <at> ix.netcom.com
"Maxine" <mg@nospam.com> wrote in message
news:Xns99CCA76DE7F0Amgusenetatpcgdotnet
@207.115.17.102...
> Hi. I want to create a cross-reference between my cobol programs and
> copylib members (in a zOS environment). Are there tools which can help me
> with that? Obviously, this information is known at compile time, but is
> there any way to access it?
>
> Thanks,
> Maxine



Larry Kahm

2007-10-18, 6:55 pm

Since you mention z/OS, I'll ask: what change management software are you
using?

Endevor has a cross-reference facility built-in, as does ChangeMan ZMF. Ask
your change management administrator for where the options/reports are
located.

Larry Kahm
Heliotropic Systems, Inc.

"Maxine" <mg@nospam.com> wrote in message
news:Xns99CCA76DE7F0Amgusenetatpcgdotnet
@207.115.17.102...
> Hi. I want to create a cross-reference between my cobol programs and
> copylib members (in a zOS environment). Are there tools which can help me
> with that? Obviously, this information is known at compile time, but is
> there any way to access it?
>
> Thanks,
> Maxine



Charles Hottel

2007-10-18, 9:55 pm


"Maxine" <mg@nospam.com> wrote in message
news:Xns99CCA76DE7F0Amgusenetatpcgdotnet
@207.115.17.102...
> Hi. I want to create a cross-reference between my cobol programs and
> copylib members (in a zOS environment). Are there tools which can help me
> with that? Obviously, this information is known at compile time, but is
> there any way to access it?
>
> Thanks,
> Maxine


Where are your programs stored? In LIBRARIAN, a ROSCOE library or a PDS?

If you have ROSCOE then see http://www.cbttape.org/cbtdowns.htm for some
RPFs that I contributed.

See the SCANROS or SCANLIB, or SCANPDS rpfs. They use some other RPFs so get
them all. If you need more help I am available. It is not hard if you have a
list of the names of all the programs and if they are not scattered in too
many different pds libraries. For example if all your programs are
DSN=MY.PDS then the command:

SCANPDS "MY.PDS" COPY MIST

would create a RPF called MIST (short for my instruction but call it
whatever you want). Then just run the MIST rpf and it searches each member
in the pdf for the string "COPY" and the results are placed in ROSCOE member
@TEMP. The results look like this:

MY.PDS(MEM1)
xxxxxxxxxxxxxxxxxxxxxCOPYxxxxxxxxxxxxxxx
xxxxxxxx
yyyyyyyyyyyCOPYyyyyyyyyyyyyyyyyyyyyyy
MY.PDS(MEM2)
zzzzzzzzzzzzzzzzzzzzzzzzCOPYzzzzzzzzzzzz
zzzzzzzzzzzz

It will show each line where it found the searched for string. SCANROS
searches an entire ROSCOE library (i.e. one prefix) and SCANLIB searches a
LIBRARIAN dataset. Both give results similar to the above.


If you don't have ROSCOE you cound use SUPERC to scan for "copy" :

//SEARCH EXEC PGM=ISRSUPC,
// PARM=(SRCHCMP,
// 'ANYC')
//NEWDD DD DSN=dataset.to.search,
// DISP=SHR
//OUTDD DD SYSOUT=(X)
//SYSIN DD *
SRCHFOR 'COPY'
/*

The trick is generating a step for each program. Again I would use ROSCOE
but you could use REXX . I am not that familiar with TSO/ISPF but there
might be a way to use it to invoke SUPERC on your pds members. I am sur
someone here or on ibm-main knows the answer.



Charles Hottel

2007-10-18, 9:55 pm


"Charles Hottel" <chottel@earthlink.net> wrote in message
news:13hg16r90gp0bce@corp.supernews.com...
>
> "Maxine" <mg@nospam.com> wrote in message
> news:Xns99CCA76DE7F0Amgusenetatpcgdotnet
@207.115.17.102...
>
> Where are your programs stored? In LIBRARIAN, a ROSCOE library or a PDS?
>
> If you have ROSCOE then see http://www.cbttape.org/cbtdowns.htm for some
> RPFs that I contributed.
>
> See the SCANROS or SCANLIB, or SCANPDS rpfs. They use some other RPFs so
> get them all. If you need more help I am available. It is not hard if you
> have a list of the names of all the programs and if they are not scattered
> in too many different pds libraries. For example if all your programs are
> DSN=MY.PDS then the command:
>
> SCANPDS "MY.PDS" COPY MIST
>
> would create a RPF called MIST (short for my instruction but call it
> whatever you want). Then just run the MIST rpf and it searches each
> member in the pdf for the string "COPY" and the results are placed in
> ROSCOE member @TEMP. The results look like this:
>
> MY.PDS(MEM1)
> xxxxxxxxxxxxxxxxxxxxxCOPYxxxxxxxxxxxxxxx
xxxxxxxx
> yyyyyyyyyyyCOPYyyyyyyyyyyyyyyyyyyyyyy
> MY.PDS(MEM2)
> zzzzzzzzzzzzzzzzzzzzzzzzCOPYzzzzzzzzzzzz
zzzzzzzzzzzz
>
> It will show each line where it found the searched for string. SCANROS
> searches an entire ROSCOE library (i.e. one prefix) and SCANLIB searches a
> LIBRARIAN dataset. Both give results similar to the above.
>
>
> If you don't have ROSCOE you cound use SUPERC to scan for "copy" :
>
> //SEARCH EXEC PGM=ISRSUPC,
> // PARM=(SRCHCMP,
> // 'ANYC')
> //NEWDD DD DSN=dataset.to.search,
> // DISP=SHR
> //OUTDD DD SYSOUT=(X)
> //SYSIN DD *
> SRCHFOR 'COPY'
> /*
>
> The trick is generating a step for each program. Again I would use ROSCOE
> but you could use REXX . I am not that familiar with TSO/ISPF but there
> might be a way to use it to invoke SUPERC on your pds members. I am sur
> someone here or on ibm-main knows the answer.
>
>
>


Opps on the web url you want file 532.


Andreas Lerch

2007-10-19, 6:55 pm

Hi Maxine

you can use ISRLEMX to expand and list any sources - cobol include -=20=

and generate references...

look at google: ixrlemx parm to get some excamples

einen schoenen tag
Andreas Lerch



?? Urspr=FCngliche Nachricht

Am 18.10.07, 01:27:32, schrieb Maxine <mg@nospam.com> zum Thema copylib =

cross-reference?:


> Hi. I want to create a cross-reference between my cobol programs and
> copylib members (in a zOS environment). Are there tools which can help=

=20
me
> with that? Obviously, this information is known at compile time, but=20=


is
> there any way to access it?


> Thanks,
> Maxine




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com