Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

COPY/REPLACING statement.

170 views
Skip to first unread message

SR

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to

I want to copy a copybook into my program and replace all occurrences of
(PR)- in the copybook by spaces.

My statement looks like this:
COPY SBKACDET REPLACING ==(PR)-== BY == ==.

I've also tried:
COPY SBKACDET REPLACING ==(PR)-== BY ==' '==.

Neither of these statements work as I get compile errors. I'm using a
COBOL II compiler. My question is:

Is it possible to replace a string by spaces using the COPY/REPLACING
statement?

Sandra.

suzie

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to
from the ibm vs cobol for os/vs manual:
A character string for pseudo-text is a complete cobol word; the prefix
portion of a data name, for example, cannot be replaced using
pseudo-text unless the entire data name is used. That is, when using
pseudo-text, you can only replace entire data names and not just
specific portions of them.

if (pr)- is the complete data name, could i suggest using the cobol
reserve word SPACES?

hth,
suzie

Joseph Kohler

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to

SR wrote:
>
> I want to copy a copybook into my program and replace all occurrences of
> (PR)- in the copybook by spaces.
>
> My statement looks like this:
> COPY SBKACDET REPLACING ==(PR)-== BY == ==.
>
> I've also tried:
> COPY SBKACDET REPLACING ==(PR)-== BY ==' '==.
>
> Neither of these statements work as I get compile errors. I'm using a
> COBOL II compiler. My question is:
>
> Is it possible to replace a string by spaces using the COPY/REPLACING
> statement?
>
> Sandra.

Sandra,
Try this:


COPY SBKACDET REPLACING ==(PR)-== BY ==''==.

This is the NULL operand and *should* work. If not then the copybook
tag should be redefined as null and replaced when needed.

--
Joe
+-------------------------------------------------------+
| Nothing is fool-proof to a sufficiently talented fool.|
+-------------------------------------------------------+
| In order to reply via e-mail address as follows: |
| jkohler at compuserve dot com |
| replace the at and dot with the appropriate symbols. |
+-------------------------------------------------------+

Kevin Bender

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to


SR wrote:

> I want to copy a copybook into my program and replace all occurrences of
> (PR)- in the copybook by spaces.
>
> My statement looks like this:
> COPY SBKACDET REPLACING ==(PR)-== BY == ==.
>
> I've also tried:
> COPY SBKACDET REPLACING ==(PR)-== BY ==' '==.
>
> Neither of these statements work as I get compile errors. I'm using a
> COBOL II compiler. My question is:
>
> Is it possible to replace a string by spaces using the COPY/REPLACING
> statement?
>
> Sandra.

Sandra,
This works for me using Microfocus ver 4.0.32 and COBOL II (4)
directives. Below shows
result after 'checking' the program. I hope this helps
Kevin.

IDENTIFICATION DIVISION.
PROGRAM-ID. TESTIT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.

*--------------------------------------------------------------*
* The following is the copy member 'copybook'
* presented as a comment for illustration purposes.
*--------------------------------------------------------------*
**01 TESTX.
* 05 :PR-:TEST-FIELD-1 PIC X.
* 05 :PR-:TEST-FIELD-2 PIC X.
* 05 TEST-:PR-:FIELD-3 PIC X.
*
01 TESTX. COPY COPYBOOK REPLACING == :PR-: == BY == ==.
**01 TESTX.
05 TEST-FIELD-1 PIC X.
05 TEST-FIELD-2 PIC X.
05 TEST-FIELD-3 PIC X.

PROCEDURE DIVISION.

GOBACK
.

Chris Westbury

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to

In article <01bd408c$81bd2e20$ac29...@t658mdg.iol.ie>,

"SR" <t65...@iol.ie> wrote:
>
> COPY SBKACDET REPLACING ==(PR)-== BY == ==.
[...]

> Is it possible to replace a string by spaces using the COPY/REPLACING
> statement?

The REPLACING option works on text-words, not on strings. (PR)- is not a
text-word. What you want to do is something more like this:

COPY SBKACDET REPLACING ==(PR-)== BY == ==.

The parens are not part of the language. You put them around strings in
the copy that you intend to REPLACE to fool the compiler into seeing
text-words. You could even do it this way:

COPY SBKACDET REPLACING ==)PR-(== BY == ==.

PS: It's not necessary to put parens into copy text at all if you use
proper qualification.


--
Christopher Westbury, Midtown Associates, 15 Fallon Place, Cambridge, MA 02138

Kevin

unread,
Feb 24, 1998, 3:00:00 AM2/24/98
to

On Mon, 23 Feb 1998 13:30:45 -0600, suzie
<hig...@dhfs.state.wisconsin.unitedstates> wrote:

>SR wrote:
>>
>> I want to copy a copybook into my program and replace all occurrences of
>> (PR)- in the copybook by spaces.
>>
>> My statement looks like this:
>> COPY SBKACDET REPLACING ==(PR)-== BY == ==.
>>
>> I've also tried:

>> COPY SBKACDET REPLACING ==(PR)-== BY ==' '==.
>>

>> Neither of these statements work as I get compile errors. I'm using a
>> COBOL II compiler. My question is:
>>

>> Is it possible to replace a string by spaces using the COPY/REPLACING
>> statement?
>>

>> Sandra.
>from the ibm vs cobol for os/vs manual:
>A character string for pseudo-text is a complete cobol word; the prefix
>portion of a data name, for example, cannot be replaced using
>pseudo-text unless the entire data name is used. That is, when using
>pseudo-text, you can only replace entire data names and not just
>specific portions of them.
>
>if (pr)- is the complete data name, could i suggest using the cobol
>reserve word SPACES?
>
>hth,
>suzie

I'll agree with Suzie. I "believe" we were able to just replace part
of the name with the 74 version (IBM) but CobII enforces the standard.


Cheers,
Kevin

Art Perry

unread,
Feb 24, 1998, 3:00:00 AM2/24/98
to

Christopher-

Can you clarify what you mean by "Text-Words" we are having the same
problem here with our COBOL II compiler.

-Thanks

Art

--
Arthur Perry
EDS Chicago Resource Center
(remove 88 from email address to reply)

Chris Westbury wrote in message <1998Feb23.211428.18730@giant>...


>In article <01bd408c$81bd2e20$ac29...@t658mdg.iol.ie>,
>"SR" <t65...@iol.ie> wrote:

snip

William M. Klein

unread,
Feb 24, 1998, 3:00:00 AM2/24/98
to

The definition of a text-word is very specific and is well documented in the
VS COBOL II (and all other IBM - and non-IBM) manuals. The bottom-line is
that "partial word" replacement is not really supported (but see below) -
and wasn't in OS/VS COBOL or any other ANSI conforming compiler.

Definition of "text word" follows:

"* text word. A character or a sequence of contiguous characters between
margin A and margin R in a COBOL library, source program, or in pseudo-text
which is:

1) A separator, except for: space; a pseudo-text delimiter; and the opening
and closing delimiters for nonnumeric literals. The right parenthesis and
left parenthesis characters, regardless of context within the library,
source program, or pseudo-text, are always considered text words.

2) A literal including, in the case of nonnumeric literals, the opening
quotation mark and the closing quotation mark that bound the literal.

3) Any other sequence of contiguous COBOL characters except comment lines
and the word 'COPY' bounded by separators that are neither a separator nor a
literal. "

There are ways to do copy/replacing and get partial word replacement - but
they are basically "tricks" and they only work on source code that will NOT
compile cleanly without the replacement, e.g.

Library text looks like.

01 :Tag:.
05 :Tag:rest-of-1 Pic X.
05 :Tag:rest-of-2 Pic 9.

And a copy statement of

Copy whatever replacing ==:Tag:== by ==new-prefix-==.

Please note that the original source code would get compiler-errors if you
tried to compile it without REPLACING, but will compile cleanly with
replacing. You can use a few symbols other than a colon, but the list is
very limited.

--
+ +
+ Bill Klein -
"C" is a nice letter to START the name of your programming language
with
but I wouldn't want to end up there.

Art Perry wrote in message <6cuktm$hoe$1...@news.ses.cio.eds.com>...

Ken Foskey

unread,
Feb 25, 1998, 3:00:00 AM2/25/98
to

On Mon, 23 Feb 1998 13:30:45 -0600, suzie
<hig...@dhfs.state.wisconsin.unitedstates> wrote:

>SR wrote:
>>
>> I want to copy a copybook into my program and replace all occurrences of
>> (PR)- in the copybook by spaces.
>>
>> My statement looks like this:
>> COPY SBKACDET REPLACING ==(PR)-== BY == ==.
>>
>> I've also tried:
>> COPY SBKACDET REPLACING ==(PR)-== BY ==' '==.
>>
>> Neither of these statements work as I get compile errors. I'm using a
>> COBOL II compiler. My question is:
>>
>> Is it possible to replace a string by spaces using the COPY/REPLACING
>> statement?
>>
>> Sandra.
>from the ibm vs cobol for os/vs manual:
>A character string for pseudo-text is a complete cobol word; the prefix
>portion of a data name, for example, cannot be replaced using
>pseudo-text unless the entire data name is used. That is, when using
>pseudo-text, you can only replace entire data names and not just
>specific portions of them.
>
>if (pr)- is the complete data name, could i suggest using the cobol
>reserve word SPACES?
>
>hth,
>suzie

The statement above is basically correct. What it misses and the
first post almost gets is that the definition of a word can be '(PR)'
because it is not actually an identifier per se.

I would recommend the you use '(PR-)' in the copybook. If it not to
late (multiple programs already using it). I can't test it right now
I am sorry.

HTH,
Ken

Fred van Deelen

unread,
Mar 8, 1998, 3:00:00 AM3/8/98
to

In article <01bd408c$81bd2e20$ac29...@t658mdg.iol.ie>, t65...@iol.ie
says...

> I want to copy a copybook into my program and replace all occurrences of
> (PR)- in the copybook by spaces.
>
> My statement looks like this:
> COPY SBKACDET REPLACING ==(PR)-== BY == ==.
>
> I've also tried:
> COPY SBKACDET REPLACING ==(PR)-== BY ==' '==.
>
> Neither of these statements work as I get compile errors. I'm using a
> COBOL II compiler. My question is:

Try this:

COPY SBKACDET REPLACING ==(PR)-== BY SPACES

Groeten,

Fred van Deelen.


**************************************************************
*** Als je het niet zelf hebt getest, dan werkt het niet ***
**************************************************************

Sff5ky

unread,
Mar 8, 1998, 3:00:00 AM3/8/98
to

In article <MPG.f6bf2a92...@news.bART.nl>, fvde...@bart.nl (Fred van
Deelen) writes:

>In article <01bd408c$81bd2e20$ac29...@t658mdg.iol.ie>, t65...@iol.ie
>says...
>> I want to copy a copybook into my program and replace all occurrences of
>> (PR)- in the copybook by spaces.
>>
>> My statement looks like this:
>> COPY SBKACDET REPLACING ==(PR)-== BY == ==.
>>
>> I've also tried:
>> COPY SBKACDET REPLACING ==(PR)-== BY ==' '==.
>>
>> Neither of these statements work as I get compile errors. I'm using a
>> COBOL II compiler. My question is:
>
>Try this:
>
>COPY SBKACDET REPLACING ==(PR)-== BY SPACES
>
>Groeten,
>
>Fred van Deelen.
>
>

I was not aware that the copy replacing syntax worked on partial strings.
It is my understanding that the replacement is performed on whole strings (
delimited by spaces ) and the replacement has to be the exact size ( no less
and
no more ). I have heard of setting up entirely generic libraries that allow
for
complete replacement of fields, but found this to be very cumbersome in the
imlpementation and maintenance.

William M. Klein

unread,
Mar 8, 1998, 3:00:00 AM3/8/98
to

Sff5ky wrote in message <19980308172...@ladder03.news.aol.com>...

The current COPY/REPLACING does only work on whole words, but it is "text
words" and not "COBOL words" . The definition of text words (in the 85 but
not the 74 Standard) says that left and right parenthesis are ALWAYS text
words and do not need spaces before/after them (similarly colon works the
same way). That is why something like

(PR-)This

is made up of 4 text words "(" "PR-" ")" and "This". This means that you
can replace any or all of them.

P.S. There is actually an obscure problem with call "PR-" a text word and I
have raised this issue with J4, but for all practical purposes, it should be
considered a text word.

Note: One of the earlier posts in this thread explained that the error with
the example was that it had ==(PR)-== which won't work while ==(PR-)== will
work.

0 new messages